List of usage examples for net.minecraftforge.event.entity.living LivingDamageEvent getAmount
public float getAmount()
From source file:com.lothrazar.cyclicmagic.item.SoulstoneItem.java
License:Open Source License
@SubscribeEvent(priority = EventPriority.LOWEST) public void onLivingDamageEvent(LivingDamageEvent event) { //used to be net.minecraftforge.event.entity.living.LivingHurtEvent float currentHealth = event.getEntityLiving().getAbsorptionAmount() + event.getEntityLiving().getHealth(); if (currentHealth - event.getAmount() <= 0 && event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { ItemStack stack = player.inventory.getStackInSlot(i); if (stack.getItem() instanceof SoulstoneItem) { player.inventory.setInventorySlotContents(i, ItemStack.EMPTY); player.setHealth(HEALTH_AFTER_TRIGGER); applyPotions(player);/*from www. j a va 2s . c o m*/ UtilSound.playSound(player, SoundEvents.BLOCK_GLASS_BREAK); UtilChat.addChatMessage(player, event.getEntityLiving().getName() + UtilChat.lang("item.soulstone.used")); event.setCanceled(true); break; } } } }