Jump to content

Inconsistent Event-subsciption in eclipse vs built mod


WorldsEnder

Recommended Posts

I have the following classes:

 

package mhfc.net.common.eventhandler.quests;

import cpw.mods.fml.common.eventhandler.Event;

public abstract class QuestGoalEventHandler<EventType extends Event> {
NotifyableQuestGoal<EventType> questGoal;
boolean stillActive;
protected Class<EventType> eventType;

public QuestGoalEventHandler(NotifyableQuestGoal<EventType> g,
		Class<EventType> t) {
	this.questGoal = g;
	stillActive = false;
	this.eventType = t;
}

public abstract <E extends EventType> void onEventCaught(E event);

public void setActive(boolean active) {
	stillActive = active;
}
}

 

package mhfc.net.common.eventhandler.quests;

import net.minecraftforge.event.entity.living.LivingDeathEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class LivingDeathEventHandler
	extends
		QuestGoalEventHandler<LivingDeathEvent> {

public LivingDeathEventHandler(NotifyableQuestGoal<LivingDeathEvent> g) {
	super(g, LivingDeathEvent.class);
}

@Override
@SubscribeEvent
public void onEventCaught(LivingDeathEvent event) {
	if (stillActive)
		questGoal.notifyOfEvent(event);
}

}

 

At some point I call this piece of code:

MinecraftForge.EVENT_BUS.register(new LivingDeathEventHandler(this));

. Now the following is inconsistent.

When I execute and test the Mod in eclipse nothing special happens and everything runs smooth, the problem occurs after I built the mod and try it "in the wild":

 

java.lang.ClassCastException: net.minecraftforge.client.event.RenderLivingEvent$Specials$Pre cannot be cast to net.minecraftforge.event.entity.living.LivingDeathEvent
        at mhfc.net.common.eventhandler.quests.LivingDeathEventHandler.onEventCaught(LivingDeathEventHandler.java:6)

Full crash report can be found here: http://pastebin.com/8mBh7h9K

 

I can fully understand WHY this happens in the wild, if you can't refrain to this: http://stackoverflow.com/questions/28388034/

Why does forge think it has to call LivingDeathEventHandler.onEventCaught() for net.minecraftforge.client.event.RenderLivingEvent$Specials$Pre? When I analyze the produced classes I see the @SubscribeEvent annotation only on the method "onEventCaught(LivingDeathEvent)", so I don't see why the method should be registered for any other event at all.

 

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.