longbowrocks Posted February 11, 2018 Posted February 11, 2018 (edited) I've been running into java.lang.NoSuchMethodError: net.minecraft.client.Minecraft.getMinecraft() while creating a 1.11.2/1.12.2 mod, and finally (I think) figured out that it was occurring because TickEvent.ClientTickEvent is NOT restricted to the logical client, but rather to the physical client, which may include a logical server. I was satisfied with this answer until I looked at other mods to see how they checked for logical sidedness without calling Minecraft.getMinecraft().isRemote. From what I can see, most mods are just checking physical sidedness: Tinker's Construct: @SubscribeEvent @SideOnly(Side.CLIENT) public void playerJoinedWorld(TickEvent.ClientTickEvent event) { EntityPlayerSP player = Minecraft.getMinecraft().player; Astral Sorcery: @SubscribeEvent @SideOnly(Side.CLIENT) public void onTick(TickEvent.ClientTickEvent event) { if(event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().player != null) { JustEnoughItems: @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { if (event.side == Side.CLIENT && SessionData.hasJoinedWorld() && Minecraft.getMinecraft().player != null) { inventorytweaks (Actually works, but the above three should work too and they don't): @SubscribeEvent public void onTick(@NotNull TickEvent.ClientTickEvent tick) { if(tick.phase == TickEvent.Phase.START) { Minecraft mc = FMLClientHandler.instance().getClient(); My question is: Why aren't these mods receiving ClientTickEvents on the logical server? Have I misunderstood what my problem is? Is there some hocus-pocus that will allow me to do what they're doing (if I copy the code for the first three, I still get NoSuchMethodError)? Edited February 11, 2018 by longbowrocks clarity Quote
Draco18s Posted February 11, 2018 Posted February 11, 2018 On 2/11/2018 at 2:45 AM, longbowrocks said: My question is: Why aren't these mods receiving ClientTickEvents on the logical server? Expand I would assume that that question answers itself. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
longbowrocks Posted February 11, 2018 Author Posted February 11, 2018 (edited) On 2/11/2018 at 2:54 AM, Draco18s said: I would assume that that question answers itself. Expand That was my initial thinking, until I started getting NoSuchMethodError: Minecraft.getMinecraft() which means I was getting this event in a server context. Additionally, if the name had any bearing on where the event was received, those other mods shouldn't need a @SideOnly decorator. Edited February 11, 2018 by longbowrocks Original edit could have been misconstrued as confrontational. Current is slightly less clear, but overall better Quote
longbowrocks Posted February 11, 2018 Author Posted February 11, 2018 Alright, solved it: The problem I was having was not what I thought: Minecraft.getMinecraft() actually was in my classloader (probably, if I'm right this time). The issue was that running the jar gradle task under build doesn't reobfuscate the code (correctly? at all?), so you end up with a jar that doesn't work with you minecraft installation, because it looks up methods and other names in the wrong place. The correct way to do it is to run the build gradle task under build, and copy the jar that doesn't have any suffixes. The @SideOnly annotation is probably just there to keep certain classes from showing up on the physical server. Quote
Draco18s Posted February 11, 2018 Posted February 11, 2018 On 2/11/2018 at 4:16 AM, longbowrocks said: The @SideOnly annotation is probably just there to keep certain classes from showing up on the physical server. Expand Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.