예제 #1
0
  @Override
  public boolean attackEntityFrom(DamageSource source, float damage) {
    if (!worldObj.isRemote && !isDead) {
      setTimeSinceHit(10);
      setDamageTaken(this.getDamageTaken() + damage * 10.0F);

      boolean isPlayer = source.getEntity() instanceof EntityPlayer;

      if (this.getDamageTaken() > 20.0F) {
        setDead();
        if (isPlayer) {
          if (!((EntityPlayer) source.getEntity()).capabilities.isCreativeMode)
            dropItem(Extruder.Items.extruder, 1);
          if (source.getEntity().isSprinting()) setMotion(0, 0, 0);
        }

        if (inventory.contents().size() != 0)
          for (ItemStack stack : inventory.contents()) if (stack != null) entityDropItem(stack, 0);
      }

      if (!getRunning())
        setMotion(
            (double) getFacing().offsetX / 10,
            (double) getFacing().offsetY / 10,
            (double) getFacing().offsetZ / 10);
      setRunning(!getRunning());
    }

    if (worldObj.isRemote) worldObj.playAuxSFX(1001, (int) posX, (int) posY, (int) posZ, 0);

    return false;
  }