Jump to content

[1.7.10] EventHandlers not loading


charsmud

Recommended Posts

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. 

Link to comment
Share on other sites

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);
        }

}
}

Link to comment
Share on other sites

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). 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.