@Override public ArmorProperties getProperties(EntityLivingBase player, @Nonnull ItemStack armor, DamageSource source, double damage, int slot) { if(source.isUnblockable()) return new ArmorProperties(0, 0, 0); return new ArmorProperties(0, damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); }
@Override public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { if(!event.getSource().isUnblockable()) { int range = 6; List mobs = player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range), Predicates.instanceOf(IMob.class)); for(IMob mob : (List<IMob>) mobs) if(mob instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) mob; entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.getAmount()); } player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.unholyCloak, SoundCategory.PLAYERS, 1F, 1F); for(int i = 0; i < 90; i++) { float rad = i * 4F * (float) Math.PI / 180F; float xMotion = (float) Math.cos(rad) * 0.2F; float zMotion = (float) Math.sin(rad) * 0.2F; Botania.proxy.wispFX(player.posX, player.posY + 0.5, player.posZ, 0.4F + (float) Math.random() + 0.25F, 0F, 0F, 0.6F + (float) Math.random() * 0.2F, xMotion, 0F, zMotion); } return true; } return false; }
@Override public boolean canBlock(ItemStack shield, DamageSource source) { return !source.isUnblockable(); }
@Override protected float applyArmorCalculations(@Nonnull DamageSource p_70655_1_, float p_70655_2_) { if (!p_70655_1_.isUnblockable()) { return Math.min(Math.max(p_70655_2_ - 3 - this.getSlimeSize(), this.getSlimeSize()) / 2, p_70655_2_); } return p_70655_2_; }
@Override public boolean attackEntityFrom(DamageSource source, float damage) { if (isEntityInvulnerable(source)) { return false; } else if (source instanceof EntityDamageSourceIndirect) { for (int i = 0; i < 64; ++i) { if (teleportRandomly()) { return true; } } return false; } else { boolean flag = super.attackEntityFrom(source, Math.min(damage, EntityAttributes.BASE_DEFENSE_2)); if (source.isUnblockable() && rand.nextInt(10) != 0) { teleportRandomly(); } return flag; } }
@Override public ArmorProperties getProperties(EntityLivingBase player, @Nonnull ItemStack armor, DamageSource source, double damage, int slot) { double ratio = 0d; // percentage of damage that is removed before normal armor calculations are done. This is actually bad for armor with a high // toughness... if (!source.isUnblockable()) { ArmorMaterial armorMaterial = getMaterial(armor); int damageReductionAmount = armorMaterial.getDamageReductionAmount(armorType) - ArmorMaterial.DIAMOND.getDamageReductionAmount(armorType); if (damageReductionAmount > 0) { // Reduce the damage by 5% for each point of armor we have more than diamond ratio = damageReductionAmount * .05d; // This is just to counter the maximum effective armor (80%) vanilla enforces for normal armor calculations } } return new ArmorProperties(0, ratio, Integer.MAX_VALUE); }
@Override public boolean attackEntityFrom(DamageSource source, float damage) { if (isEntityInvulnerable(source)) { return false; } else if (source instanceof EntityDamageSourceIndirect) { for (int i = 0; i < 64; ++i) { if (teleportRandomly()) { return true; } } return false; } else { boolean flag = super.attackEntityFrom(source, Math.min(damage, EntityAttributes.BASE_DEFENSE_1)); if (source.isUnblockable() && rand.nextInt(10) != 0) { teleportRandomly(); } return flag; } }
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { if (source == drown) return new ArmorProperties(0, 0.01D, Integer.MAX_VALUE); else if(source.isUnblockable()) return new ArmorProperties(0, 0, 0); else if (source.getEntity() instanceof EntityGuardian) { return new ArmorProperties(0, 0.04D, Integer.MAX_VALUE); } else return new ArmorProperties(0, 0.4D, Integer.MAX_VALUE); }
ISpecialArmor armor = (ISpecialArmor) stack.getItem(); prop = armor.getProperties(entity, stack, source, damage / 25D, x).copy(); } else if (stack.getItem() instanceof ItemArmor && !source.isUnblockable()) { ItemArmor armor = (ItemArmor) stack.getItem(); prop = new ArmorProperties(0, armor.damageReduceAmount / 25D, Integer.MAX_VALUE);
return new ArmorProperties(-1, source.isUnblockable() ? 1 - remainder : damageAmount, maxAbsorption); if (source.isUnblockable()) { return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
public boolean canBlockDamageSource(EntityLivingBase player, DamageSource source) { if (!source.isUnblockable() && player.isActiveItemStackBlocking()) { Vec3d sourceLocation = source.getDamageLocation(); if (sourceLocation != null) { Vec3d playerLook = player.getLook(1.0F); Vec3d sourceToPlayer = sourceLocation.subtractReverse(new Vec3d(player.posX, player.posY, player.posZ)) .normalize(); sourceToPlayer = new Vec3d(sourceToPlayer.x, 0.0, sourceToPlayer.z); if (sourceToPlayer.dotProduct(playerLook) < 0.0D) { return true; } } } return false; } }
damageAmount *= (armourReduction); if (source.isUnblockable()) { return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption); if (source.isUnblockable()) { return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
@Override protected float applyArmorCalculations(DamageSource source, float amount) { if (!source.isUnblockable()) { if (getArmorValueOverride() >= 0) { return super.applyArmorCalculations(source, amount); } else { NonNullList<ItemStack> armor = NonNullList.create(); for (ItemStack armorPiece : getArmorInventoryList()) { armor.add(armorPiece); } float value = ISpecialArmor.ArmorProperties.applyArmor(this, armor, source, amount); if (value > 0.0F && getShieldStack().getItem() instanceof ItemShield) { float absorb = value * ((ItemShield) getShieldStack().getItem()).getArmorBonusValue() / 25F; int dmg = Math.max((int) absorb, 1); getShieldStack().damageItem(dmg, this); value -= absorb; } if (value < 0.0F) return 0; return value; } } return amount; }
@SubscribeEvent (priority = EventPriority.HIGH) public void handleLivingAttackEvent(LivingAttackEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof EntityPlayer)) { return; } DamageSource source = event.getSource(); if (source instanceof EntityDamageSourceIndirect || source.isUnblockable() || source.isProjectile()) { return; } if (source instanceof EntityDamageSource && ((EntityDamageSource) source).getIsThornsDamage()) { return; } EntityPlayer player = (EntityPlayer) event.getEntityLiving(); ItemStack stack = player.getActiveItemStack(); if (!stack.isEmpty() && stack.getItem() instanceof ItemShieldCore) { ((ItemShieldCore) stack.getItem()).onHit(stack, player, source.getTrueSource()); } }
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { int preDamage = stack.getItemDamage(); if (source.isUnblockable()) { return;
return; if (!src.isUnblockable() && player.isActiveItemStackBlocking() && amount > 0.0F) { amount = (1.0F + amount) * 0.5F;