Jump to content

Recommended Posts

Posted

I want to give the player an achievement when they kill a specific mob, but I don't know how to do things when a mob dies.

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

Events are your friend.

 

I've tried LivingDeathEvent

@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
	System.out.println("Entity Death");
	Entity e = event.entityLiving;
	DamageSource source = event.source;

	if(source.getSourceOfDamage() instanceof EntityPlayer) {
		System.out.println("Player Kill!");
		if(e instanceof EntityZombie ) {
			System.out.println("Zombie Killed!");
			mobZombieKill = true;
		}
	}

}

@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
	if (mobZombieKill == true) {
		System.out.println("Achievement");
		event.player.addStat(ExtraAchievements.mobKillZombie, 1);
		mobZombieKill = false;
	}
}

and none of the "System.out.println"s get triggered.

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

Have you registered the event?

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

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

Have you registered the event?

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

I use

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

Unsure if it makes a diffrence

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

Big difference. If the event is in cpw's packages, use what you are using. If it is from Minecraft forge packages, use what I said.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

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.