Posted June 24, 201411 yr 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]
June 24, 201411 yr Author 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]
June 24, 201411 yr 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.
June 24, 201411 yr Author 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]
June 24, 201411 yr 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.
June 24, 201411 yr As mentioned there are different event buses. In my tutorial on events I explain which events are on which busses, so it might be interesting to you (either this time or in the future next time you are considering using events): http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.