Posted February 16, 201510 yr I am attempting to update my event handlers to 1.7.10, but for some reason, they are not being called. Here are the main file and event handler files (Edited for relevancy): @EventHandler public void preLoad(FMLPreInitializationEvent event) { snw = NetworkRegistry.INSTANCE.newSimpleChannel(modid); snw.registerMessage(TimeTravelerPacketHandler.class, Message.class, 0, Side.CLIENT); FMLCommonHandler.instance().bus().register(new TTEventHandler()); FMLCommonHandler.instance().bus().register(new Ticker()); MinecraftForge.EVENT_BUS.register(new TTEventHandler()); MinecraftForge.EVENT_BUS.register(new Ticker()); } @SubscribeEvent public void onItemTossEvent(ItemTossEvent ev) throws IOException { System.out.println("EVENTS WORKING"); List<PastAction> aList = TimeTraveler.instance.getActionListForPlayer(ev.player); if (aList != null) { PastAction ma = new PastAction(PastActionTypes.DROP); ev.entityItem.getEntityItem().writeToNBT(ma.itemData); aList.add(ma); } } I have tried moving the FMLCommon lines to both the PreInit and Init to no avail.
February 16, 201510 yr do MinecraftForge.EVENT_BUS.register with your handlers as well Maker of the Craft++ mod.
February 16, 201510 yr Author TTEventTicker is now working, but Ticker is not. Ticker is as follows: package timeTraveler.ticker; import java.io.File; import java.util.EnumSet; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiScreen; import net.minecraft.potion.Potion; import timeTraveler.core.TimeTraveler; import timeTraveler.gui.GuiTimeTravel; import timeTraveler.mechanics.CopyFile; import timeTraveler.pasttravel.PastMechanics; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; /** * Ticker * @author Charsmud * */ public class Ticker { public int ctr; public int ct; public int count; public static int paradoxLevel; public static int seconds = 1; public static int minutes = 5; public int invisPotTime = 0; public int sneakTime = 0; private int timeNumber = 1; private int pathFileLine = 0; private int hunterSpawn = 0; String text; CopyFile copyFile = new CopyFile(); public boolean hasInitRun = false; public boolean hasInitMobs = false; private boolean mobsInitSpawned = false; private boolean isInPast; private boolean hasRun = false; @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { paradoxLevel = TimeTraveler.vars.getParadoxAmt(); } @SubscribeEvent private void onWorldTick(WorldTickEvent event) { System.out.println("TICK"); Minecraft mc = Minecraft.getMinecraft(); ctr++; ct++; hasInitRun = (new File(mc.mcDataDir + "/mods/TimeMod/past/" + FMLClientHandler.instance().getServer().getWorldName())).exists(); PastMechanics mechanics = new PastMechanics(); text = "Time Remaining: " + minutes + " Minute, " + seconds + " Seconds"; isInPast = GuiTimeTravel.isInPast; if(!isInPast && !TimeTraveler.vars.getIsInFuture()) { TimeTraveler.vars.setIsSpawnedPastPlayer(false); if(mc.thePlayer.isSneaking()) { } if(paradoxLevel >= 30) { hunterSpawn++; if(hunterSpawn == 150) { mechanics.spawnParadoxHunter(mc.getIntegratedServer(), mc); System.out.println("Spawned Paradox Hunter!"); hunterSpawn = 0; } } } if(ct == 20) { if(!isInPast && !TimeTraveler.vars.getIsInFuture()) { ct = 0; } } if(ctr == 5140) { if(!isInPast && !TimeTraveler.vars.getIsInFuture()) { mechanics.saveTime(mc.getIntegratedServer(), mc, copyFile); mechanics.beginPastRecording(FMLClientHandler.instance().getClient().thePlayer, FMLClientHandler.instance().getClient().thePlayer.getDisplayName()); mechanics.beginPastRecording(FMLClientHandler.instance().getClient().thePlayer, FMLClientHandler.instance().getClient().thePlayer.getDisplayName()); } ctr = 0; } if(!hasInitRun) { hasInitRun = true; mechanics.firstTime(mc.getIntegratedServer(), mc); mechanics.saveTime(mc.getIntegratedServer(), mc, copyFile); } if(!hasRun) { hasRun = true; mechanics.beginPastRecording(FMLClientHandler.instance().getClient().thePlayer, FMLClientHandler.instance().getClient().thePlayer.getDisplayName()); } if(isInPast) { if(!TimeTraveler.vars.getIsSpawnedPastPlayer()) { mechanics.replayPast(mc.thePlayer); TimeTraveler.vars.setIsSpawnedPastPlayer(true); } if(TimeTraveler.vars.getNextSet()) { } count++; if(paradoxLevel < 0) { paradoxLevel = 0; } if(paradoxLevel <= 128) { EntityPlayerSP eps = mc.thePlayer; if(eps.isPotionActive(Potion.invisibility)) { invisPotTime++; if(invisPotTime == 10) { paradoxLevel = paradoxLevel - 5; invisPotTime = 0; } } if(eps.isSneaking()) { sneakTime++; if(sneakTime == 30) { paradoxLevel = paradoxLevel - 2; sneakTime = 0; } } } else { mechanics.returnToPresent(mc, paradoxLevel, mc.getIntegratedServer()); mobsInitSpawned = false; isInPast = false; TimeTraveler.vars.setNextSet(true); } } if(isInPast) { if(count == 20) { seconds--; count = 0; } if(seconds == 0) { minutes--; seconds = 60; } if(minutes == 0) { text = "Time Remaining: " + seconds + " Seconds"; } if(minutes <= 0 && seconds <= 1) { mechanics.outOfTime(mc, mc.getIntegratedServer(), text); mobsInitSpawned = false; isInPast = false; TimeTraveler.vars.setNextSet(true); } } TimeTraveler.vars.setParadoxAmt(paradoxLevel); } @SubscribeEvent private void onRenderTick(TickEvent.RenderTickEvent event) { Minecraft mc = FMLClientHandler.instance().getClient(); PastMechanics mechanics = new PastMechanics(); if(mc.currentScreen == null) { if(isInPast) { mechanics.drawTimeTicker(mc, text); } mechanics.updateParadoxBar(mc, paradoxLevel); } } }
February 16, 201510 yr Author I used TickType.CLIENT. And whether or not the code is correctly optimized, it was never designed for a multiplayer experience, so I didn't bother trying to make it one (Plus this project has been going on for a few years and I haven't gotten around to renovating the old code, which most of this is).
February 17, 201510 yr Author Still, the System.out.println is not printing when I change it to ClientTickEvent, and the code inside is not running.
February 18, 201510 yr Author Yes, I currently have both FMLCommonHandler.instance().bus().register(new Ticker()); and MinecraftForge.EVENT_BUS.register(new Ticker());
February 18, 201510 yr Any event listener method that you write MUST be public for it to be called by Forge / FML event bus. TickEvents are only on the FML bus, so if your class contains only those events, you only need to register it on the one bus, not both. http://i.imgur.com/NdrFdld.png[/img]
February 18, 201510 yr Yes, I currently have both FMLCommonHandler.instance().bus().register(new Ticker()); and MinecraftForge.EVENT_BUS.register(new Ticker()); Please post your current code. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 18, 201510 yr I have edited the OP with the updated code. And? Does it still not work? Can you show the ENTIRE class in which you listen for ItemCraftedEvent? And why are you declaring your method as throwing an IOException? http://i.imgur.com/NdrFdld.png[/img]
February 18, 201510 yr Author TTEventHandler works, but Ticker does not. EDIT: I fixed it by changing private to public for the @ForgeSubscribe methods.
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.