Client-only method called from dedicated server
josephcsible opened this issue ยท 3 comments
Biome#getBiomeName()
is @SideOnly(Side.CLIENT)
but Item#getItemStackDisplayName
is not, so it's not safe to call it from here. Doing so causes crashes like this one on dedicated servers.
Here's another crash, this time triggered by RFTools Control instead of by Integrated Dynamics: https://gist.github.com/josephcsible/40b7451f0f01a8fae5d0910abe5e76ca
Also, you can get the error (but not a crash) with no other mods just by running /give @p randomthings:biomecrystal 1 0 {biomeName:"plains"}
on a dedicated server:
[16:09:57] [Server thread/WARN] [net.minecraft.command.CommandHandler]: Couldn't process command: give @p randomthings:biomecrystal 1 0 {biomeName:"plains"}
java.lang.NoSuchMethodError: net.minecraft.world.biome.Biome.func_185359_l()Ljava/lang/String;
at lumien.randomthings.item.ItemBiomeCrystal.func_77653_i(ItemBiomeCrystal.java:38) ~[ItemBiomeCrystal.class:?]
at net.minecraft.item.ItemStack.func_82833_r(ItemStack.java:617) ~[aip.class:?]
at net.minecraft.item.ItemStack.func_151000_E(ItemStack.java:1047) ~[aip.class:?]
at net.minecraft.command.CommandGive.func_184881_a(SourceFile:81) ~[cm.class:?]
at net.minecraft.command.CommandHandler.func_175786_a(CommandHandler.java:119) [bj.class:?]
at net.minecraft.command.CommandHandler.func_71556_a(CommandHandler.java:91) [bj.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:958) [pa.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:937) [pa.class:?]
at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:37) [la.class:?]
at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:9) [la.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [hv$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_151]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_151]
at net.minecraft.util.Util.func_181617_a(SourceFile:46) [h.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:721) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396) [nz.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
Note that biomeName itself isn't client-only; it's just its getter that is. RFTools Dimensions also uses biome names in item display names, and it handles it by using an access transformer and then just using the field directly. To fix this, you can either do that, or access the field reflectively. Which do you prefer?
37cd644 fixed the crash, but it causes a new bug. I'll open a new issue for it.