TripleCF Posted December 29, 2021 Share Posted December 29, 2021 (edited) @Mod.EventBusSubscriber(modid = challengemod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.DEDICATED_SERVER) public class Test { private boolean toggled = true; @SubscribeEvent public void onTick(TickEvent.WorldTickEvent event) { System.out.println("tickerticker"); if(toggled){ if (Minecraft.getInstance().player != null) { System.out.println("tick"); } } Hi I watched some tutorials but somehow it just doesn't register. Nothing happens. Any idea? From what I heard you don't need to register them in the main class but the way I do it here just outputs nothing. Oh btw when I had the same thing in my main class it worked fine. Edited December 29, 2021 by TripleCF Added information Quote Link to comment Share on other sites More sharing options...
TripleCF Posted December 29, 2021 Author Share Posted December 29, 2021 Ok so thanks alot for the fast reply. Thing is following: My method can't be static as far as I know because I use some variables out of the class. Then it should be running in Singleplayer but It should control the world so I thought world event tick would fit best. I registered the event now by doing MinecraftForge.EVENT_BUS.register(new Test()) which somehow works. But from a good qualitiy coding aspect should I instead use a non static method and change the tick event to client? Quote Link to comment Share on other sites More sharing options...
TripleCF Posted December 29, 2021 Author Share Posted December 29, 2021 Ok I get your points. Thing was I tried having my tick method static but IntelliJ showed me an error on my boolean toggled: Non static field cannot be referenced from a static context. I probably have a bit of misunderstanding of the static constructor. I changed the boolean toggled to static as well as the method which lead to it working. I think I also understand the sides a bit better. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
TripleCF Posted December 29, 2021 Author Share Posted December 29, 2021 1 hour ago, diesieben07 said: Please learn basic Java. There is no such thing as a "static constructor". These still apply. Im not english so I don't know the name. I think the official term for it is access modifier or so. Doesn't change anything about java knowledge Quote Link to comment Share on other sites More sharing options...
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.