Jump to content

LivingDeathEvent not working


NeverMind

Recommended Posts

I made this method to give the player more xp when he kills a mob, but it doesn't work, it simply does nothing.

 

@SubscribeEvent

public void itDied(LivingDeathEvent event)

{

Entity entity = event.entity;

DamageSource source = event.source;

System.out.println("ASTA MERGE !111111111111");

if (source.getSourceOfDamage() instanceof EntityPlayer)

{

System.out.println("ASTA MERGE!!!!");

if (event.entity instanceof EntityMob)

{

System.out.println("ASTA MERGE!!! 222222");

EntityPlayer player = (EntityPlayer) event.source.getEntity();

player.addExperience(1000);

}

}

}

 

 

 

This is the part from my main modding class:

 

public void preInit(FMLPreInitializationEvent e)

{

 

FMLCommonHandler.instance().bus().register(new PlayerEventHandler());

}

Link to comment
Share on other sites

@Nevermind, the code example was an example and the TheClassWhereYouHaveYouExperienceStuff needs to be changed to the name of your event handler class.

 

Based on your previous code posted above, I think you called it PlayerEventHandler, so in that case it would be:

MinecraftForge.EVENT_BUS.register(new PlayerEventHandler());

 

By the way if you want to know more about event handlers, I have a tutorial with list of which events are on which bus (and explanation on how to check package to figure this out yourself), see: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.