Posted June 13, 20169 yr I am making a sword that will kill anything, but I've run into a problem. I am using EntityLivingBase#setHealth() to set the mob's health to zero. However when I use setHealth() zero the mob does not drop any drops. I am guessing that this is because setHealth() bypasses all hurt and death events. But the reason I'm using setHealth() zero is because I want to bypass all hurt and death events, so that other mods can't cancel the death event to bypass my sword. So is there a way to trigger the death and hurt events without having them cancelable? Heres my current code: @Override public boolean onLeftClickEntity(ItemStack item, EntityPlayer player, Entity entity) { if (entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isCreativeMode) return false; if (entity instanceof EntityLivingBase) { EntityLivingBase mob = (EntityLivingBase) entity; EntityHelper.knockbackEntity(player, mob); mob.setHealth(0); } return true; }
June 13, 20169 yr Author Is there at least a way to trigger the death event? I was looking at ForgeEventFactory but there was no onDeath method.
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.