public void killMinecart(DamageSource par1DamageSource) {
    super.killMinecart(par1DamageSource);

    if (!par1DamageSource.isExplosion()) {
      this.entityDropItem(new ItemStack(Block.furnaceIdle, 1), 0.0F);
    }
  }
Ejemplo n.º 2
0
  public static boolean attackEntityFrom(
      EntityItem item, DamageSource par1DamageSource, float par2) {
    if (item.isEntityInvulnerable()) {
      return false;
    } else if (item.getEntityItem() != null
        && item.getEntityItem().getItem() == Items.nether_star
        && par1DamageSource.isExplosion()
        && canItemBurn(item.getEntityItem())) {
      return false;
    } else {
      if ((par1DamageSource == DamageSource.lava
              | par1DamageSource == DamageSource.onFire
              | par1DamageSource == DamageSource.inFire)
          && !canItemBurn(item.getEntityItem())) return false;
      if (par1DamageSource == DamageSource.cactus) return false;

      setHealth(item, (int) (getHealth(item) - 1));

      if (getHealth(item) <= 0) {
        item.setDead();
      }

      return false;
    }
  }
Ejemplo n.º 3
0
  private boolean isPoweredCreeper(DamageSource source) {
    if (source.isExplosion() && source instanceof EntityDamageSource) {
      Entity entity = ((EntityDamageSource) source).getEntity();
      if (entity != null && entity instanceof EntityCreeper)
        return ((EntityCreeper) entity).getPowered();
    }

    return false;
  }
Ejemplo n.º 4
0
  @Override
  public void killMinecart(DamageSource par1DamageSource) {
    this.setDead();
    ItemStack itemstack = new ItemStack(Items.minecart, 1);

    this.entityDropItem(itemstack, 0.0F);

    double d0 = this.motionX * this.motionX + this.motionZ * this.motionZ;

    if (!par1DamageSource.isExplosion()) {
      this.entityDropItem(new ItemStack(ICBM.blockExplosive, 1, this.explosiveID), 0.0F);
    }

    if (par1DamageSource.isFireDamage()
        || par1DamageSource.isExplosion()
        || d0 >= 0.009999999776482582D) {
      this.explodeCart(d0);
    }
  }
Ejemplo n.º 5
0
  @Override
  public ArmorProperties getProperties(
      EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) {
    int h = getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.HEAD);
    int c = getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST);
    int p = getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.LEGS);
    int b = getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.FEET);

    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());

    if (stack.getTagCompound().getBoolean("destroyed"))
      return new ArmorProperties(0, 1 / damage, 1);

    if (stack.getTagCompound().getByte("all") > 0) {
      h += 1;
      c += 2;
      p += 1;
      b += 1;
    } else if (stack.getTagCompound().getByte("blast") > 0 && source.isExplosion()) {
      h += 2;
      c += 3;
      p += 2;
      b += 2;
    } else if (stack.getTagCompound().getByte("fire") > 0 && source.isFireDamage()) {
      h += 2;
      c += 3;
      p += 2;
      b += 2;
    } else if (stack.getTagCompound().getByte("magic") > 0 && source.isMagicDamage()) {
      h += 2;
      c += 3;
      p += 2;
      b += 2;
    } else if (stack.getTagCompound().getByte("projectile") > 0 && source.isProjectile()) {
      h += 2;
      c += 3;
      p += 2;
      b += 2;
    }

    switch (slot) {
      case 3:
        return new ArmorProperties(0, h / 25D, Integer.MAX_VALUE);
      case 2:
        return new ArmorProperties(1, c / 25D, Integer.MAX_VALUE);
      case 1:
        return new ArmorProperties(1, p / 25D, Integer.MAX_VALUE);
      case 0:
        return new ArmorProperties(0, b / 25D, Integer.MAX_VALUE);
      default:
        return null;
    }
  }
Ejemplo n.º 6
0
  @Override
  public void damageArmor(
      EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());

    if (stack.getItemDamage() >= stack.getMaxDamage() - 2) {
      NBTTagCompound tag = stack.getTagCompound();
      tag.setBoolean("destroyed", true);
      stack.setTagCompound(tag);

      return;
    }

    if (stack.getTagCompound().getByte("all") > 0) stack.damageItem(1, entity);
    else if (stack.getTagCompound().getByte("blast") > 0 && source.isExplosion())
      stack.damageItem(1, entity);
    else if (stack.getTagCompound().getByte("fire") > 0 && source.isFireDamage())
      stack.damageItem(1, entity);
    else if (stack.getTagCompound().getByte("magic") > 0 && source.isMagicDamage())
      stack.damageItem(1, entity);
    else if (stack.getTagCompound().getByte("projectile") > 0 && source.isProjectile())
      stack.damageItem(1, entity);
    else if (!source.isUnblockable()) stack.damageItem(2, entity);
  }
 /**
  * Called when the shield blocks an attack when held in the normal fashion (i.e. non-BG2) used by
  * Deku Shield to damage / destroy the stack and by Mirror Shield to reflect projectiles
  *
  * @return Return the amount of damage remaining, if any; 0 cancels the hurt event
  */
 public float onBlock(EntityPlayer player, ItemStack shield, DamageSource source, float damage) {
   ZSSPlayerInfo.get(player).onAttackBlocked(shield, damage);
   WorldUtils.playSoundAtEntity(player, Sounds.HAMMER, 0.4F, 0.5F);
   float damageBlocked = damage;
   if (toolMaterial == ToolMaterial.WOOD) {
     if (source.isProjectile()
         && !source.isExplosion()
         && source.getSourceOfDamage() instanceof IProjectile) {
       if (ZSSMain.isBG2Enabled
           && player.getHeldItem() == shield
           && shield.getItem() instanceof IArrowCatcher) {
         if (((IArrowCatcher) shield.getItem())
             .catchArrow(shield, player, (IProjectile) source.getSourceOfDamage())) {
           ((InventoryPlayerBattle) player.inventory).hasChanged = true;
         }
       }
     } else if (source instanceof IDamageAoE && ((IDamageAoE) source).isAoEDamage()) {
       damageBlocked *= magicReduction;
     }
     int dmg = Math.round(source.isFireDamage() ? damage + 10.0F : damage - 2.0F);
     if (dmg > 0) {
       shield.damageItem(dmg, player);
       if (shield.stackSize <= 0) {
         ForgeEventFactory.onPlayerDestroyItem(player, shield);
         if (ZSSMain.isBG2Enabled && BattlegearUtils.isPlayerInBattlemode(player)) {
           BattlegearUtils.setPlayerOffhandItem(player, null);
         } else {
           player.destroyCurrentEquippedItem();
         }
       }
     }
   } else if (toolMaterial == ToolMaterial.EMERALD) {
     if (source.isProjectile() && !source.isExplosion() && source.getSourceOfDamage() != null) {
       float chance = (source.isMagicDamage() ? (1F / 3F) : 1.0F);
       if (source.getSourceOfDamage() instanceof IReflectable) {
         ((IReflectable) source.getSourceOfDamage())
             .getReflectChance(shield, player, source.getEntity());
       }
       if (player.worldObj.rand.nextFloat() < chance) {
         Entity projectile = null;
         try {
           projectile =
               source
                   .getSourceOfDamage()
                   .getClass()
                   .getConstructor(World.class)
                   .newInstance(player.worldObj);
         } catch (Exception e) {;
         }
         if (projectile != null) {
           NBTTagCompound data = new NBTTagCompound();
           source.getSourceOfDamage().writeToNBT(data);
           projectile.readFromNBT(data);
           projectile.getEntityData().setBoolean("isReflected", true);
           projectile.posX -= projectile.motionX;
           projectile.posY -= projectile.motionY;
           projectile.posZ -= projectile.motionZ;
           double motionX =
               (double)
                   (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI)
                       * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI));
           double motionZ =
               (double)
                   (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI)
                       * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI));
           double motionY =
               (double) (-MathHelper.sin(player.rotationPitch / 180.0F * (float) Math.PI));
           TargetUtils.setEntityHeading(
               projectile,
               motionX,
               motionY,
               motionZ,
               1.0F,
               2.0F + (20.0F * player.worldObj.rand.nextFloat()),
               false);
           if (projectile instanceof IReflectable) {
             ((IReflectable) projectile)
                 .onReflected(shield, player, source.getEntity(), source.getSourceOfDamage());
           }
           player.worldObj.spawnEntityInWorld(projectile);
         }
       } else if (source.isUnblockable()
           || (source instanceof IDamageAoE
               && ((IDamageAoE) source).isAoEDamage())) { // failed to reflect projectile
         damageBlocked *= magicReduction;
       }
     }
   } else if (source.isUnblockable()
       || (source instanceof IDamageAoE && ((IDamageAoE) source).isAoEDamage())) {
     damageBlocked *=
         magicReduction; // default shield behavior blocks half damage from AoE magic attacks
   }
   return (damage - damageBlocked);
 }
Ejemplo n.º 8
0
 /** Called when the entity is attacked. */
 public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) {
   if (par1DamageSource.isExplosion()) {
     return false;
   }
   return super.attackEntityFrom(par1DamageSource, par2);
 }
Ejemplo n.º 9
0
 @Override
 public boolean attackEntityFrom(DamageSource source, float dmg) {
   if (getState() == BossState.CHARGING || getShieldRadius() > -1 || source.isExplosion())
     return false;
   return super.attackEntityFrom(source, dmg);
 }