Posted December 31, 20159 yr Hello guys, I tried to make a class, which registers my EventHandlers (there is only one yet). But I can't get it working. Here is, what I coded until now: Main Class: package de.Femtopedia.titantoolbox; import de.Femtopedia.titantoolbox.Constants.Constants; import de.Femtopedia.titantoolbox.Skype.skypemethods; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid=Constants.MODID, version=Constants.VERSION, name=Constants.NAME) public class titantoolbox { @Instance public static titantoolbox instance = new titantoolbox(); @EventHandler public void preInit(FMLPreInitializationEvent e) { } @EventHandler public void init(FMLInitializationEvent e) { FMLCommonHandler.instance().bus().register(new titantoolboxDCHandler()); } @EventHandler public void postInit(FMLPostInitializationEvent e) { } } EventHandler-Class: package de.Femtopedia.titantoolbox; import de.Femtopedia.titantoolbox.Constants.Constants; import de.Femtopedia.titantoolbox.Skype.skypemethods; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; public class titantoolboxDCHandler { @SubscribeEvent public void clientConnection(ClientConnectedToServerEvent e) { System.out.println("Message"); } } Bringing the best mod back alive! Our mod REFORGED! Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases
December 31, 20159 yr You need to check if the connection is local when running a singleplayer world. To do this, do something like this: @SubscribeEvent public void onJoin(ClientConnectedToServerEvent event) { if(event.isLocal) { System.out.println("Local Connection"); }else { System.out.println("Server Connection"); } } As you can see, I check if the client is on a local server, and print in the console accordingly. When you do not check if it is local, you need to run a server within forge, and join it from the client. When you do, it will print out whatever you'd like in the server console. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
December 31, 20159 yr Author Thanks for the answer, got it working now. Bringing the best mod back alive! Our mod REFORGED! Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases
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.