@Override
  public int execute(
      EAI_Manager manager, EntityLiving entity, IInventory inventory, int slotnum, int maxcol) {
    super.execute(manager, entity, inventory, slotnum, maxcol);

    // 食べ物を持ってたら食べる。次へ進む
    //
    // ロジックをなるだけ壊さないように、検索は後ろから
    for (int i = inventory.getSizeInventory() - 1; i > 0; i--) {
      ItemStack stack = inventory.getStackInSlot(i);
      if (stack != null && stack.getItem() instanceof ItemFood) {
        UtilInventory.decrStackSize(inventory, i, 1); // アイテムを 1 つ減らす
        ItemFood food = (ItemFood) stack.getItem();

        entity.worldObj.playSoundEffect(
            entity.posX,
            entity.posY,
            entity.posZ,
            "random.eat",
            0.5F,
            entity.worldObj.rand.nextFloat() * 0.1F + 0.9F);

        entity.setEating(true);
        entity.setEntityHealth(entity.getHealth() + 1); // HP を 1 回復する
        EasyAIInterface.debugPrint("[EAI_TASK_eatFood] Eat Food " + stack + " " + slotnum);

        return this.returnTrue();
      }
    }
    return this.returnFalse();
  }
 /** Execute a one shot task or start executing a continuous task */
 public void startExecuting() {
   double d = leapTarget.posX - leaper.posX;
   double d1 = leapTarget.posZ - leaper.posZ;
   float f = MathHelper.sqrt_double(d * d + d1 * d1);
   leaper.motionX +=
       (d / (double) f) * 0.5D * 0.80000001192092896D + leaper.motionX * 0.20000000298023224D;
   leaper.motionZ +=
       (d1 / (double) f) * 0.5D * 0.80000001192092896D + leaper.motionZ * 0.20000000298023224D;
   leaper.motionY = leapMotionY;
 }
Exemplo n.º 3
0
 public int func_77323_a(int p_77323_1_, EntityLiving p_77323_2_) {
   return this.field_77361_a == 0
       ? p_77323_1_ * 3
       : (this.field_77361_a == 1 && p_77323_2_.func_70668_bt() == EnumCreatureAttribute.UNDEAD
           ? p_77323_1_ * 4
           : (this.field_77361_a == 2
                   && p_77323_2_.func_70668_bt() == EnumCreatureAttribute.ARTHROPOD
               ? p_77323_1_ * 4
               : 0));
 }
  protected boolean func_48376_a(EntityLiving par1EntityLiving, boolean par2) {
    if (par1EntityLiving == null) {
      return false;
    } else if (par1EntityLiving == this.taskOwner) {
      return false;
    } else if (!par1EntityLiving.isEntityAlive()) {
      return false;
    } else {
      if (!this.taskOwner.func_48100_a(par1EntityLiving.getClass())) {
        return false;
      } else {
        if (this.taskOwner instanceof EntityTameable
            && ((EntityTameable) this.taskOwner).isTamed()) {
          if (par1EntityLiving instanceof EntityTameable
              && ((EntityTameable) par1EntityLiving).isTamed()) {
            return false;
          }

          if (par1EntityLiving == ((EntityTameable) this.taskOwner).getOwner()) {
            return false;
          }
        } else if (par1EntityLiving instanceof EntityPlayer
            && !par2 /*&& ((EntityPlayer)par1EntityLiving).capabilities.disableDamage*/) {
          return false;
        }

        if (!this.taskOwner.isWithinHomeDistance(
            MathHelper.floor_double(par1EntityLiving.posX),
            MathHelper.floor_double(par1EntityLiving.posY),
            MathHelper.floor_double(par1EntityLiving.posZ))) {
          return false;
        } else if (this.field_48380_e
            && !this.taskOwner.getEntitySenses().canSee(par1EntityLiving)) {
          return false;
        } else {
          if (this.field_48383_a) {
            if (--this.field_48377_f <= 0) {
              this.field_48381_b = 0;
            }

            if (this.field_48381_b == 0) {
              this.field_48381_b = this.func_48375_a(par1EntityLiving) ? 1 : 2;
            }

            if (this.field_48381_b == 2) {
              return false;
            }
          }

          return true;
        }
      }
    }
  }
 /** Updates the task */
 public void updateTask() {
   theWatcher
       .getLookHelper()
       .setLookPosition(
           closestEntity.posX,
           closestEntity.posY + (double) closestEntity.getEyeHeight(),
           closestEntity.posZ,
           10F,
           theWatcher.getVerticalFaceSpeed());
   lookTime--;
 }
Exemplo n.º 6
0
  public boolean collideEntity(Entity var1) {
    ElevatorsCore.say("Collision detected...");

    if (ElevatorsCore.killBelow && var1.posY < this.posY && var1 instanceof EntityLiving) {
      EntityLiving var2 = (EntityLiving) var1;
      var2.attackEntityFrom(DamageSource.inWall, 50);
      ElevatorsCore.say("Damaging!");
      return true;
    } else {
      return false;
    }
  }
 public boolean func_75250_a() {
   if (field_75363_b.func_70681_au().nextInt(field_75363_b.func_70631_g_() ? 50 : 1000) != 0) {
     return false;
   }
   int i = MathHelper.func_76128_c(field_75363_b.field_70165_t);
   int j = MathHelper.func_76128_c(field_75363_b.field_70163_u);
   int k = MathHelper.func_76128_c(field_75363_b.field_70161_v);
   if (field_75364_c.func_72798_a(i, j, k) == Block.field_71962_X.field_71990_ca
       && field_75364_c.func_72805_g(i, j, k) == 1) {
     return true;
   }
   return field_75364_c.func_72798_a(i, j - 1, k) == Block.field_71980_u.field_71990_ca;
 }
 public boolean func_75250_a() {
   EntityLiving var1 = this.field_75441_b.func_70638_az();
   if (var1 == null) {
     return false;
   } else if (this.field_75444_h != null
       && !this.field_75444_h.isAssignableFrom(var1.getClass())) {
     return false;
   } else {
     this.field_75442_c = var1;
     this.field_75438_g = this.field_75441_b.func_70661_as().func_75494_a(this.field_75442_c);
     return this.field_75438_g != null;
   }
 }
Exemplo n.º 9
0
  public boolean onHitTarget(Entity entity) {
    worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.7F));

    if (!(entity instanceof EntityLiving)) {
      return true;
    }

    EntityLiving entityliving = (EntityLiving) entity;

    if (hasFireAttachment || hasLavaAttachment) {
      entityliving.setFire(100);
    }

    return true;
  }
  @Override
  public int execute(
      EAI_Manager manager, EntityLiving entity, IInventory inventory, int slotnum, int maxcol) {
    super.execute(manager, entity, inventory, slotnum, maxcol);

    if (entity.getHealth() < entity.getMaxHealth() / 2) {
      mod_EasyAIInterface
          .getInstance()
          .mod
          .debugPrint("[" + this.getItemName() + "] HP Low == true");
      return this.returnTrue();
    }

    return this.returnFalse();
  }
Exemplo n.º 11
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readEntityFromNBT(par1NBTTagCompound);
    NBTTagList var2 = par1NBTTagCompound.getTagList("Inventory");
    this.inventory.readFromNBT(var2);
    this.dimension = par1NBTTagCompound.getInteger("Dimension");
    this.sleeping = par1NBTTagCompound.getBoolean("Sleeping");
    this.sleepTimer = par1NBTTagCompound.getShort("SleepTimer");
    this.experience = par1NBTTagCompound.getFloat("XpP");
    this.experienceLevel = par1NBTTagCompound.getInteger("XpLevel");
    this.experienceTotal = par1NBTTagCompound.getInteger("XpTotal");

    if (this.sleeping) {
      this.playerLocation =
          new ChunkCoordinates(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY),
              MathHelper.floor_double(this.posZ));
      this.wakeUpPlayer(true, true, false);
    }

    if (par1NBTTagCompound.hasKey("SpawnX")
        && par1NBTTagCompound.hasKey("SpawnY")
        && par1NBTTagCompound.hasKey("SpawnZ")) {
      this.spawnChunk =
          new ChunkCoordinates(
              par1NBTTagCompound.getInteger("SpawnX"),
              par1NBTTagCompound.getInteger("SpawnY"),
              par1NBTTagCompound.getInteger("SpawnZ"));
    }

    this.foodStats.readNBT(par1NBTTagCompound);
    this.capabilities.readCapabilitiesFromNBT(par1NBTTagCompound);
  }
Exemplo n.º 12
0
  /** Called when the mob's health reaches 0. */
  public void onDeath(DamageSource par1DamageSource) {
    super.onDeath(par1DamageSource);
    this.setSize(0.2F, 0.2F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.10000000149011612D;

    if (this.username.equals("Notch")) {
      this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
    }

    this.inventory.dropAllItems();

    if (par1DamageSource != null) {
      this.motionX =
          (double)
              (-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float) Math.PI / 180.0F)
                  * 0.1F);
      this.motionZ =
          (double)
              (-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float) Math.PI / 180.0F)
                  * 0.1F);
    } else {
      this.motionX = this.motionZ = 0.0D;
    }

    this.yOffset = 0.1F;
    this.addStat(StatList.deathsStat, 1);
  }
Exemplo n.º 13
0
 public EntityBolt(World world, EntityLiving entityliving, float f) {
   this(world);
   shooter = entityliving;
   shotByPlayer = entityliving instanceof EntityPlayer;
   this.setSize(0.5F, 0.5F);
   this.setLocationAndAngles(
       entityliving.posX,
       entityliving.posY + (double) entityliving.getEyeHeight(),
       entityliving.posZ,
       entityliving.rotationYaw,
       entityliving.rotationPitch);
   this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
   this.posY -= 0.10000000149011612D;
   this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
   this.setPosition(this.posX, this.posY, this.posZ);
   this.yOffset = 0.0F;
   this.motionX =
       (double)
           (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
               * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
   this.motionZ =
       (double)
           (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
               * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
   this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
   this.setArrowHeading(this.motionX, this.motionY, this.motionZ, f * 1.5F);
 }
  public void onUpdate() {
    field_767_b = field_768_a;
    boolean flag = onGround;
    super.onUpdate();
    if (onGround && !flag) {
      int i = getSlimeSize();
      for (int j = 0; j < i * 8; j++) {
        float f = rand.nextFloat() * 3.141593F * 2.0F;
        float f1 = rand.nextFloat() * 0.5F + 0.5F;
        float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1;
        float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1;
        worldObj.spawnParticle(
            "slime", posX + (double) f2, boundingBox.minY, posZ + (double) f3, 0.0D, 0.0D, 0.0D);
      }

      if (i > 2) {
        worldObj.playSoundAtEntity(
            this,
            "mob.slime",
            getSoundVolume(),
            ((rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
      }
      field_768_a = -0.5F;
    }
    field_768_a = field_768_a * 0.6F;
  }
Exemplo n.º 15
0
 public void moveEntityWithHeading(float f, float f1) {
   double d = posX;
   double d1 = posY;
   double d2 = posZ;
   if (capabilities.isFlying) {
     double d3 = motionY;
     float f2 = jumpMovementFactor;
     jumpMovementFactor = 0.05F;
     super.moveEntityWithHeading(f, f1);
     motionY = d3 * 0.59999999999999998D;
     jumpMovementFactor = f2;
   } else {
     super.moveEntityWithHeading(f, f1);
   }
   addMovementStat(posX - d, posY - d1, posZ - d2);
 }
Exemplo n.º 16
0
 public void setEntityDead() {
   super.setEntityDead();
   inventorySlots.onCraftGuiClosed(this);
   if (craftingInventory != null) {
     craftingInventory.onCraftGuiClosed(this);
   }
 }
Exemplo n.º 17
0
 public void preparePlayerToSpawn() {
   yOffset = 1.62F;
   setSize(0.6F, 1.8F);
   super.preparePlayerToSpawn();
   setEntityHealth(getMaxHealth());
   deathTime = 0;
 }
Exemplo n.º 18
0
 public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
   super.readEntityFromNBT(nbttagcompound);
   NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory");
   inventory.readFromNBT(nbttaglist);
   dimension = nbttagcompound.getInteger("Dimension");
   sleeping = nbttagcompound.getBoolean("Sleeping");
   sleepTimer = nbttagcompound.getShort("SleepTimer");
   currentXP = nbttagcompound.getFloat("XpP");
   playerLevel = nbttagcompound.getInteger("XpLevel");
   totalXP = nbttagcompound.getInteger("XpTotal");
   if (sleeping) {
     bedChunkCoordinates =
         new ChunkCoordinates(
             MathHelper.floor_double(posX),
             MathHelper.floor_double(posY),
             MathHelper.floor_double(posZ));
     wakeUpPlayer(true, true, false);
   }
   if (nbttagcompound.hasKey("SpawnX")
       && nbttagcompound.hasKey("SpawnY")
       && nbttagcompound.hasKey("SpawnZ")) {
     playerSpawnCoordinate =
         new ChunkCoordinates(
             nbttagcompound.getInteger("SpawnX"),
             nbttagcompound.getInteger("SpawnY"),
             nbttagcompound.getInteger("SpawnZ"));
   }
   foodStats.readStatsFromNBT(nbttagcompound);
   capabilities.readCapabilitiesFromNBT(nbttagcompound);
 }
Exemplo n.º 19
0
 public void handleHealthUpdate(byte byte0) {
   if (byte0 == 9) {
     func_35208_ae();
   } else {
     super.handleHealthUpdate(byte0);
   }
 }
Exemplo n.º 20
0
  public EntityArrow(
      World par1World,
      EntityLiving par2EntityLiving,
      EntityLiving par3EntityLiving,
      float par4,
      float par5) {
    super(par1World);
    this.xTile = -1;
    this.yTile = -1;
    this.zTile = -1;
    this.inTile = 0;
    this.inData = 0;
    this.inGround = false;
    this.field_70251_a = 0;
    this.arrowShake = 0;
    this.ticksInAir = 0;
    this.damage = 2D;
    this.shootingEntity = par2EntityLiving;

    if (par2EntityLiving instanceof EntityPlayer) {
      this.field_70251_a = 1;
    }

    this.posY = (par2EntityLiving.posY + par2EntityLiving.getEyeHeight()) - 0.10000000149011612D;
    double d = par3EntityLiving.posX - par2EntityLiving.posX;
    double d1 =
        (par3EntityLiving.posY + par3EntityLiving.getEyeHeight())
            - 0.69999998807907104D
            - this.posY;
    double d2 = par3EntityLiving.posZ - par2EntityLiving.posZ;
    double d3 = MathHelper.sqrt_double(d * d + d2 * d2);

    if (d3 < 9.9999999999999995E-008D) {
      return;
    } else {
      float f = (float) ((Math.atan2(d2, d) * 180D) / Math.PI) - 90F;
      float f1 = (float) (-((Math.atan2(d1, d3) * 180D) / Math.PI));
      double d4 = d / d3;
      double d5 = d2 / d3;
      setLocationAndAngles(
          par2EntityLiving.posX + d4, this.posY, par2EntityLiving.posZ + d5, f, f1);
      this.yOffset = 0.0F;
      float f2 = (float) d3 * 0.2F;
      setArrowHeading(d, d1 + f2, d2, par4, par5);
      return;
    }
  }
Exemplo n.º 21
0
 public void func_35780_a(Packet41EntityEffect var1) {
   Entity var2 = this.getEntityByID(var1.field_35261_a);
   if (var2 != null && var2 instanceof EntityLiving) {
     ((EntityLiving) var2)
         .func_35165_a(
             new PotionEffect(var1.field_35259_b, var1.field_35258_d, var1.field_35260_c));
   }
 }
Exemplo n.º 22
0
  /** Will get destroyed next tick. */
  public void setDead() {
    super.setDead();
    this.inventorySlots.onCraftGuiClosed(this);

    if (this.craftingInventory != null) {
      this.craftingInventory.onCraftGuiClosed(this);
    }
  }
Exemplo n.º 23
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    if (this.flyToggleTimer > 0) {
      --this.flyToggleTimer;
    }

    if (this.worldObj.difficultySetting == 0
        && this.getHealth() < this.getMaxHealth()
        && this.ticksExisted % 20 * 12 == 0) {
      this.heal(1);
    }

    this.inventory.decrementAnimations();
    this.prevCameraYaw = this.cameraYaw;
    super.onLivingUpdate();
    this.landMovementFactor = this.speedOnGround;
    this.jumpMovementFactor = this.speedInAir;

    if (this.isSprinting()) {
      this.landMovementFactor =
          (float) ((double) this.landMovementFactor + (double) this.speedOnGround * 0.3D);
      this.jumpMovementFactor =
          (float) ((double) this.jumpMovementFactor + (double) this.speedInAir * 0.3D);
    }

    float var1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    float var2 = (float) Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;

    if (var1 > 0.1F) {
      var1 = 0.1F;
    }

    if (!this.onGround || this.getHealth() <= 0) {
      var1 = 0.0F;
    }

    if (this.onGround || this.getHealth() <= 0) {
      var2 = 0.0F;
    }

    this.cameraYaw += (var1 - this.cameraYaw) * 0.4F;
    this.cameraPitch += (var2 - this.cameraPitch) * 0.8F;

    if (this.getHealth() > 0) {
      List var3 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this, this.boundingBox.expand(1.0D, 0.0D, 1.0D));

      if (var3 != null) {
        for (int var4 = 0; var4 < var3.size(); ++var4) {
          Entity var5 = (Entity) var3.get(var4);

          if (!var5.isDead) {
            this.collideWithPlayer(var5);
          }
        }
      }
    }
  }
 /** Return the (magic) extra damage of the enchantments on player equipped item. */
 public static int getEnchantmentModifierLiving(
     EntityLiving par0EntityLiving, EntityLiving par1EntityLiving) {
   enchantmentModifierLiving.livingModifier = 0;
   enchantmentModifierLiving.entityLiving = par1EntityLiving;
   applyEnchantmentModifier(enchantmentModifierLiving, par0EntityLiving.getHeldItem());
   return enchantmentModifierLiving.livingModifier > 0
       ? 1 + enchantmentRand.nextInt(enchantmentModifierLiving.livingModifier)
       : 0;
 }
Exemplo n.º 25
0
  /** Called when the mob is falling. Calculates and applies fall damage. */
  protected void fall(float par1) {
    if (!this.capabilities.allowFlying) {
      if (par1 >= 2.0F) {
        this.addStat(StatList.distanceFallenStat, (int) Math.round((double) par1 * 100.0D));
      }

      super.fall(par1);
    }
  }
Exemplo n.º 26
0
 /** Handles updating while being ridden by an entity */
 public void updateRidden() {
   double var1 = this.posX;
   double var3 = this.posY;
   double var5 = this.posZ;
   super.updateRidden();
   this.prevCameraYaw = this.cameraYaw;
   this.cameraYaw = 0.0F;
   this.addMountedMovementStat(this.posX - var1, this.posY - var3, this.posZ - var5);
 }
Exemplo n.º 27
0
 public void func_75246_d() {
   field_75365_a = Math.max(0, field_75365_a - 1);
   if (field_75365_a != 4) {
     return;
   }
   int i = MathHelper.func_76128_c(field_75363_b.field_70165_t);
   int j = MathHelper.func_76128_c(field_75363_b.field_70163_u);
   int k = MathHelper.func_76128_c(field_75363_b.field_70161_v);
   if (field_75364_c.func_72798_a(i, j, k) == Block.field_71962_X.field_71990_ca) {
     field_75364_c.func_72926_e(2001, i, j, k, Block.field_71962_X.field_71990_ca + 4096);
     field_75364_c.func_72859_e(i, j, k, 0);
     field_75363_b.func_70615_aA();
   } else if (field_75364_c.func_72798_a(i, j - 1, k) == Block.field_71980_u.field_71990_ca) {
     field_75364_c.func_72926_e(2001, i, j - 1, k, Block.field_71980_u.field_71990_ca);
     field_75364_c.func_72859_e(i, j - 1, k, Block.field_71979_v.field_71990_ca);
     field_75363_b.func_70615_aA();
   }
 }
Exemplo n.º 28
0
 public void updateRidden() {
   double d = posX;
   double d1 = posY;
   double d2 = posZ;
   super.updateRidden();
   prevCameraYaw = cameraYaw;
   cameraYaw = 0.0F;
   addMountedMovementStat(posX - d, posY - d1, posZ - d2);
 }
Exemplo n.º 29
0
 protected void fall(float f) {
   if (capabilities.allowFlying) {
     return;
   }
   if (f >= 2.0F) {
     addStat(StatList.distanceFallenStat, (int) Math.round((double) f * 100D));
   }
   super.fall(f);
 }
Exemplo n.º 30
0
 protected void jump() {
   super.jump();
   addStat(StatList.jumpStat, 1);
   if (isSprinting()) {
     addExhaustion(0.8F);
   } else {
     addExhaustion(0.2F);
   }
 }