コード例 #1
0
  protected void renderAir(int width, int height) {
    if (pre(AIR)) return;
    mc.mcProfiler.startSection("air");
    EntityPlayer player = (EntityPlayer) this.mc.getRenderViewEntity();
    GlStateManager.enableBlend();
    int left = width / 2 + 91;
    int top = height - right_height;

    if (player.isInsideOfMaterial(Material.water)) {
      int air = player.getAir();
      int full = MathHelper.ceiling_double_int((double) (air - 2) * 10.0D / 300.0D);
      int partial = MathHelper.ceiling_double_int((double) air * 10.0D / 300.0D) - full;

      for (int i = 0; i < full + partial; ++i) {
        drawTexturedModalRect(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
      }
      right_height += 10;
    }

    GlStateManager.disableBlend();
    mc.mcProfiler.endSection();
    post(AIR);
  }
コード例 #2
0
ファイル: TEC.java プロジェクト: AhmiDarrow/ThaumicExpansion
 private static void addAspect(
     EntityPlayer player, ScanResult scan, double chanceToIncrease, double increaseMult) {
   Thaumcraft.proxy
       .getResearchManager()
       .completeScannedObject(
           player, "@" + ScanManager.generateItemHash(Item.getItemById(scan.id), scan.meta));
   AspectList aspects =
       ThaumcraftCraftingManager.getObjectTags(
           new ItemStack(Item.getItemById(scan.id), 1, scan.meta));
   if (aspects != null) {
     PlayerKnowledge pk = Thaumcraft.proxy.getPlayerKnowledge();
     for (Aspect aspect : aspects.getAspects()) {
       if (pk.hasDiscoveredParentAspects(player.getCommandSenderName(), aspect)) {
         int amt = aspects.getAmount(aspect);
         if (chanceToIncrease > 0d && player.getEntityWorld().rand.nextDouble() < chanceToIncrease)
           amt = MathHelper.ceiling_double_int((double) amt * increaseMult);
         ScanManager.checkAndSyncAspectKnowledge(player, aspect, amt);
       }
     }
   }
 }
コード例 #3
0
  // @Override
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      // this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) *
      // 180.0D / Math.PI);
    }

    Block block =
        this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);

    if (block.getMaterial() != Material.air) {
      block.setBlockBoundsBasedOnState(
          this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
      AxisAlignedBB axisalignedbb =
          block.getCollisionBoundingBoxFromPool(
              this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);

      if (axisalignedbb != null
          && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
        this.inGround = true;
      }
    }

    if (this.arrowShake > 0) {
      --this.arrowShake;
    }

    if (this.inGround) {
      /*int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);

      if (block == this.field_145790_g && j == this.inData)
      {
          ++this.ticksInGround;

          if (this.ticksInGround == 1200)
          {
              this.setDead();
          }
      }
      else
      {
          this.inGround = false;
          this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
          this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
          this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
          this.ticksInGround = 0;
          this.ticksInAir = 0;
      }*/

      if (!this.worldObj.isRemote) {
        this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 2.5F, true);
        ExplosionChaos.burn(this.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, 10);
        ExplosionChaos.flameDeath(
            this.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, 20);
        ExplosionNukeGeneric.waste(
            this.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, 20);
        ExplosionChaos.poison(this.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, 20);
      }
      this.worldObj.spawnEntityInWorld(
          new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
      this.setDead();
    } else {
      ++this.ticksInAir;
      Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      Vec3 vec3 =
          Vec3.createVectorHelper(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition =
          this.worldObj.func_147447_a(vec31, vec3, false, true, false);
      vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      vec3 =
          Vec3.createVectorHelper(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (movingobjectposition != null) {
        vec3 =
            Vec3.createVectorHelper(
                movingobjectposition.hitVec.xCoord,
                movingobjectposition.hitVec.yCoord,
                movingobjectposition.hitVec.zCoord);
      }

      Entity entity = null;
      List list =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      int i;
      float f1;

      for (i = 0; i < list.size(); ++i) {
        Entity entity1 = (Entity) list.get(i);

        if (entity1.canBeCollidedWith()
            && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1);
          MovingObjectPosition movingobjectposition1 =
              axisalignedbb1.calculateIntercept(vec31, vec3);

          if (movingobjectposition1 != null) {
            double d1 = vec31.distanceTo(movingobjectposition1.hitVec);

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null
          && movingobjectposition.entityHit != null
          && movingobjectposition.entityHit instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;

        if (entityplayer.capabilities.disableDamage
            || this.shootingEntity instanceof EntityPlayer
                && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f4;

      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null) {
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          int k = MathHelper.ceiling_double_int(f2 * this.damage);

          if (this.getIsCritical()) {
            k += this.rand.nextInt(k / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shootingEntity == null) {
            damagesource = DamageSource.causeIndirectMagicDamage(this, this);
          } else {
            damagesource = DamageSource.causeIndirectMagicDamage(this, this);
          }

          if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
            movingobjectposition.entityHit.setFire(5);
          }

          if (movingobjectposition.entityHit.attackEntityFrom(damagesource, k)) {
            if (movingobjectposition.entityHit instanceof EntityLivingBase) {
              EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit;

              if (!this.worldObj.isRemote) {
                entitylivingbase.setArrowCountInEntity(
                    entitylivingbase.getArrowCountInEntity() + 1);
              }

              if (this.knockbackStrength > 0) {
                f4 =
                    MathHelper.sqrt_double(
                        this.motionX * this.motionX + this.motionZ * this.motionZ);

                if (f4 > 0.0F) {
                  movingobjectposition.entityHit.addVelocity(
                      this.motionX * this.knockbackStrength * 0.6000000238418579D / f4,
                      0.1D,
                      this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4);
                }
              }

              if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) {
                EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
                EnchantmentHelper.func_151385_b(
                    (EntityLivingBase) this.shootingEntity, entitylivingbase);
              }

              if (this.shootingEntity != null
                  && movingobjectposition.entityHit != this.shootingEntity
                  && movingobjectposition.entityHit instanceof EntityPlayer
                  && this.shootingEntity instanceof EntityPlayerMP) {
                ((EntityPlayerMP) this.shootingEntity)
                    .playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
              }
            }

            if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
              if (!this.worldObj.isRemote) {
                this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 2.5F, true);
              }
              this.setDead();
            }
          } else {
            this.motionX *= -0.10000000149011612D;
            this.motionY *= -0.10000000149011612D;
            this.motionZ *= -0.10000000149011612D;
            this.rotationYaw += 180.0F;
            this.prevRotationYaw += 180.0F;
            this.ticksInAir = 0;
          }
        } else {
          this.field_145791_d = movingobjectposition.blockX;
          this.field_145792_e = movingobjectposition.blockY;
          this.field_145789_f = movingobjectposition.blockZ;
          this.field_145790_g =
              this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
          this.inData =
              this.worldObj.getBlockMetadata(
                  this.field_145791_d, this.field_145792_e, this.field_145789_f);
          this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX));
          this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY));
          this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          this.posX -= this.motionX / f2 * 0.05000000074505806D;
          this.posY -= this.motionY / f2 * 0.05000000074505806D;
          this.posZ -= this.motionZ / f2 * 0.05000000074505806D;
          this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.arrowShake = 7;
          this.setIsCritical(false);

          if (this.field_145790_g.getMaterial() != Material.air) {
            this.field_145790_g.onEntityCollidedWithBlock(
                this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
          }
        }
      }

      if (true) {
        for (i = 0; i < 4; ++i) {
          this.worldObj.spawnParticle(
              "smoke",
              this.posX,
              this.posY,
              this.posZ,
              0,
              0,
              0 /*this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ*/);
        }
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

      // for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI);
      // this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
      {;
      }

      /*while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
      {
          this.prevRotationPitch += 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw < -180.0F)
      {
          this.prevRotationYaw -= 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
      {
          this.prevRotationYaw += 360.0F;
      }*/

      // this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch)
      // * 0.2F;
      // this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
      float f3 = 0.99F;
      f1 = 0.05F;

      if (this.isInWater()) {
        for (int l = 0; l < 4; ++l) {
          f4 = 0.25F;
          this.worldObj.spawnParticle(
              "bubble",
              this.posX - this.motionX * f4,
              this.posY - this.motionY * f4,
              this.posZ - this.motionZ * f4,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        f3 = 0.8F;
      }

      if (this.isWet()) {
        this.extinguish();
      }

      this.motionX *= f3;
      this.motionY *= f3;
      this.motionZ *= f3;
      this.motionY -= gravity;
      this.setPosition(this.posX, this.posY, this.posZ);
      this.func_145775_I();
    }
  }
コード例 #4
0
  /** Called to update the entity's position/logic. */
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float var1 =
          MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, var1) * 180.0D / Math.PI);
    }

    int var16 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);

    if (var16 > 0) {
      Block.blocksList[var16].setBlockBoundsBasedOnState(
          this.worldObj, this.xTile, this.yTile, this.zTile);
      AxisAlignedBB var2 =
          Block.blocksList[var16].getCollisionBoundingBoxFromPool(
              this.worldObj, this.xTile, this.yTile, this.zTile);

      if (var2 != null
          && var2.isVecInside(
              this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) {
        this.inGround = true;
      }
    }

    if (this.arrowShake > 0) {
      --this.arrowShake;
    }

    if (this.inGround) {
      int var17 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
      int var3 = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);

      if (var17 == this.inTile && var3 == this.inData) {
        ++this.ticksInGround;

        if (this.ticksInGround == 1200) {
          this.setDead();
        }
      } else {
        this.inGround = false;
        this.motionX *= this.rand.nextFloat() * 0.2F;
        this.motionY *= this.rand.nextFloat() * 0.2F;
        this.motionZ *= this.rand.nextFloat() * 0.2F;
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      }
    } else {
      ++this.ticksInAir;
      Vec3 var18 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      Vec3 var19 =
          this.worldObj
              .getWorldVec3Pool()
              .getVecFromPool(
                  this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var4 = this.worldObj.rayTraceBlocks_do_do(var18, var19, false, true);
      var18 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      var19 =
          this.worldObj
              .getWorldVec3Pool()
              .getVecFromPool(
                  this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (var4 != null) {
        var19 =
            this.worldObj
                .getWorldVec3Pool()
                .getVecFromPool(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
      }

      Entity var5 = null;
      List var6 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var7 = 0.0D;
      Iterator var9 = var6.iterator();
      float var10;
      MovingObjectPosition var13;

      while (var9.hasNext()) {
        Entity var11 = (Entity) var9.next();

        if (var11.canBeCollidedWith() && (var11 != this.shootingEntity || this.ticksInAir >= 5)) {
          var10 = 0.3F;
          AxisAlignedBB var12 = var11.boundingBox.expand(var10, var10, var10);
          var13 = var12.calculateIntercept(var18, var19);

          if (var13 != null) {
            double var14 = var18.distanceTo(var13.hitVec);

            if (var14 < var7 || var7 == 0.0D) {
              var5 = var11;
              var7 = var14;
            }
          }
        }
      }

      if (var5 != null) {
        var4 = new MovingObjectPosition(var5);
      }

      int var21;
      float var20;
      float var24;
      float var26;

      if (var4 != null) {
        if (var4.entityHit != null) {
          var20 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          var21 = MathHelper.ceiling_double_int(var20 * this.damage);

          if (this.getIsCritical()) {
            var21 += this.rand.nextInt(var21 / 2 + 2);
          }

          var13 = null;
          DamageSource var22;

          if (this.shootingEntity == null) {
            var22 = causeSerenityArrowDamage(this, this);
          } else {
            var22 = causeSerenityArrowDamage(this, this.shootingEntity);
          }

          if (this.isBurning()) {
            var4.entityHit.setFire(5);
          }

          if (var4.entityHit.attackEntityFrom(var22, var21)) {
            if (var4.entityHit instanceof EntityLiving) {
              EntityLiving var241 = (EntityLiving) var4.entityHit;

              if (!this.worldObj.isRemote) {
                var241.setArrowCountInEntity(var241.getArrowCountInEntity() + 1);
              }

              if (this.knockbackStrength > 0) {
                var26 =
                    MathHelper.sqrt_double(
                        this.motionX * this.motionX + this.motionZ * this.motionZ);

                if (var26 > 0.0F) {
                  var4.entityHit.addVelocity(
                      this.motionX * this.knockbackStrength * 0.6000000238418579D / var26,
                      0.1D,
                      this.motionZ * this.knockbackStrength * 0.6000000238418579D / var26);
                }
              }
              if (this.shootingEntity != null
                  && var4.entityHit != this.shootingEntity
                  && var4.entityHit instanceof EntityPlayer
                  && this.shootingEntity instanceof EntityPlayerMP) {
                ((EntityPlayerMP) this.shootingEntity)
                    .playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
              }
            }

            this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));

            if (!(var4.entityHit instanceof EntityEnderman)) {
              this.setDead();
            }
          } else {
            this.motionX *= -0.10000000149011612D;
            this.motionY *= -0.10000000149011612D;
            this.motionZ *= -0.10000000149011612D;
            this.rotationYaw += 180.0F;
            this.prevRotationYaw += 180.0F;
            this.ticksInAir = 0;
          }
        } else {
          this.xTile = var4.blockX;
          this.yTile = var4.blockY;
          this.zTile = var4.blockZ;
          this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
          this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
          this.motionX = ((float) (var4.hitVec.xCoord - this.posX));
          this.motionY = ((float) (var4.hitVec.yCoord - this.posY));
          this.motionZ = ((float) (var4.hitVec.zCoord - this.posZ));
          var20 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          this.posX -= this.motionX / var20 * 0.05000000074505806D;
          this.posY -= this.motionY / var20 * 0.05000000074505806D;
          this.posZ -= this.motionZ / var20 * 0.05000000074505806D;
          this.worldObj.playSoundAtEntity(
              this, "random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.arrowShake = 7;
          this.setIsCritical(false);
        }
      }

      if (this.getIsCritical()) {
        for (var21 = 0; var21 < 4; ++var21) {
          this.worldObj.spawnParticle(
              "crit",
              this.posX + this.motionX * var21 / 4.0D,
              this.posY + this.motionY * var21 / 4.0D,
              this.posZ + this.motionZ * var21 / 4.0D,
              -this.motionX,
              -this.motionY + 0.2D,
              -this.motionZ);
        }
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

      for (this.rotationPitch = (float) (Math.atan2(this.motionY, var20) * 180.0D / Math.PI);
          this.rotationPitch - this.prevRotationPitch < -180.0F;
          this.prevRotationPitch -= 360.0F) {;
      }

      while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
        this.prevRotationPitch += 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
        this.prevRotationYaw -= 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
        this.prevRotationYaw += 360.0F;
      }

      this.rotationPitch =
          this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
      this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
      float var23 = 0.99F;
      var10 = 0.05F;

      if (this.isInWater()) {
        for (int var25 = 0; var25 < 4; ++var25) {
          var24 = 0.25F;
          this.worldObj.spawnParticle(
              "bubble",
              this.posX - this.motionX * var24,
              this.posY - this.motionY * var24,
              this.posZ - this.motionZ * var24,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        var23 = 0.8F;
      }

      this.motionX *= var23;
      this.motionY *= var23;
      this.motionZ *= var23;
      this.motionY -= var10;
      this.setPosition(this.posX, this.posY, this.posZ);
      this.doBlockCollisions();
    }
  }
コード例 #5
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
    }

    Block i = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);

    if (!i.equals(Blocks.air)) {
      i.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
      AxisAlignedBB axisalignedbb =
          i.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);

      if (axisalignedbb != null
          && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
        this.inGround = true;
      }
    }

    if (this.arrowShake > 0) {
      --this.arrowShake;
    }

    if (this.inGround) {
      Block j = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
      int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);

      if (j == this.inTile && k == this.inData) {
        ++this.ticksInGround;

        if (this.ticksInGround == 1200) {
          this.setDead();
        }
      } else {
        this.inGround = false;
        this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      }
    } else {
      ++this.ticksInAir;
      Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      Vec3 vec3 =
          Vec3.createVectorHelper(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition =
          this.worldObj.func_147447_a(vec31, vec3, false, true, false);
      vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      vec3 =
          Vec3.createVectorHelper(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (movingobjectposition != null) {
        vec31 =
            Vec3.createVectorHelper(
                movingobjectposition.hitVec.xCoord,
                movingobjectposition.hitVec.yCoord,
                movingobjectposition.hitVec.zCoord);
      }

      Entity entity = null;
      List list =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      int l;
      float f1;

      for (l = 0; l < list.size(); ++l) {
        Entity entity1 = (Entity) list.get(l);

        if (entity1.canBeCollidedWith()
            && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.expand((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 =
              axisalignedbb1.calculateIntercept(vec3, vec31);

          if (movingobjectposition1 != null) {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null
          && movingobjectposition.entityHit != null
          && movingobjectposition.entityHit instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;

        if (entityplayer.capabilities.disableDamage
            || this.shootingEntity instanceof EntityPlayer
                && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f3;

      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null) {
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          int i1 = MathHelper.ceiling_double_int((double) f2 * this.damage);

          if (this.getIsCritical()) {
            i1 += this.rand.nextInt(i1 / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shootingEntity == null) {
            damagesource = mod_Rediscovered.causeParrowDamage(this, this);
          } else {
            damagesource = mod_Rediscovered.causeParrowDamage(this, this.shootingEntity);
          }

          if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
            movingobjectposition.entityHit.setFire(5);
          }

          if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float) i1)) {
            if (movingobjectposition.entityHit instanceof EntityLivingBase) {
              EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit;

              if (!this.worldObj.isRemote) {
                entitylivingbase.setArrowCountInEntity(
                    entitylivingbase.getArrowCountInEntity() + 1);
              }

              if (this.knockbackStrength > 0) {
                f3 =
                    MathHelper.sqrt_double(
                        this.motionX * this.motionX + this.motionZ * this.motionZ);

                if (f3 > 0.0F) {
                  movingobjectposition.entityHit.addVelocity(
                      this.motionX
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3,
                      0.1D,
                      this.motionZ
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3);
                }
              }
            }

            this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));

            if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
              this.setDead();
            }
          } else {
            this.motionX *= -0.10000000149011612D;
            this.motionY *= -0.10000000149011612D;
            this.motionZ *= -0.10000000149011612D;
            this.rotationYaw += 180.0F;
            this.prevRotationYaw += 180.0F;
            this.ticksInAir = 0;
          }
        } else {
          this.xTile = movingobjectposition.blockX;
          this.yTile = movingobjectposition.blockY;
          this.zTile = movingobjectposition.blockZ;
          this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
          this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
          this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX));
          this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY));
          this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          this.posX -= this.motionX / (double) f2 * 0.05000000074505806D;
          this.posY -= this.motionY / (double) f2 * 0.05000000074505806D;
          this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D;
          this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.arrowShake = 7;
          this.setIsCritical(false);

          if (!this.inTile.equals(Blocks.air)) {
            this.inTile.onEntityCollidedWithBlock(
                this.worldObj, this.xTile, this.yTile, this.zTile, this);
          }
        }
      }

      if (this.getIsCritical()) {
        for (l = 0; l < 4; ++l) {
          this.worldObj.spawnParticle(
              "crit",
              this.posX + this.motionX * (double) l / 4.0D,
              this.posY + this.motionY * (double) l / 4.0D,
              this.posZ + this.motionZ * (double) l / 4.0D,
              -this.motionX,
              -this.motionY + 0.2D,
              -this.motionZ);
        }
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

      for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f2) * 180.0D / Math.PI);
          this.rotationPitch - this.prevRotationPitch < -180.0F;
          this.prevRotationPitch -= 360.0F) {;
      }

      while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
        this.prevRotationPitch += 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
        this.prevRotationYaw -= 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
        this.prevRotationYaw += 360.0F;
      }

      this.rotationPitch =
          this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
      this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
      float f4 = 0.99F;
      f1 = 0.05F;

      if (this.isInWater()) {
        for (int j1 = 0; j1 < 4; ++j1) {
          f3 = 0.25F;
          this.worldObj.spawnParticle(
              "bubble",
              this.posX - this.motionX * (double) f3,
              this.posY - this.motionY * (double) f3,
              this.posZ - this.motionZ * (double) f3,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        f4 = 0.8F;
      }

      this.motionX *= (double) f4;
      this.motionY *= (double) f4;
      this.motionZ *= (double) f4;
      this.motionY -= (double) f1;
      this.setPosition(this.posX, this.posY, this.posZ);
      //            this.doBlockCollisions();
    }
  }
コード例 #6
0
ファイル: EntityNutsCall.java プロジェクト: Glassmaker/Atum
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
    }

    int i = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);

    if (i > 0) {
      Block.blocksList[i].setBlockBoundsBasedOnState(
          this.worldObj, this.xTile, this.yTile, this.zTile);
      AxisAlignedBB axisalignedbb =
          Block.blocksList[i].getCollisionBoundingBoxFromPool(
              this.worldObj, this.xTile, this.yTile, this.zTile);

      if (axisalignedbb != null
          && axisalignedbb.isVecInside(
              this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) {
        this.inGround = true;
      }
    }

    if (this.arrowShake > 0) {
      --this.arrowShake;
    }

    if (this.inGround) {
      int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
      int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);

      if (j == this.inTile && k == this.inData) {
        ++this.ticksInGround;

        if (this.ticksInGround == 20000) {
          this.setDead();
        }
      } else {
        this.inGround = false;
        this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      }
    } else {
      ++this.ticksInAir;
      Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      Vec3 vec31 =
          this.worldObj
              .getWorldVec3Pool()
              .getVecFromPool(
                  this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition =
          this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true);
      vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      vec31 =
          this.worldObj
              .getWorldVec3Pool()
              .getVecFromPool(
                  this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (movingobjectposition != null) {
        vec31 =
            this.worldObj
                .getWorldVec3Pool()
                .getVecFromPool(
                    movingobjectposition.hitVec.xCoord,
                    movingobjectposition.hitVec.yCoord,
                    movingobjectposition.hitVec.zCoord);
      }

      Entity entity = null;
      List list =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      int l;
      float f1;

      for (l = 0; l < list.size(); ++l) {
        Entity entity1 = (Entity) list.get(l);

        if (entity1.canBeCollidedWith()
            && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.expand((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 =
              axisalignedbb1.calculateIntercept(vec3, vec31);

          if (movingobjectposition1 != null) {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null
          && movingobjectposition.entityHit != null
          && movingobjectposition.entityHit instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;

        if (entityplayer.capabilities.disableDamage
            || this.shootingEntity instanceof EntityPlayer
                && !((EntityPlayer) this.shootingEntity).func_96122_a(entityplayer)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f3;

      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null) {
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          int i1 = MathHelper.ceiling_double_int((double) f2 * this.damage);

          if (this.getIsCritical()) {
            i1 += this.rand.nextInt(i1 / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shootingEntity == null) {
            damagesource = DamageSource.causeThrownDamage(this, this);
          } else {
            damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity);
          }

          if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
            movingobjectposition.entityHit.setFire(5);
          }

          if (Math.random() > 0.5)
            worldObj.addWeatherEffect(
                new EntityLightningBolt(worldObj, (double) posX, (double) posY, (double) posZ));

          if (movingobjectposition.entityHit.attackEntityFrom(damagesource, i1)) {
            if (movingobjectposition.entityHit instanceof EntityLiving) {
              EntityLiving entityliving = (EntityLiving) movingobjectposition.entityHit;

              if (this.knockbackStrength > 0) {
                f3 =
                    MathHelper.sqrt_double(
                        this.motionX * this.motionX + this.motionZ * this.motionZ);

                if (f3 > 0.0F) {
                  movingobjectposition.entityHit.addVelocity(
                      this.motionX
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3,
                      0.1D,
                      this.motionZ
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3);
                }
              }

              if (this.shootingEntity != null) {
                EnchantmentThorns.func_92096_a(this.shootingEntity, entityliving, this.rand);
              }

              if (this.shootingEntity != null
                  && movingobjectposition.entityHit != this.shootingEntity
                  && movingobjectposition.entityHit instanceof EntityPlayer
                  && this.shootingEntity instanceof EntityPlayerMP) {
                ((EntityPlayerMP) this.shootingEntity)
                    .playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
              }
            }

            this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
          } else {
            this.motionX *= -0.10000000149011612D;
            this.motionY *= -0.10000000149011612D;
            this.motionZ *= -0.10000000149011612D;
            this.rotationYaw += 180.0F;
            this.prevRotationYaw += 180.0F;
            this.ticksInAir = 0;
          }
        } else {
          this.xTile = movingobjectposition.blockX;
          this.yTile = movingobjectposition.blockY;
          this.zTile = movingobjectposition.blockZ;
          this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
          this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
          this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX));
          this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY));
          this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          this.posX -= this.motionX / (double) f2 * 0.05000000074505806D;
          this.posY -= this.motionY / (double) f2 * 0.05000000074505806D;
          this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D;
          this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.arrowShake = 7;
          this.setIsCritical(false);

          if (this.inTile != 0) {
            Block.blocksList[this.inTile].onEntityCollidedWithBlock(
                this.worldObj, this.xTile, this.yTile, this.zTile, this);
          }
        }
      }

      if (this.getIsCritical()) {
        for (l = 0; l < 4; ++l) {
          this.worldObj.spawnParticle(
              "crit",
              this.posX + this.motionX * (double) l / 4.0D,
              this.posY + this.motionY * (double) l / 4.0D,
              this.posZ + this.motionZ * (double) l / 4.0D,
              -this.motionX,
              -this.motionY + 0.2D,
              -this.motionZ);
        }
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

      for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f2) * 180.0D / Math.PI);
          this.rotationPitch - this.prevRotationPitch < -180.0F;
          this.prevRotationPitch -= 360.0F) {;
      }

      while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
        this.prevRotationPitch += 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
        this.prevRotationYaw -= 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
        this.prevRotationYaw += 360.0F;
      }

      this.rotationPitch =
          this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
      this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
      float f4 = 0.99F;
      f1 = 0.05F;

      if (this.isInWater()) {
        for (int j1 = 0; j1 < 4; ++j1) {
          f3 = 0.25F;
          this.worldObj.spawnParticle(
              "bubble",
              this.posX - this.motionX * (double) f3,
              this.posY - this.motionY * (double) f3,
              this.posZ - this.motionZ * (double) f3,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        f4 = 0.45F;
      }

      this.motionX *= (double) f4;
      this.motionY *= (double) f4;
      this.motionZ *= (double) f4;
      this.motionY -= (double) f1;
      this.setPosition(this.posX, this.posY, this.posZ);
      this.doBlockCollisions();
    }
  }
コード例 #7
0
  @Override
  @SuppressWarnings("unchecked")
  public void onUpdate() {
    super.onUpdate();

    if (this.ticksExisted > 400) {
      if (this.isHot) {
        this.isHot = false;
        this.setHot(this.isHot);
      }
    } else if (!this.worldObj.isRemote) {
      this.setHot(this.isHot);
    }

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI);
    }

    BlockPos pos = new BlockPos(this.xTile, this.yTile, this.zTile);
    Block block = this.worldObj.getBlockState(pos).getBlock();

    if (!block.isAir(this.worldObj, pos)) {
      block.setBlockBoundsBasedOnState(this.worldObj, pos);
      AxisAlignedBB axisalignedbb =
          block.getCollisionBoundingBox(this.worldObj, pos, this.worldObj.getBlockState(pos));

      if (axisalignedbb != null
          && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) {
        this.inGround = true;
      }
    }

    if (this.inGround) {
      Block j = this.worldObj.getBlockState(pos).getBlock();
      int k = j.getMetaFromState(this.worldObj.getBlockState(pos));

      if (j == this.inTile && k == this.inData) {
        ++this.ticksInGround;

        if (this.ticksInGround == 1200) {
          this.setDead();
        }
      } else {
        this.inGround = false;
        this.motionX *= this.rand.nextFloat() * 0.2F;
        this.motionY *= this.rand.nextFloat() * 0.2F;
        this.motionZ *= this.rand.nextFloat() * 0.2F;
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      }
    } else {
      ++this.ticksInAir;
      Vec3 vec3 = new Vec3(this.posX, this.posY, this.posZ);
      Vec3 vec31 =
          new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition =
          this.worldObj.rayTraceBlocks(vec3, vec31, false, true, false);
      vec3 = new Vec3(this.posX, this.posY, this.posZ);
      vec31 =
          new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (movingobjectposition != null) {
        vec31 =
            new Vec3(
                movingobjectposition.hitVec.xCoord,
                movingobjectposition.hitVec.yCoord,
                movingobjectposition.hitVec.zCoord);
      }

      this.rotationPitch += 1F;

      Entity entity = null;
      List<Entity> list =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.getEntityBoundingBox()
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      int l;
      float f1;

      for (l = 0; l < list.size(); ++l) {
        Entity entity1 = list.get(l);

        if (entity1.canBeCollidedWith()
            && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand(f1, f1, f1);
          MovingObjectPosition movingobjectposition1 =
              axisalignedbb1.calculateIntercept(vec3, vec31);

          if (movingobjectposition1 != null) {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null
          && movingobjectposition.entityHit != null
          && movingobjectposition.entityHit instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;

        if (entityplayer.capabilities.disableDamage
            || this.shootingEntity instanceof EntityPlayer
                && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f3;
      double damage = ConfigManagerCore.hardMode ? 3.2D : 1.6D;

      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null) {
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          int i1 = MathHelper.ceiling_double_int(f2 * damage);

          DamageSource damagesource = null;

          if (this.shootingEntity == null) {
            damagesource =
                new EntityDamageSourceIndirect("meteorChunk", this, this).setProjectile();
          } else {
            damagesource =
                new EntityDamageSourceIndirect("meteorChunk", this, this.shootingEntity)
                    .setProjectile();
          }

          if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
            movingobjectposition.entityHit.setFire(2);
          }

          if (movingobjectposition.entityHit.attackEntityFrom(damagesource, i1)) {
            if (movingobjectposition.entityHit instanceof EntityLivingBase) {
              EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit;

              if (!this.worldObj.isRemote) {
                entitylivingbase.setArrowCountInEntity(
                    entitylivingbase.getArrowCountInEntity() + 1);
              }

              if (this.knockbackStrength > 0) {
                f3 =
                    MathHelper.sqrt_double(
                        this.motionX * this.motionX + this.motionZ * this.motionZ);

                if (f3 > 0.0F) {
                  movingobjectposition.entityHit.addVelocity(
                      this.motionX * this.knockbackStrength * 0.6000000238418579D / f3,
                      0.1D,
                      this.motionZ * this.knockbackStrength * 0.6000000238418579D / f3);
                }
              }

              if (this.shootingEntity != null) {
                EnchantmentHelper.applyThornEnchantments(entitylivingbase, this.shootingEntity);
                EnchantmentHelper.applyArthropodEnchantments(
                    (EntityLivingBase) this.shootingEntity, entitylivingbase);
              }

              if (this.shootingEntity != null
                  && movingobjectposition.entityHit != this.shootingEntity
                  && movingobjectposition.entityHit instanceof EntityPlayer
                  && this.shootingEntity instanceof EntityPlayerMP) {
                ((EntityPlayerMP) this.shootingEntity)
                    .playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
              }
            }

            if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
              this.setDead();
            }
          } else {
            this.motionX *= -0.10000000149011612D;
            this.motionY *= -0.10000000149011612D;
            this.motionZ *= -0.10000000149011612D;
            this.rotationYaw += 180.0F;
            this.prevRotationYaw += 180.0F;
            this.ticksInAir = 0;
          }
        } else {
          this.xTile = movingobjectposition.getBlockPos().getX();
          this.yTile = movingobjectposition.getBlockPos().getY();
          this.zTile = movingobjectposition.getBlockPos().getZ();
          IBlockState state = this.worldObj.getBlockState(movingobjectposition.getBlockPos());
          this.inTile = state.getBlock();
          this.inData = this.inTile.getMetaFromState(state);
          this.motionX = (float) (movingobjectposition.hitVec.xCoord - this.posX);
          this.motionY = (float) (movingobjectposition.hitVec.yCoord - this.posY);
          this.motionZ = (float) (movingobjectposition.hitVec.zCoord - this.posZ);
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          this.posX -= this.motionX / f2 * 0.05000000074505806D;
          this.posY -= this.motionY / f2 * 0.05000000074505806D;
          this.posZ -= this.motionZ / f2 * 0.05000000074505806D;
          this.inGround = true;

          if (!this.inTile.isAir(this.worldObj, movingobjectposition.getBlockPos())) {
            this.inTile.onEntityCollidedWithBlock(
                this.worldObj, movingobjectposition.getBlockPos(), this);
          }
        }
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

      if (!this.onGround) {
        this.rotationPitch += 10;
        this.rotationYaw += 2;
      }

      float f4 = 0.99F;
      f1 = 0.05F;

      if (this.isInWater()) {
        for (int j1 = 0; j1 < 4; ++j1) {
          f3 = 0.25F;
          this.worldObj.spawnParticle(
              EnumParticleTypes.WATER_BUBBLE,
              this.posX - this.motionX * f3,
              this.posY - this.motionY * f3,
              this.posZ - this.motionZ * f3,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        f4 = 0.8F;
      }

      this.motionX *= f4;
      this.motionY *= f4;
      this.motionZ *= f4;
      this.motionY -= WorldUtil.getGravityForEntity(this);
      this.setPosition(this.posX, this.posY, this.posZ);
      this.doBlockCollisions();
    }
  }
コード例 #8
0
  /*
   * Tick毎に呼ばれる更新処理。
   * 速度の更新、衝突判定などをここで行う。
   */
  @Override
  public void onUpdate() {
    super.onUpdate();

    livingTimeCount++;

    // その1、爆発処理
    byte exp = this.isExploded();
    if (exp == 1) {
      this.setDead();
    } else if (exp > 1) {
      AMTLogger.debugInfo("current explode int :" + exp);
      this.worldObj.spawnParticle(
          "hugeexplosion",
          this.posX,
          this.posY + 1.0D,
          this.posZ,
          this.motionX,
          this.motionY,
          this.motionZ);
      exp--;
      this.setTimeCount(exp);
    }

    // その2、アクティブか否か
    if (livingTimeCount > 3 && !this.active) {
      this.active = true;
      this.setActive((byte) 1);
      this.playSound("defeatedcrow:knock", 0.5F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
    }

    boolean explode = false;

    // 以降、アクティブか否かで動作が変わる。
    if (this.active) {
      double dx = -(double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI));
      double dz = -(double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI));
      for (int i = 0; i < 4; ++i) {
        this.worldObj.spawnParticle(
            "crit",
            this.posX + dx,
            this.posY,
            this.posZ + dz,
            -this.motionX,
            -this.motionY + 0.2D,
            -this.motionZ);
      }
    }

    // 直前のパラメータと新パラメータを一致させているところ。
    // また、速度に応じてエンティティの向きを調整し、常に進行方向に前面が向くようにしている。
    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI);
    }

    // 激突したブロックを確認している
    Block i = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
    boolean air = this.worldObj.isAirBlock(xTile, yTile, zTile);

    // 空気じゃないブロックに当たった&ブロック貫通エンティティでない時
    if (i != null && i.getMaterial() != Material.air) {
      i.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
      AxisAlignedBB axisalignedbb =
          i.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);

      // 当たり判定に接触しているかどうか
      if (axisalignedbb != null
          && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
        this.inGround = true;
      }
    }

    // 空気じゃないブロックに当たった
    if (this.inGround) {
      Block j = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
      int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);

      /*
       * 前のTickに確認した埋まりブロックのIDとメタを照合している。違ったら埋まり状態を解除、一致したら埋まり状態を継続。
       * /* 埋まり状態2tick継続でこのエンティティを消す
       */
      if (j == this.inTile && k == this.inData) {
        ++this.ticksInGround;
        // ブロック貫通の場合、20tick(1秒間)はブロック中にあっても消えないようになる。
        int limit = 2;

        if (this.ticksInGround > limit) {
          explode = true;
        }
      } else // 埋まり状態の解除処理
      {
        this.inGround = false;
        this.motionX *= this.rand.nextFloat() * 0.1F;
        this.motionY *= this.rand.nextFloat() * 0.1F;
        this.motionZ *= this.rand.nextFloat() * 0.1F;
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      }
    } else // 埋まってない時。速度の更新。
    {
      ++this.ticksInAir;
      // ブロックとの衝突判定
      Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      Vec3 vec31 =
          Vec3.createVectorHelper(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition =
          this.worldObj.func_147447_a(vec3, vec31, false, true, false);
      vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      vec31 =
          Vec3.createVectorHelper(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      // ブロックに当たった
      if (movingobjectposition != null) {
        vec31 =
            Vec3.createVectorHelper(
                movingobjectposition.hitVec.xCoord,
                movingobjectposition.hitVec.yCoord,
                movingobjectposition.hitVec.zCoord);
      }

      // Entityとの衝突判定。
      List list =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      int l;
      float f1;

      MovingObjectPosition entityTarget = null;

      // 1ブロック分の範囲内にいるエンティティ全てに対して繰り返す
      for (l = 0; l < list.size(); ++l) {
        Entity entity1 = (Entity) list.get(l);
        Entity entity = null;

        // ターゲットの場合
        if (entity1 instanceof EntityLivingBase || entity1 instanceof EntityDragonPart) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1);
          MovingObjectPosition movingobjectposition1 =
              axisalignedbb1.calculateIntercept(vec3, vec31);

          if (movingobjectposition1 != null) {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

            if (d1 < d0 || d0 == 0.0D) {
              // arrowと異なり、あたったEntityすべてをリストに入れる
              entityTarget = new MovingObjectPosition(entity1);
              d0 = d1;
              break;
            }
          }
        }
      }

      /*
       * 当たったエンティティそれそれについての判定部分。
       * ここで特定の種類のエンティティに当たらないようにできる。
       */
      boolean canAttack = false;
      if (entityTarget != null) {
        Entity target = entityTarget.entityHit;

        if (target instanceof EntityPlayer) {
          // プレイヤーに当たった時
          EntityPlayer entityplayer = (EntityPlayer) target;

          if (entityplayer.capabilities.disableDamage
              || this.shootingEntity instanceof EntityPlayer
                  && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
            // PvPが許可されていないと当たらない
            canAttack = false;
          } else if (entityplayer == this.shootingEntity) {
            // 対象が撃った本人の場合も当たらない
            canAttack = false;
          } else if (DCsConfig.PvPProhibitionMode && entityplayer instanceof EntityPlayer) {
            canAttack = false;
          }
        } else if (target instanceof EntityTameable || target instanceof EntityHorse) {
          // 事故防止の為、EntityTameable(犬や猫などのペット)、馬にも当たらないようにする
          canAttack = false;
        } else {
          canAttack = true;
        }
      }

      float f2;
      float f3;

      // 当たったあとの処理
      // まずはリストから
      if (canAttack) {
        Entity target = entityTarget.entityHit;

        int i1 = MathHelper.ceiling_double_int(1.0D * this.damage);
        // 0~2程度の乱数値を上乗せ
        i1 += this.rand.nextInt(3);

        DamageSource damagesource = null;

        // 別メソッドでダメージソースを確認
        damagesource = this.thisDamageSource(this.shootingEntity);

        // バニラ矢と同様、このエンティティが燃えているなら対象に着火することも出来る
        if (this.isBurning() && !(target instanceof EntityEnderman)) {
          target.setFire(5);
        } else if (target instanceof IProjectile) {
          // 対象が矢などの飛翔Entityの場合、打ち消すことが出来る
          target.setDead();
        } else {
          // ダメージを与える処理を呼ぶ
          if (target.attackEntityFrom(damagesource, i1)) {
            // ダメージを与えることに成功したら以下の処理を行う
            if (target instanceof EntityLivingBase) {
              EntityLivingBase entitylivingbase = (EntityLivingBase) target;

              // ノックバック
              if (this.knockbackStrength > 0) {
                f3 =
                    MathHelper.sqrt_double(
                        this.motionX * this.motionX + this.motionZ * this.motionZ);

                if (f3 > 0.0F) {
                  // Y方向に大きめに打ち上げる
                  target.addVelocity(
                      this.motionX * this.knockbackStrength * 0.2000000238418579D / f3,
                      0.3D,
                      this.motionZ * this.knockbackStrength * 0.2000000238418579D / f3);
                }
              }

              // 無敵時間はなし
              target.hurtResistantTime = 0;

              // マルチプレイ時に、両者がプレイヤーだった時のパケット送信処理
              if (this.shootingEntity != null
                  && target != this.shootingEntity
                  && target instanceof EntityPlayer
                  && this.shootingEntity instanceof EntityPlayerMP) {
                ((EntityPlayerMP) this.shootingEntity)
                    .playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
              }
            }

            // ここでヒット時の効果音がなる
            this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));

            // 当たったあと、弾を消去する。エンティティ貫通がONの弾種はそのまま残す。
            explode = true;
          }
        }
      }

      if (movingobjectposition != null) // blockのみ
      {
        this.xTile = movingobjectposition.blockX;
        this.yTile = movingobjectposition.blockY;
        this.zTile = movingobjectposition.blockZ;
        this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
        this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
        this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX));
        this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY));
        this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
        f2 =
            MathHelper.sqrt_double(
                this.motionX * this.motionX
                    + this.motionY * this.motionY
                    + this.motionZ * this.motionZ);
        this.posX -= this.motionX / f2 * 0.05000000074505806D;
        this.posY -= this.motionY / f2 * 0.05000000074505806D;
        this.posZ -= this.motionZ / f2 * 0.05000000074505806D;
        this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
        this.inGround = true;

        if (this.inTile != null) {
          // Block側に衝突を伝える
          this.inTile.onEntityCollidedWithBlock(
              this.worldObj, this.xTile, this.yTile, this.zTile, this);
        }
      }
    }

    // さいごに爆発処理
    int live = (targetEntity != null && targetEntity.isEntityAlive()) ? 10 : 600;

    if (explode || this.livingTimeCount > live) {
      if (this.isExploded() == 0) {
        AMTLogger.debugInfo("explosion");
        this.setExplosion();
        if (!DCsConfig.disableMissileExplosion && !worldObj.isRemote) {
          float f = 5.0F;
          CustomExplosion explosion =
              new CustomExplosion(
                  worldObj,
                  this,
                  shootingEntity,
                  this.posX,
                  this.posY,
                  this.posZ,
                  f,
                  CustomExplosion.Type.Anchor,
                  true);
          explosion.doExplosion();
        }
      }
    }

    // 追尾
    if (active) {
      if (targetEntity != null && targetEntity.isEntityAlive()) {
        double dx = targetEntity.posX - this.posX;
        double dy = targetEntity.boundingBox.minY + (targetEntity.height / 2.0D) - this.posY;
        double dz = targetEntity.posZ - this.posZ;
        double d3 = MathHelper.sqrt_double(dx * dx + dz * dz);

        if (d3 >= 1.0E-7D) {
          float f4 = (float) d3 * 0.2F;
          double dy2 = dy + f4;

          float ff = MathHelper.sqrt_double(dx * dx + dy2 * dy2 + dz * dz);
          dx /= ff;
          dy /= ff;
          dz /= ff;

          this.motionX = (this.motionX + dx) / 2;
          this.motionY = (this.motionY + dy) / 2;
          this.motionZ = (this.motionZ + dz) / 2;

          this.motionX *= 1.25D;
          this.motionY *= 1.25D;
          this.motionZ *= 1.25D;
        }
      }
    }

    // 直前のパラメータと新パラメータを一致させているところ。
    // また、速度に応じてエンティティの向きを調整し、常に進行方向に前面が向くようにしている。
    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI);
    }

    // 改めてポジションに速度を加算。向きも更新。
    this.posX += this.motionX;
    this.posY += this.motionY;
    this.posZ += this.motionZ;
    float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
    this.rotationPitch = (float) (Math.atan2(this.motionY, f2) * 180.0D / Math.PI);

    while (this.rotationPitch - this.prevRotationPitch < -180.0F) {
      this.prevRotationPitch -= 360.0F;
    }

    while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
      this.prevRotationPitch += 360.0F;
    }

    while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
      this.prevRotationYaw -= 360.0F;
    }

    while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
      this.prevRotationYaw += 360.0F;
    }

    this.rotationPitch =
        this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
    this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;

    // 水中に有る
    if (this.isInWater()) {
      // 泡パーティクルが出る
      for (int j1 = 0; j1 < 4; ++j1) {
        float f3 = 0.25F;
        this.worldObj.spawnParticle(
            "bubble",
            this.posX - this.motionX * f3,
            this.posY - this.motionY * f3,
            this.posZ - this.motionZ * f3,
            this.motionX,
            this.motionY,
            this.motionZ);
      }
    }

    this.setPosition(this.posX, this.posY, this.posZ);
    this.func_145775_I();
  }
コード例 #9
0
ファイル: GuiIngame.java プロジェクト: DUFULL/InstanceClient
  private void func_180477_d(ScaledResolution p_180477_1_) {
    if (this.mc.func_175606_aa() instanceof EntityPlayer) {
      EntityPlayer var2 = (EntityPlayer) this.mc.func_175606_aa();
      int var3 = MathHelper.ceiling_float_int(var2.getHealth());
      boolean var4 =
          this.field_175191_F > (long) this.updateCounter
              && (this.field_175191_F - (long) this.updateCounter) / 3L % 2L == 1L;

      if (var3 < this.field_175194_C && var2.hurtResistantTime > 0) {
        this.field_175190_E = Minecraft.getSystemTime();
        this.field_175191_F = (long) (this.updateCounter + 20);
      } else if (var3 > this.field_175194_C && var2.hurtResistantTime > 0) {
        this.field_175190_E = Minecraft.getSystemTime();
        this.field_175191_F = (long) (this.updateCounter + 10);
      }

      if (Minecraft.getSystemTime() - this.field_175190_E > 1000L) {
        this.field_175194_C = var3;
        this.field_175189_D = var3;
        this.field_175190_E = Minecraft.getSystemTime();
      }

      this.field_175194_C = var3;
      int var5 = this.field_175189_D;
      this.rand.setSeed((long) (this.updateCounter * 312871));
      boolean var6 = false;
      FoodStats var7 = var2.getFoodStats();
      int var8 = var7.getFoodLevel();
      int var9 = var7.getPrevFoodLevel();
      IAttributeInstance var10 = var2.getEntityAttribute(SharedMonsterAttributes.maxHealth);
      int var11 = p_180477_1_.getScaledWidth() / 2 - 91;
      int var12 = p_180477_1_.getScaledWidth() / 2 + 91;
      int var13 = p_180477_1_.getScaledHeight() - 39;
      float var14 = (float) var10.getAttributeValue();
      float var15 = var2.getAbsorptionAmount();
      int var16 = MathHelper.ceiling_float_int((var14 + var15) / 2.0F / 10.0F);
      int var17 = Math.max(10 - (var16 - 2), 3);
      int var18 = var13 - (var16 - 1) * var17 - 10;
      float var19 = var15;
      int var20 = var2.getTotalArmorValue();
      int var21 = -1;

      if (var2.isPotionActive(Potion.regeneration)) {
        var21 = this.updateCounter % MathHelper.ceiling_float_int(var14 + 5.0F);
      }

      this.mc.mcProfiler.startSection("armor");
      int var22;
      int var23;

      for (var22 = 0; var22 < 10; ++var22) {
        if (var20 > 0) {
          var23 = var11 + var22 * 8;

          if (var22 * 2 + 1 < var20) {
            this.drawTexturedModalRect(var23, var18, 34, 9, 9, 9);
          }

          if (var22 * 2 + 1 == var20) {
            this.drawTexturedModalRect(var23, var18, 25, 9, 9, 9);
          }

          if (var22 * 2 + 1 > var20) {
            this.drawTexturedModalRect(var23, var18, 16, 9, 9, 9);
          }
        }
      }

      this.mc.mcProfiler.endStartSection("health");
      int var25;
      int var26;
      int var27;

      for (var22 = MathHelper.ceiling_float_int((var14 + var15) / 2.0F) - 1; var22 >= 0; --var22) {
        var23 = 16;

        if (var2.isPotionActive(Potion.poison)) {
          var23 += 36;
        } else if (var2.isPotionActive(Potion.wither)) {
          var23 += 72;
        }

        byte var24 = 0;

        if (var4) {
          var24 = 1;
        }

        var25 = MathHelper.ceiling_float_int((float) (var22 + 1) / 10.0F) - 1;
        var26 = var11 + var22 % 10 * 8;
        var27 = var13 - var25 * var17;

        if (var3 <= 4) {
          var27 += this.rand.nextInt(2);
        }

        if (var22 == var21) {
          var27 -= 2;
        }

        byte var28 = 0;

        if (var2.worldObj.getWorldInfo().isHardcoreModeEnabled()) {
          var28 = 5;
        }

        this.drawTexturedModalRect(var26, var27, 16 + var24 * 9, 9 * var28, 9, 9);

        if (var4) {
          if (var22 * 2 + 1 < var5) {
            this.drawTexturedModalRect(var26, var27, var23 + 54, 9 * var28, 9, 9);
          }

          if (var22 * 2 + 1 == var5) {
            this.drawTexturedModalRect(var26, var27, var23 + 63, 9 * var28, 9, 9);
          }
        }

        if (var19 > 0.0F) {
          if (var19 == var15 && var15 % 2.0F == 1.0F) {
            this.drawTexturedModalRect(var26, var27, var23 + 153, 9 * var28, 9, 9);
          } else {
            this.drawTexturedModalRect(var26, var27, var23 + 144, 9 * var28, 9, 9);
          }

          var19 -= 2.0F;
        } else {
          if (var22 * 2 + 1 < var3) {
            this.drawTexturedModalRect(var26, var27, var23 + 36, 9 * var28, 9, 9);
          }

          if (var22 * 2 + 1 == var3) {
            this.drawTexturedModalRect(var26, var27, var23 + 45, 9 * var28, 9, 9);
          }
        }
      }

      Entity var34 = var2.ridingEntity;
      int var36;

      if (var34 == null) {
        this.mc.mcProfiler.endStartSection("food");

        for (var23 = 0; var23 < 10; ++var23) {
          var36 = var13;
          var25 = 16;
          byte var38 = 0;

          if (var2.isPotionActive(Potion.hunger)) {
            var25 += 36;
            var38 = 13;
          }

          if (var2.getFoodStats().getSaturationLevel() <= 0.0F
              && this.updateCounter % (var8 * 3 + 1) == 0) {
            var36 = var13 + (this.rand.nextInt(3) - 1);
          }

          if (var6) {
            var38 = 1;
          }

          var27 = var12 - var23 * 8 - 9;
          this.drawTexturedModalRect(var27, var36, 16 + var38 * 9, 27, 9, 9);

          if (var6) {
            if (var23 * 2 + 1 < var9) {
              this.drawTexturedModalRect(var27, var36, var25 + 54, 27, 9, 9);
            }

            if (var23 * 2 + 1 == var9) {
              this.drawTexturedModalRect(var27, var36, var25 + 63, 27, 9, 9);
            }
          }

          if (var23 * 2 + 1 < var8) {
            this.drawTexturedModalRect(var27, var36, var25 + 36, 27, 9, 9);
          }

          if (var23 * 2 + 1 == var8) {
            this.drawTexturedModalRect(var27, var36, var25 + 45, 27, 9, 9);
          }
        }
      } else if (var34 instanceof EntityLivingBase) {
        this.mc.mcProfiler.endStartSection("mountHealth");
        EntityLivingBase var35 = (EntityLivingBase) var34;
        var36 = (int) Math.ceil((double) var35.getHealth());
        float var37 = var35.getMaxHealth();
        var26 = (int) (var37 + 0.5F) / 2;

        if (var26 > 30) {
          var26 = 30;
        }

        var27 = var13;

        for (int var39 = 0; var26 > 0; var39 += 20) {
          int var29 = Math.min(var26, 10);
          var26 -= var29;

          for (int var30 = 0; var30 < var29; ++var30) {
            byte var31 = 52;
            byte var32 = 0;

            if (var6) {
              var32 = 1;
            }

            int var33 = var12 - var30 * 8 - 9;
            this.drawTexturedModalRect(var33, var27, var31 + var32 * 9, 9, 9, 9);

            if (var30 * 2 + 1 + var39 < var36) {
              this.drawTexturedModalRect(var33, var27, var31 + 36, 9, 9, 9);
            }

            if (var30 * 2 + 1 + var39 == var36) {
              this.drawTexturedModalRect(var33, var27, var31 + 45, 9, 9, 9);
            }
          }

          var27 -= 10;
        }
      }

      this.mc.mcProfiler.endStartSection("air");

      if (var2.isInsideOfMaterial(Material.water)) {
        var23 = this.mc.thePlayer.getAir();
        var36 = MathHelper.ceiling_double_int((double) (var23 - 2) * 10.0D / 300.0D);
        var25 = MathHelper.ceiling_double_int((double) var23 * 10.0D / 300.0D) - var36;

        for (var26 = 0; var26 < var36 + var25; ++var26) {
          if (var26 < var36) {
            this.drawTexturedModalRect(var12 - var26 * 8 - 9, var18, 16, 18, 9, 9);
          } else {
            this.drawTexturedModalRect(var12 - var26 * 8 - 9, var18, 25, 18, 9, 9);
          }
        }
      }

      this.mc.mcProfiler.endSection();
    }
  }