Elix_x Posted August 22, 2015 Posted August 22, 2015 Hello! Today, i'm here with really strange issue, caused by something unknown to me: I did not happen to me, but of one users who downloaded the mod, put it on server and joined server. Here's part of server log that contains the issue: [22:14:34] [server thread/ERROR] [FML/]: Exception caught during firing event cpw.mods.fml.common.gameevent.TickEvent$PlayerTickEvent@862de2b: java.lang.NoSuchMethodError: net.minecraft.entity.player.EntityPlayer.func_71011_bu()Lnet/minecraft/item/ItemStack; at code.elix_x.mods.teleplates.teleplates.TeleportationManager.onPlayerUpdate(TeleportationManager.java:50) ~[TeleportationManager.class:?] at code.elix_x.mods.teleplates.events.OnPlayerTickEvent.tick(OnPlayerTickEvent.java:17) ~[OnPlayerTickEvent.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_470_OnPlayerTickEvent_tick_PlayerTickEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) [EventBus.class:?] at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345) [FMLCommonHandler.class:?] at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:220) [yz.class:?] at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:295) [mw.class:?] at net.minecraft.network.NetHandlerPlayServer.func_147347_a(NetHandlerPlayServer.java:303) [nh.class:?] at net.minecraft.network.play.client.C03PacketPlayer.func_148833_a(SourceFile:137) [jd.class:?] at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.func_148833_a(SourceFile:20) [jf.class:?] at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:212) [ej.class:?] at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:165) [nc.class:?] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:659) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334) [lt.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?] The issue happens on line 50 of TeleportationManager, so here's line 50 of TeleportationManager: if(player.rotationPitch == 90 && ((block == TeleplatesBase.teleplate && EnergyManager.canTeleportFromTeleplate(player)) || (player.getItemInUse() != null && player.getItemInUse().getItem() == TeleplatesBase.portableTeleplate && EnergyManager.canTeleportFromPortableTeleplate(player)))){ As you can see, EntityPlayer.func_71011_bu() can only be player.getItemInUse() (it's the only called 1 param player method that returns ItemStack). So apearently, something wrong went with obfuscation of the mod... Although BUILD SUCESSFULL... In total, i'm confused in what have caused this... It seems that something else caused this error. Obfuscator? Different forge versions? MCP mappings? 3rd party coremod? What? Original issue topic: http://www.minecraftforge.net/forum/index.php/topic,33187 Thanks for help! If you have any questions - just ask! Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
Choonster Posted August 22, 2015 Posted August 22, 2015 EntityPlayer#getItemInUse is marked as @SideOnly(Side.CLIENT) , which means that it doesn't exist on the server. To access the EntityPlayer#itemInUse field on the server, you'll need to use reflection or an access transformer. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Elix_x Posted August 22, 2015 Author Posted August 22, 2015 EntityPlayer#getItemInUse is marked as @SideOnly(Side.CLIENT) , which means that it doesn't exist on the server. To access the EntityPlayer#itemInUse field on the server, you'll need to use reflection or an access transformer. Why is it so? It's illogical... Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
TheGreyGhost Posted August 22, 2015 Posted August 22, 2015 EntityPlayer#getItemInUse is marked as @SideOnly(Side.CLIENT) , which means that it doesn't exist on the server. To access the EntityPlayer#itemInUse field on the server, you'll need to use reflection or an access transformer. Why is it so? It's illogical... The Dedicated Server doesn't have a lot of the client-side code because it's not necessary if there's no local client. I guess none of the dedicated server code needs to access itemInUse from outside EntityPlayer, so they never added a getter on that side. Anyhow as Choonster said you can either use Reflection, an Access Transformer, or alternatively PlayerUseItemEvent and isUsingItem(). If you just want to access a private field it's pretty easy, eg @SideOnly(Side.CLIENT) public class KeyBindingInterceptor { private static final Field pressTimeField = ReflectionHelper.findField(KeyBinding.class, "pressTime", "field_151474_i"); // unobfuscated name, and obfuscatedname //... int value = 0; try { value = pressTimeField.getInt(keyBinding, 0); } catch (Exception e) { throw Throwables.propagate(e); } } -TGG Quote
Elix_x Posted August 22, 2015 Author Posted August 22, 2015 EntityPlayer#getItemInUse is marked as @SideOnly(Side.CLIENT) , which means that it doesn't exist on the server. To access the EntityPlayer#itemInUse field on the server, you'll need to use reflection or an access transformer. Why is it so? It's illogical... The Dedicated Server doesn't have a lot of the client-side code because it's not necessary if there's no local client. I guess none of the dedicated server code needs to access itemInUse from outside EntityPlayer, so they never added a getter on that side. Anyhow as Choonster said you can either use Reflection, an Access Transformer, or alternatively PlayerUseItemEvent and isUsingItem(). If you just want to access a private field it's pretty easy, eg @SideOnly(Side.CLIENT) public class KeyBindingInterceptor { private static final Field pressTimeField = ReflectionHelper.findField(KeyBinding.class, "pressTime", "field_151474_i"); // unobfuscated name, and obfuscatedname //... int value = 0; try { value = pressTimeField.getInt(keyBinding, 0); } catch (Exception e) { throw Throwables.propagate(e); } } -TGG I know how to use both reflection and ats to be friendly with obfuscation, don''t worry. The thing is that i have to check it every tick for each player. So the question of performance is here... Also, why can't forge add their both sides getter method? Perhaps, i could add it myself, if only i could install forge on my pc, but i can't: running gradlew setupForge in cloned forge, stops at :git and then build failed . Where should i report this, by the way??? Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
coolAlias Posted August 22, 2015 Posted August 22, 2015 You can use player.isUsingItem() without any issues, and if that's true, use player.getHeldItem() to get the item being used. No need for Reflection here. Quote http://i.imgur.com/NdrFdld.png[/img]
Elix_x Posted August 22, 2015 Author Posted August 22, 2015 You can use player.isUsingItem() without any issues, and if that's true, use player.getHeldItem() to get the item being used. No need for Reflection here. Thanks. That is the way to go too... Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
TheGreyGhost Posted August 22, 2015 Posted August 22, 2015 HI I know how to use both reflection and ats to be friendly with obfuscation, don''t worry. The thing is that i have to check it every tick for each player. So the question of performance is here... 100% for sure using Reflection to get this field once per tick will not be noticeable. You could do it a million times per tick and the user probably still wouldn't notice. Just a comment - if you haven't specifically designed your mod to work with DedicatedServer, then it's a pretty good bet a whole pile of other things will break. If one of your classes has any mention of a vanilla client-side class, the classloader for your classes will often cause a crash even if the code that uses the client-side class is never ever executed. > You can use player.isUsingItem() without any issues, and if that's true, use player.getHeldItem() to get the item being used. No need for Reflection here. Didn't think of that... it's probably safe to assume they're always the same... probably... -TGG Quote
coolAlias Posted August 22, 2015 Posted August 22, 2015 > You can use player.isUsingItem() without any issues, and if that's true, use player.getHeldItem() to get the item being used. No need for Reflection here. Didn't think of that... it's probably safe to assume they're always the same... probably... At least until 1.9 Quote http://i.imgur.com/NdrFdld.png[/img]
Elix_x Posted August 23, 2015 Author Posted August 23, 2015 > You can use player.isUsingItem() without any issues, and if that's true, use player.getHeldItem() to get the item being used. No need for Reflection here. Didn't think of that... it's probably safe to assume they're always the same... probably... At least until 1.9 Yep... Forge and modders will have fun with 1.9 for sure Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.