@Override public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) { if (player.worldObj.isRemote) return true; if (victim instanceof EntityPlayer) { EntityPlayer pvp = (EntityPlayer) victim; if (LudicrousItems.isInfinite(pvp)) { victim.attackEntityFrom( new DamageSourceInfinitySword(player).setDamageBypassesArmor(), 4.0F); return true; } if (pvp.getHeldItem() != null && pvp.getHeldItem().getItem() == LudicrousItems.infinity_sword && pvp.isUsingItem()) return true; } try { stupidMojangProtectedVariable.setInt(victim, 60); } catch (Exception e) { Lumberjack.log(Level.ERROR, e, "The sword isn't reflecting right! Polish it!"); } victim .func_110142_aN() .func_94547_a( new DamageSourceInfinitySword(player), victim.getHealth(), victim.getHealth()); victim.setHealth(0); victim.onDeath(new EntityDamageSource("infinity", player)); return true; }
@SubscribeEvent public void PlayerDeath(LivingDeathEvent evt) { if (evt.entityLiving instanceof EntityPlayer) { IPokemob pokemob = proxy.getPokemob((EntityPlayer) evt.entityLiving); if (pokemob != null) { ((EntityLivingBase) pokemob).setHealth(10); ((IHungrymob) pokemob).setHungerTime(0); } } }
@Override public void onHeld( ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { if (par3Entity instanceof EntityLivingBase) { if (!par2World.isRemote && par2World.rand.nextInt(100) == 0) { // about 5 seconds EntityLivingBase elb = (EntityLivingBase) par3Entity; elb.setHealth(elb.getHealth() + 1); // elb.heal(1F); } } }
protected int applyArmorCalculations( EntityLivingBase entity, DamageSource source, float originalDamage) { ItemStack[] armor = entity.getLastActiveItems(); int pierceRating = 0; int slashRating = 0; int crushRating = 0; EntityArmorCalcEvent eventPre = new EntityArmorCalcEvent(entity, originalDamage, EntityArmorCalcEvent.EventType.PRE); MinecraftForge.EVENT_BUS.post(eventPre); float damage = eventPre.incomingDamage; if (!source.isUnblockable() && armor != null) { // 1. Get Random Hit Location int location = getRandomSlot(entity.getRNG()); // 2. Get Armor Rating for armor in hit Location if (armor[location] != null && armor[location].getItem() instanceof ItemTFCArmor) { pierceRating = ((ItemTFCArmor) armor[location].getItem()).armorTypeTFC.getPiercingAR(); slashRating = ((ItemTFCArmor) armor[location].getItem()).armorTypeTFC.getSlashingAR(); crushRating = ((ItemTFCArmor) armor[location].getItem()).armorTypeTFC.getCrushingAR(); if (entity instanceof IInnateArmor) { pierceRating += ((IInnateArmor) entity).getPierceArmor(); slashRating += ((IInnateArmor) entity).getSlashArmor(); crushRating += ((IInnateArmor) entity).getCrushArmor(); } // 3. Convert the armor rating to % damage reduction float pierceMult = getDamageReduction(pierceRating); float slashMult = getDamageReduction(slashRating); float crushMult = getDamageReduction(crushRating); // 4. Reduce incoming damage damage = processDamageSource(source, damage, pierceMult, slashMult, crushMult); // 5. Damage the armor that was hit armor[location].damageItem((int) processArmorDamage(armor[location], damage), entity); } else if (armor[location] == null || armor[location] != null && !(armor[location].getItem() instanceof ItemTFCArmor)) { if (entity instanceof IInnateArmor) { pierceRating += ((IInnateArmor) entity).getPierceArmor(); slashRating += ((IInnateArmor) entity).getSlashArmor(); crushRating += ((IInnateArmor) entity).getCrushArmor(); } // 1. Convert the armor rating to % damage reduction float pierceMult = getDamageReduction(pierceRating); float slashMult = getDamageReduction(slashRating); float crushMult = getDamageReduction(crushRating); // 4. Reduce incoming damage damage = processDamageSource(source, damage, pierceMult, slashMult, crushMult); // a. If the attack hits an unprotected head, it does 75% more damage // b. If the attack hits unprotected feet, it applies a slow to the player if (location == 3) damage *= 1.75f; else if (location == 0) entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 100, 1)); } // 6. Apply the damage to the player EntityArmorCalcEvent eventPost = new EntityArmorCalcEvent(entity, damage, EntityArmorCalcEvent.EventType.POST); MinecraftForge.EVENT_BUS.post(eventPost); // TerraFirmaCraft.log.info(entity.getClass()+", "+eventPre.incomingDamage+", // "+eventPost.incomingDamage); float hasHealth = entity.getHealth(); entity.setHealth(entity.getHealth() - eventPost.incomingDamage); entity.func_110142_aN().func_94547_a(source, hasHealth, eventPost.incomingDamage); } return 0; }