Java Code Examples for net.minecraftforge.event.entity.living.LivingDeathEvent#setCanceled()
The following examples show how to use
net.minecraftforge.event.entity.living.LivingDeathEvent#setCanceled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentResurrect.java From Artifacts with MIT License | 6 votes |
@Override public void onDeath(ItemStack itemStack, LivingDeathEvent event, boolean isWornArmor) { System.out.println("ABORTING DEATH"); if(isWornArmor && !event.isCanceled()) { EntityPlayer player = (EntityPlayer)event.entity; NBTTagCompound data = itemStack.getTagCompound(); //System.out.println("Cooldown: " + data.getInteger("resCooldown")); if(data.getInteger("resCooldown_armor") <= 0) { event.setCanceled(true); player.setHealth(20); data.setInteger("resCooldown_armor", 6000); itemStack.damageItem(5, player); return; } } }
Example 2
Source File: ItemHeartUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent public void handleDeath(LivingDeathEvent event) { EntityLivingBase e = event.getEntityLiving(); ItemStack test = new ItemStack(this, 1, 0); if (CyberwareAPI.isCyberwareInstalled(e, test) && !event.isCanceled()) { ICyberwareUserData cyberware = CyberwareAPI.getCapability(e); ItemStack stack = CyberwareAPI.getCyberware(e, test); if ((!CyberwareAPI.getCyberwareNBT(stack).hasKey("used")) && cyberware.usePower(test, this.getPowerConsumption(test), false)) { ItemStack[] items = cyberware.getInstalledCyberware(EnumSlot.HEART); ItemStack[] itemsNew = items.clone(); for (int i = 0; i < items.length; i++) { ItemStack item = items[i]; if (item != null && item.getItem() == this && item.getItemDamage() == 0) { itemsNew[i] = null; break; } } if (e instanceof EntityPlayer) { cyberware.setInstalledCyberware(e, EnumSlot.HEART, itemsNew); cyberware.updateCapacity(); if (!e.worldObj.isRemote) { CyberwareAPI.updateData(e); } } else { stack = CyberwareAPI.getCyberware(e, test); NBTTagCompound com = CyberwareAPI.getCyberwareNBT(stack); com.setBoolean("used", true); stack.getTagCompound().setTag(CyberwareAPI.DATA_TAG, com); CyberwareAPI.updateData(e); } e.setHealth(e.getMaxHealth() / 3F); CyberwarePacketHandler.INSTANCE.sendToAllAround(new ParticlePacket(1, (float) e.posX, (float) e.posY + e.height / 2F, (float) e.posZ), new TargetPoint(e.worldObj.provider.getDimension(), e.posX, e.posY, e.posZ, 20)); event.setCanceled(true); } } }