Exemplo n.º 1
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

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

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= 0.03999999910593033D;

    if (this.worldObj.getBlockMaterial(
            MathHelper.floor_double(this.posX),
            MathHelper.floor_double(this.posY),
            MathHelper.floor_double(this.posZ))
        == Material.lava) {
      this.motionY = 0.20000000298023224D;
      this.motionX = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
      this.motionZ = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
      this.worldObj.playSoundAtEntity(
          this, "random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F);
    }

    this.pushOutOfBlocks(
        this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    float var1 = 0.98F;

    if (this.onGround) {
      var1 = 0.58800006F;
      int var2 =
          this.worldObj.getBlockId(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.boundingBox.minY) - 1,
              MathHelper.floor_double(this.posZ));

      if (var2 > 0) {
        var1 = Block.blocksList[var2].slipperiness * 0.98F;
      }
    }

    this.motionX *= (double) var1;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= (double) var1;

    if (this.onGround) {
      this.motionY *= -0.5D;
    }

    ++this.age;

    if (this.age >= 6000) {
      this.setDead();
    }
  }
Exemplo n.º 2
0
 @Override
 public void onUpdate() {
   super.onUpdate();
   if (duration > 0) {
     if (duration < ticksExisted) {
       this.setDead();
     }
   }
   moveEntity(motionX, motionY, motionZ);
 }
Exemplo n.º 3
0
  /** Handles updating while being ridden by an entity */
  public void updateRidden() {
    if (ridingEntity.isDead) {
      ridingEntity = null;
      return;
    }

    motionX = 0.0D;
    motionY = 0.0D;
    motionZ = 0.0D;
    onUpdate();

    if (ridingEntity == null) {
      return;
    }

    ridingEntity.updateRiderPosition();
    entityRiderYawDelta += ridingEntity.rotationYaw - ridingEntity.prevRotationYaw;
    entityRiderPitchDelta += ridingEntity.rotationPitch - ridingEntity.prevRotationPitch;

    for (; entityRiderYawDelta >= 180D; entityRiderYawDelta -= 360D) {}

    for (; entityRiderYawDelta < -180D; entityRiderYawDelta += 360D) {}

    for (; entityRiderPitchDelta >= 180D; entityRiderPitchDelta -= 360D) {}

    for (; entityRiderPitchDelta < -180D; entityRiderPitchDelta += 360D) {}

    double d = entityRiderYawDelta * 0.5D;
    double d1 = entityRiderPitchDelta * 0.5D;
    float f = 10F;

    if (d > (double) f) {
      d = f;
    }

    if (d < (double) (-f)) {
      d = -f;
    }

    if (d1 > (double) f) {
      d1 = f;
    }

    if (d1 < (double) (-f)) {
      d1 = -f;
    }

    entityRiderYawDelta -= d;
    entityRiderPitchDelta -= d1;
    rotationYaw += d;
    rotationPitch += d1;
  }
 public void onUpdate() {
   decayFlash();
   super.onUpdate();
   onLivingUpdate();
   double d = posX - prevPosX;
   double d1 = posZ - prevPosZ;
   float f = MathHelper.sqrt_double(d * d + d1 * d1);
   float f1 = renderYawOffset;
   float f2 = 0.0F;
   field_9362_u = field_9361_v;
   float f3 = 0.0F;
   if (f > 0.05F) {
     f3 = 1.0F;
     f2 = f * 3F;
     f1 = ((float) Math.atan2(d1, d) * 180F) / 3.141593F - 90F;
   }
   if (swingProgress > 0.0F) {
     f1 = rotationYaw;
   }
   if (!onGround) {
     f3 = 0.0F;
   }
   field_9361_v = field_9361_v + (f3 - field_9361_v) * 0.3F;
   float f4;
   for (f4 = f1 - renderYawOffset; f4 < -180F; f4 += 360F) {}
   for (; f4 >= 180F; f4 -= 360F) {}
   renderYawOffset += f4 * 0.3F;
   float f5;
   for (f5 = rotationYaw - renderYawOffset; f5 < -180F; f5 += 360F) {}
   for (; f5 >= 180F; f5 -= 360F) {}
   boolean flag = f5 < -90F || f5 >= 90F;
   if (f5 < -75F) {
     f5 = -75F;
   }
   if (f5 >= 75F) {
     f5 = 75F;
   }
   renderYawOffset = rotationYaw - f5;
   if (f5 * f5 > 2500F) {
     renderYawOffset += f5 * 0.2F;
   }
   if (flag) {
     f2 *= -1F;
   }
   for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}
   for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}
   for (; renderYawOffset - prevRenderYawOffset < -180F; prevRenderYawOffset -= 360F) {}
   for (; renderYawOffset - prevRenderYawOffset >= 180F; prevRenderYawOffset += 360F) {}
   for (; rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {}
   for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}
   field_9360_w += f2;
 }
Exemplo n.º 5
0
  public void onUpdate() {
    super.onUpdate();
    if (getTimeSinceHit() > 0) {
      setTimeSinceHit(getTimeSinceHit() - 1);
    }
    if (getDamageTaken() > 0) {
      setDamageTaken(getDamageTaken() - 1);
    }
    prevPosX = posX;
    prevPosY = posY;
    prevPosZ = posZ;
    int i = 5;
    double d = 0.0D;
    for (int j = 0; j < i; j++) {
      double d2 =
          (boundingBox.minY
                  + ((boundingBox.maxY - boundingBox.minY) * (double) (j + 0)) / (double) i)
              - 0.125D;
      double d8 =
          (boundingBox.minY
                  + ((boundingBox.maxY - boundingBox.minY) * (double) (j + 1)) / (double) i)
              - 0.125D;
      AxisAlignedBB axisalignedbb =
          AxisAlignedBB.getBoundingBox(
              boundingBox.minX, d2, boundingBox.minZ, boundingBox.maxX, d8, boundingBox.maxZ);
      if (worldObj.isAABBInMaterial(axisalignedbb, Material.water)) {
        d += 1.0D / (double) i;
      }
    }

    double d1 = Math.sqrt(motionX * motionX + motionZ * motionZ);
    if (d1 > 0.14999999999999999D) {
      double d3 = Math.cos(((double) rotationYaw * 3.1415926535897931D) / 180D);
      double d9 = Math.sin(((double) rotationYaw * 3.1415926535897931D) / 180D);
      for (int i1 = 0; (double) i1 < 1.0D + d1 * 60D; i1++) {
        double d16 = rand.nextFloat() * 2.0F - 1.0F;
        double d19 = (double) (rand.nextInt(2) * 2 - 1) * 0.69999999999999996D;
        if (rand.nextBoolean()) {
          double d21 = (posX - d3 * d16 * 0.80000000000000004D) + d9 * d19;
          double d23 = posZ - d9 * d16 * 0.80000000000000004D - d3 * d19;
          worldObj.spawnParticle("splash", d21, posY - 0.125D, d23, motionX, motionY, motionZ);
        } else {
          double d22 = posX + d3 + d9 * d16 * 0.69999999999999996D;
          double d24 = (posZ + d9) - d3 * d16 * 0.69999999999999996D;
          worldObj.spawnParticle("splash", d22, posY - 0.125D, d24, motionX, motionY, motionZ);
        }
      }
    }
    if (worldObj.isRemote) {
      if (boatPosRotationIncrements > 0) {
        double d4 = posX + (boatX - posX) / (double) boatPosRotationIncrements;
        double d10 = posY + (boatY - posY) / (double) boatPosRotationIncrements;
        double d13 = posZ + (boatZ - posZ) / (double) boatPosRotationIncrements;
        double d17;
        for (d17 = boatYaw - (double) rotationYaw; d17 < -180D; d17 += 360D) {}
        for (; d17 >= 180D; d17 -= 360D) {}
        rotationYaw += d17 / (double) boatPosRotationIncrements;
        rotationPitch += (boatPitch - (double) rotationPitch) / (double) boatPosRotationIncrements;
        boatPosRotationIncrements--;
        setPosition(d4, d10, d13);
        setRotation(rotationYaw, rotationPitch);
      } else {
        double d5 = posX + motionX;
        double d11 = posY + motionY;
        double d14 = posZ + motionZ;
        setPosition(d5, d11, d14);
        if (onGround) {
          motionX *= 0.5D;
          motionY *= 0.5D;
          motionZ *= 0.5D;
        }
        motionX *= 0.99000000953674316D;
        motionY *= 0.94999998807907104D;
        motionZ *= 0.99000000953674316D;
      }
      return;
    }
    if (d < 1.0D) {
      double d6 = d * 2D - 1.0D;
      motionY += 0.039999999105930328D * d6;
    } else {
      if (motionY < 0.0D) {
        motionY /= 2D;
      }
      motionY += 0.0070000002160668373D;
    }
    if (riddenByEntity != null) {
      motionX += riddenByEntity.motionX * 0.20000000000000001D;
      motionZ += riddenByEntity.motionZ * 0.20000000000000001D;
    }
    double d7 = 0.40000000000000002D;
    if (motionX < -d7) {
      motionX = -d7;
    }
    if (motionX > d7) {
      motionX = d7;
    }
    if (motionZ < -d7) {
      motionZ = -d7;
    }
    if (motionZ > d7) {
      motionZ = d7;
    }
    if (onGround) {
      motionX *= 0.5D;
      motionY *= 0.5D;
      motionZ *= 0.5D;
    }
    moveEntity(motionX, motionY, motionZ);
    if (isCollidedHorizontally && d1 > 0.20000000000000001D) {
      if (!worldObj.isRemote) {
        setDead();
        for (int j = 0; j < 5; j++) {
          entityDropItem(new ItemStack(FloraTrees.redwood, 1, 8), 0F);
        }
      }
    } else {
      motionX *= 0.99000000953674316D;
      motionY *= 0.94999998807907104D;
      motionZ *= 0.99000000953674316D;
    }
    rotationPitch = 0.0F;
    double d12 = rotationYaw;
    double d15 = prevPosX - posX;
    double d18 = prevPosZ - posZ;
    if (d15 * d15 + d18 * d18 > 0.001D) {
      d12 = (float) ((Math.atan2(d18, d15) * 180D) / 3.1415926535897931D);
    }
    double d20;
    for (d20 = d12 - (double) rotationYaw; d20 >= 180D; d20 -= 360D) {}
    for (; d20 < -180D; d20 += 360D) {}
    if (d20 > 20D) {
      d20 = 20D;
    }
    if (d20 < -20D) {
      d20 = -20D;
    }
    rotationYaw += d20;
    setRotation(rotationYaw, rotationPitch);
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            this, boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
    if (list != null && list.size() > 0) {
      for (int j1 = 0; j1 < list.size(); j1++) {
        Entity entity = (Entity) list.get(j1);
        if (entity != riddenByEntity
            && entity.canBePushed()
            && (entity instanceof EucalyptusBoat)) {
          entity.applyEntityCollision(this);
        }
      }
    }
    for (int k1 = 0; k1 < 4; k1++) {
      int l1 = MathHelper.floor_double(posX + ((double) (k1 % 2) - 0.5D) * 0.80000000000000004D);
      int i2 = MathHelper.floor_double(posY);
      int j2 = MathHelper.floor_double(posZ + ((double) (k1 / 2) - 0.5D) * 0.80000000000000004D);
      if (worldObj.getBlockId(l1, i2, j2) == Block.snow.blockID) {
        worldObj.setBlockWithNotify(l1, i2, j2, 0);
      }
    }

    if (riddenByEntity != null && riddenByEntity.isDead) {
      riddenByEntity = null;
    }
  }
Exemplo n.º 6
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.getTimeSinceHit() > 0) {
      this.setTimeSinceHit(this.getTimeSinceHit() - 1);
    }

    if (this.getDamageTaken() > 0) {
      this.setDamageTaken(this.getDamageTaken() - 1);
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    byte var1 = 5;
    double var2 = 0.0D;

    for (int var4 = 0; var4 < var1; ++var4) {
      double var5 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 0)
                  / (double) var1
              - 0.125D;
      double var7 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 1)
                  / (double) var1
              - 0.125D;
      AxisAlignedBB var9 =
          AxisAlignedBB.getBoundingBoxFromPool(
              this.boundingBox.minX,
              var5,
              this.boundingBox.minZ,
              this.boundingBox.maxX,
              var7,
              this.boundingBox.maxZ);

      if (this.worldObj.isAABBInMaterial(var9, Material.water)) {
        var2 += 1.0D / (double) var1;
      }
    }

    double var21 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
    double var6;
    double var8;

    if (var21 > 0.15D) {
      var6 = Math.cos((double) this.rotationYaw * Math.PI / 180.0D);
      var8 = Math.sin((double) this.rotationYaw * Math.PI / 180.0D);

      for (int var10 = 0; (double) var10 < 1.0D + var21 * 60.0D; ++var10) {
        double var11 = (double) (this.rand.nextFloat() * 2.0F - 1.0F);
        double var13 = (double) (this.rand.nextInt(2) * 2 - 1) * 0.7D;
        double var15;
        double var17;

        if (this.rand.nextBoolean()) {
          var15 = this.posX - var6 * var11 * 0.8D + var8 * var13;
          var17 = this.posZ - var8 * var11 * 0.8D - var6 * var13;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        } else {
          var15 = this.posX + var6 + var8 * var11 * 0.7D;
          var17 = this.posZ + var8 - var6 * var11 * 0.7D;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        }
      }
    }

    double var12;
    double var23;

    if (this.worldObj.isRemote) {
      if (this.boatPosRotationIncrements > 0) {
        var6 = this.posX + (this.boatX - this.posX) / (double) this.boatPosRotationIncrements;
        var8 = this.posY + (this.boatY - this.posY) / (double) this.boatPosRotationIncrements;
        var23 = this.posZ + (this.boatZ - this.posZ) / (double) this.boatPosRotationIncrements;

        for (var12 = this.boatYaw - (double) this.rotationYaw; var12 < -180.0D; var12 += 360.0D) {;
        }

        while (var12 >= 180.0D) {
          var12 -= 360.0D;
        }

        this.rotationYaw =
            (float) ((double) this.rotationYaw + var12 / (double) this.boatPosRotationIncrements);
        this.rotationPitch =
            (float)
                ((double) this.rotationPitch
                    + (this.boatPitch - (double) this.rotationPitch)
                        / (double) this.boatPosRotationIncrements);
        --this.boatPosRotationIncrements;
        this.setPosition(var6, var8, var23);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        var6 = this.posX + this.motionX;
        var8 = this.posY + this.motionY;
        var23 = this.posZ + this.motionZ;
        this.setPosition(var6, var8, var23);

        if (this.onGround) {
          this.motionX *= 0.5D;
          this.motionY *= 0.5D;
          this.motionZ *= 0.5D;
        }

        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }
    } else {
      if (var2 < 1.0D) {
        var6 = var2 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var6;
      } else {
        if (this.motionY < 0.0D) {
          this.motionY /= 2.0D;
        }

        this.motionY += 0.007000000216066837D;
      }

      if (this.riddenByEntity != null) {
        this.motionX += this.riddenByEntity.motionX * 0.2D;
        this.motionZ += this.riddenByEntity.motionZ * 0.2D;
      }

      var6 = 0.4D;

      if (this.motionX < -var6) {
        this.motionX = -var6;
      }

      if (this.motionX > var6) {
        this.motionX = var6;
      }

      if (this.motionZ < -var6) {
        this.motionZ = -var6;
      }

      if (this.motionZ > var6) {
        this.motionZ = var6;
      }

      if (this.onGround) {
        this.motionX *= 0.5D;
        this.motionY *= 0.5D;
        this.motionZ *= 0.5D;
      }

      this.moveEntity(this.motionX, this.motionY, this.motionZ);

      if (this.isCollidedHorizontally && var21 > 0.2D) {
        if (!this.worldObj.isRemote) {
          this.setDead();
          int var22;

          for (var22 = 0; var22 < 3; ++var22) {
            this.dropItemWithOffset(Block.planks.blockID, 1, 0.0F);
          }

          for (var22 = 0; var22 < 2; ++var22) {
            this.dropItemWithOffset(Item.stick.shiftedIndex, 1, 0.0F);
          }
        }
      } else {
        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }

      this.rotationPitch = 0.0F;
      var8 = (double) this.rotationYaw;
      var23 = this.prevPosX - this.posX;
      var12 = this.prevPosZ - this.posZ;

      if (var23 * var23 + var12 * var12 > 0.001D) {
        var8 = (double) ((float) (Math.atan2(var12, var23) * 180.0D / Math.PI));
      }

      double var14;

      for (var14 = var8 - (double) this.rotationYaw; var14 >= 180.0D; var14 -= 360.0D) {;
      }

      while (var14 < -180.0D) {
        var14 += 360.0D;
      }

      if (var14 > 20.0D) {
        var14 = 20.0D;
      }

      if (var14 < -20.0D) {
        var14 = -20.0D;
      }

      this.rotationYaw = (float) ((double) this.rotationYaw + var14);
      this.setRotation(this.rotationYaw, this.rotationPitch);
      List var16 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
      int var24;

      if (var16 != null && var16.size() > 0) {
        for (var24 = 0; var24 < var16.size(); ++var24) {
          Entity var18 = (Entity) var16.get(var24);

          if (var18 != this.riddenByEntity && var18.canBePushed() && var18 instanceof EntityBoat) {
            var18.applyEntityCollision(this);
          }
        }
      }

      for (var24 = 0; var24 < 4; ++var24) {
        int var25 = MathHelper.floor_double(this.posX + ((double) (var24 % 2) - 0.5D) * 0.8D);
        int var19 = MathHelper.floor_double(this.posY);
        int var20 = MathHelper.floor_double(this.posZ + ((double) (var24 / 2) - 0.5D) * 0.8D);

        if (this.worldObj.getBlockId(var25, var19, var20) == Block.snow.blockID) {
          this.worldObj.setBlockWithNotify(var25, var19, var20, 0);
        }
      }

      if (this.riddenByEntity != null && this.riddenByEntity.isDead) {
        this.riddenByEntity = null;
      }
    }
  }
Exemplo n.º 7
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    boolean var1 = true;
    int var2 = MathHelper.floor_double(this.posX);
    int var3 = MathHelper.floor_double(this.posY);
    int var4 = MathHelper.floor_double(this.posZ);
    ++this.ticksExisted;
    ++this.tickcount;

    if (this.tickcount > 45) {
      --this.startStops;

      if (this.startStops < 0) {
        this.startStops = 0;
      }

      this.tickcount = 0;
    }

    if (this.unUpdated) {
      if (this.worldObj.getBlockId(var2, var3, var4) == blockID) {
        if (!this.isCeiling()) {
          BlockElevator var5 = (BlockElevator) Block.blocksList[blockID];
          TileEntityElevator var6 = BlockElevator.getTileEntity(this.worldObj, var2, var3, var4);

          if (var6 != null) {
            this.namedFloors = var6.convertFloorMapToArray();
            this.properties = var6.convertBooleanPropertiesToArray();
          }
        }

        if (!this.isCeiling()
            && this.properties != null
            && this.properties.length > 2
            && this.properties[2]) {
          this.worldObj.setBlockWithNotify(var2, var3, var4, ElevatorsCore.Transient.blockID);
        } else {
          this.worldObj.setBlockWithNotify(var2, var3, var4, 0);
        }

        this.worldObj.notifyBlocksOfNeighborChange(var2 - 1, var3, var4, blockID);
        this.worldObj.notifyBlocksOfNeighborChange(var2 + 1, var3, var4, blockID);
        this.worldObj.notifyBlocksOfNeighborChange(var2, var3, var4 - 1, blockID);
        this.worldObj.notifyBlocksOfNeighborChange(var2, var3, var4 + 1, blockID);
      }

      this.conjoinAllNeighbors();
      this.unUpdated = false;
    }

    if (!this.emerHalt) {
      if (!this.isDead && !this.isCeiling()) {
        this.refreshRiders();

        if (this.properties != null && this.properties.length > 2 && this.properties[2]) {
          int var7;
          int var9;
          int var11;

          if (this.motionY > 0.0D) {
            var9 = (int) Math.ceil(this.posX - 0.5D);
            var11 = (int) Math.ceil(this.posY - 0.5D);
            var7 = (int) Math.ceil(this.posZ - 0.5D);
          } else {
            var9 = (int) Math.floor(this.posX - 0.5D);
            var11 = (int) Math.floor(this.posY - 0.5D);
            var7 = (int) Math.floor(this.posZ - 0.5D);
          }

          int var8 = this.worldObj.getBlockId(var9, var11, var7);

          if (var8 == 0) {
            this.worldObj.setBlockWithNotify(var9, var11, var7, ElevatorsCore.Transient.blockID);
          }
        }
      }

      if (this.worldObj.isRemote) {
        this.setPosition(this.posX, this.posY, this.posZ, true);
        this.say("Speed: " + this.motionY + ", posY: " + this.posY + ", destY: " + this.destY);
        this.say("End Entity Update - Control is remote");
      } else if (!this.center) {
        if (this.centerElevator.isDead) {
          this.setDead();
        }

        this.say("End Entity Update - Not Center");
      } else {
        if (!this.conjoinedHasBeenSet) {
          this.conjoinAllNeighbors();
        }

        if (this.waitToAccelerate < 15) {
          if (this.waitToAccelerate < 10) {
            this.elevatorSpeed = 0.0F;
          } else {
            this.elevatorSpeed = 0.016F;
          }

          ++this.waitToAccelerate;

          if (!this.conjoinedelevators.contains(this)) {
            this.conjoinedelevators.add(this);
          }

          this.say("Waiting to accelerate");
        } else {
          float var10 = this.elevatorSpeed + 0.01F;

          if (var10 > 0.4F) {
            var10 = 0.4F;
          }

          float var12 = (var10 * var10 - 2.5600003E-4F) / 0.02F + 0.125F;
          this.say(
              "Speed: "
                  + this.motionY
                  + ", posY: "
                  + this.posY
                  + ", destY: "
                  + this.destY
                  + ", range: "
                  + var12);

          if (!this.slowingDown && MathHelper.abs((float) (this.destY - this.posY)) >= var12) {
            this.elevatorSpeed = var10;
          } else {
            this.elevatorSpeed -= 0.01F;
            this.slowingDown = true;
          }

          if (this.elevatorSpeed > 0.4F) {
            this.elevatorSpeed = 0.4F;
          }

          if (this.elevatorSpeed < 0.016F) {
            this.elevatorSpeed = 0.016F;
          }
        }

        this.atDestination =
            this.onGround || MathHelper.abs((float) (this.destY - this.posY)) < this.elevatorSpeed;

        if (this.destY < 1.0F || this.destY > ElevatorsCore.max_elevator_Y) {
          this.atDestination = true;
          this.say("Requested destination is too high or too low!");
          this.say("Requested: " + this.destY + ", max: " + ElevatorsCore.max_elevator_Y);
        }

        if (!this.atDestination) {
          this.motionY =
              this.destY > this.posY ? (double) this.elevatorSpeed : (double) (-this.elevatorSpeed);
          this.updateAllConjoined();
        } else if (this.atDestination) {
          this.killAllConjoined();
          return;
        }

        if (MathHelper.abs((float) this.motionY) < 0.016F && this.stillcount++ > 10) {
          this.killAllConjoined();
        } else {
          this.stillcount = 0;
        }

        super.onUpdate();
        this.say("End Entity Update");
      }
    }
  }
Exemplo n.º 8
0
  public void onUpdate() {
    if (!this.worldObj.isRemote
        && (this.shootingEntity != null && this.shootingEntity.isDead
            || !this.worldObj.blockExists((int) this.posX, (int) this.posY, (int) this.posZ))) {
      this.setDead();
    } else {
      super.onUpdate();
      this.setFire(1);
      if (this.inGround) {
        int var1 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
        if (var1 == this.inTile) {
          ++this.ticksAlive;
          if (this.ticksAlive == 600) {
            this.setDead();
          }

          return;
        }

        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.ticksAlive = 0;
        this.ticksInAir = 0;
      } else {
        ++this.ticksInAir;
      }

      Vec3D var15 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      Vec3D var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var15, var2);
      var15 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      if (var3 != null) {
        var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
      }

      Entity var4 = null;
      List var5 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var6 = 0.0D;

      for (int var8 = 0; var8 < var5.size(); ++var8) {
        Entity var9 = (Entity) var5.get(var8);
        if (var9.canBeCollidedWith()
            && (!var9.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) {
          float var10 = 0.3F;
          AxisAlignedBB var11 =
              var9.boundingBox.expand((double) var10, (double) var10, (double) var10);
          MovingObjectPosition var12 = var11.calculateIntercept(var15, var2);
          if (var12 != null) {
            double var13 = var15.distanceTo(var12.hitVec);
            if (var13 < var6 || var6 == 0.0D) {
              var4 = var9;
              var6 = var13;
            }
          }
        }
      }

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

      if (var3 != null) {
        this.func_40071_a(var3);
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      float var16 =
          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) var16) * 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 var17 = 0.95F;
      if (this.isInWater()) {
        for (int var19 = 0; var19 < 4; ++var19) {
          float var18 = 0.25F;
          this.worldObj.spawnParticle(
              "bubble",
              this.posX - this.motionX * (double) var18,
              this.posY - this.motionY * (double) var18,
              this.posZ - this.motionZ * (double) var18,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        var17 = 0.8F;
      }

      this.motionX += this.accelerationX;
      this.motionY += this.accelerationY;
      this.motionZ += this.accelerationZ;
      this.motionX *= (double) var17;
      this.motionY *= (double) var17;
      this.motionZ *= (double) var17;
      this.worldObj.spawnParticle(
          "smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
      this.setPosition(this.posX, this.posY, this.posZ);
    }
  }
Exemplo n.º 9
0
  @Override
  public void onUpdate() {
    super.onUpdate();
    if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
      prevRotationYaw =
          rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
      prevRotationPitch =
          rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
    }
    if (arrowShake > 0) {
      arrowShake--;
    }
    if (inGround) {
      int i = worldObj.getBlockId(xTile, yTile, zTile);
      int j = worldObj.getBlockMetadata(xTile, yTile, zTile);
      if (i != inTile || j != inData) {
        inGround = false;
        motionX *= rand.nextFloat() * 0.2F;
        motionY *= rand.nextFloat() * 0.2F;
        motionZ *= rand.nextFloat() * 0.2F;
        ticksInGround = 0;
        ticksFlying = 0;
      } else {
        ticksInGround++;
        tickInGround();
        if (ticksInGround == ttlInGround) {
          setDead();
        }
        return;
      }
    } else {
      ticksFlying++;
    }
    tickFlying();
    Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    if (movingobjectposition != null) {
      vec3d1 =
          Vec3.createVectorHelper(
              movingobjectposition.hitVec.xCoord,
              movingobjectposition.hitVec.yCoord,
              movingobjectposition.hitVec.zCoord);
    }
    Entity entity = null;
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;
    for (int k = 0; k < list.size(); k++) {
      Entity entity2 = (Entity) list.get(k);
      if (!canBeShot(entity2)) {
        continue;
      }
      float f3 = hitBox;
      AxisAlignedBB axisalignedbb = entity2.boundingBox.expand(f3, f3, f3);
      MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
      if (movingobjectposition1 == null) {
        continue;
      }
      double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
      if (d1 < d || d == 0.0D) {
        entity = entity2;
        d = d1;
      }
    }

    if (entity != null) {
      movingobjectposition = new MovingObjectPosition(entity);
    }
    if (movingobjectposition != null && (entity != shooter || ticksFlying > 2) && (onHit())) {
      Entity entity1 = movingobjectposition.entityHit;
      if (entity1 != null) {
        if (!worldObj.isRemote) {
          if (onHitTarget(entity1) && hasTorchAttachment == false) {
            if ((entity1 instanceof EntityLiving) && !(entity1 instanceof EntityPlayer)) {
              ++((EntityLiving) entity1).arrowHitTempCounter;
            }

            entity1.attackEntityFrom(
                DamageSource.causePlayerDamage((EntityPlayer) shooter),
                this.arrowCritical ? dmg * 2 : dmg);
            setDead();
          }
        }
      } else {
        xTile = movingobjectposition.blockX;
        yTile = movingobjectposition.blockY;
        zTile = movingobjectposition.blockZ;
        inTile = worldObj.getBlockId(xTile, yTile, zTile);
        inData = worldObj.getBlockMetadata(xTile, yTile, zTile);
        Block block = Block.blocksList[inTile];
        if (block != null && !(block instanceof BlockFlower)) {
          if (onHitBlock(movingobjectposition)) {
            motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
            motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
            motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
            float f2 =
                MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
            posX -= (motionX / (double) f2) * 0.05000000074505806D;
            posY -= (motionY / (double) f2) * 0.05000000074505806D;
            posZ -= (motionZ / (double) f2) * 0.05000000074505806D;
            inGround = true;
            arrowShake = 7;
            this.arrowCritical = false;
          }
        }
      }
    }
    if (movingobjectposition != null && !worldObj.isRemote) {
      Entity entity1 = movingobjectposition.entityHit;
      if (entity1 != null && entity1 instanceof EntityLiving && entity1 != shooter) {
        if (hasExplosiveAttachment && ((EntityLiving) entity1).arrowHitTempCounter < 10) {
          this.worldObj.createExplosion(
              this,
              (int) Math.floor(((EntityLiving) entity1).posX),
              (int) ((EntityLiving) entity1).posY,
              (int) Math.floor(((EntityLiving) entity1).posZ),
              1);
        }

        if (hasIceAttachment) {
          ((EntityLiving) entity1)
              .addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 280, 3));
        }

        if (hasPoisonAttachment) {
          ((EntityLiving) entity1).addPotionEffect(new PotionEffect(Potion.poison.id, 280, 3));
        }

        if (hasLightningAttachment) {
          this.worldObj.addWeatherEffect(
              new EntityLightningBolt(this.worldObj, entity1.posX, entity1.posY, entity1.posZ));
          this.setDead();
        }
      }
    }

    FMLLog.info("" + this.inGround);

    posX += motionX;
    posZ += motionZ;
    posY += motionY;
    handleMotionUpdate();
    float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
    for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D);
        rotationPitch - prevRotationPitch < -180F;
        prevRotationPitch -= 360F) {}
    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}
    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}
    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}
    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    setPosition(posX, posY, posZ);
  }
Exemplo n.º 10
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 f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) ((Math.atan2(this.motionX, this.motionZ) * 180D) / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) ((Math.atan2(this.motionY, f) * 180D) / 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(
              Vec3.func_72437_a().func_72345_a(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.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;
        return;
      }

      this.ticksInGround++;

      if (this.ticksInGround == 1200) {
        setDead();
      }

      return;
    }

    this.ticksInAir++;
    Vec3 vec3 = Vec3.func_72437_a().func_72345_a(this.posX, this.posY, this.posZ);
    Vec3 vec3_1 =
        Vec3.func_72437_a()
            .func_72345_a(
                this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
    MovingObjectPosition movingobjectposition =
        this.worldObj.rayTraceBlocks_do_do(vec3, vec3_1, false, true);
    vec3 = Vec3.func_72437_a().func_72345_a(this.posX, this.posY, this.posZ);
    vec3_1 =
        Vec3.func_72437_a()
            .func_72345_a(
                this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

    if (movingobjectposition != null) {
      vec3_1 =
          Vec3.func_72437_a()
              .func_72345_a(
                  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 d = 0.0D;
    Iterator iterator = list.iterator();

    do {
      if (!iterator.hasNext()) {
        break;
      }

      Entity entity1 = (Entity) iterator.next();

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

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

          if (d1 < d || d == 0.0D) {
            entity = entity1;
            d = d1;
          }
        }
      }
    } while (true);

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

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

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

        DamageSource damagesource = null;

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

        if (isBurning()) {
          movingobjectposition.entityHit.setFire(5);
        }

        if (movingobjectposition.entityHit.attackEntityFrom(damagesource, i1)) {
          if (movingobjectposition.entityHit instanceof EntityLiving) {
            ((EntityLiving) movingobjectposition.entityHit).arrowHitTempCounter++;

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

              if (f7 > 0.0F) {
                movingobjectposition.entityHit.addVelocity(
                    (this.motionX * this.knockbackStrength * 0.60000002384185791D) / f7,
                    0.10000000000000001D,
                    (this.motionZ * this.knockbackStrength * 0.60000002384185791D) / f7);
              }
            }
          }

          this.worldObj.playSoundAtEntity(
              this, "random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
          setDead();
        } else {
          this.motionX *= -0.10000000149011612D;
          this.motionY *= -0.10000000149011612D;
          this.motionZ *= -0.10000000149011612D;
          this.rotationYaw += 180F;
          this.prevRotationYaw += 180F;
          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 = (float) (movingobjectposition.hitVec.xCoord - this.posX);
        this.motionY = (float) (movingobjectposition.hitVec.yCoord - this.posY);
        this.motionZ = (float) (movingobjectposition.hitVec.zCoord - this.posZ);
        float 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.worldObj.playSoundAtEntity(
            this, "random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
        this.inGround = true;
        this.arrowShake = 7;
        func_70243_d(false);
      }
    }

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

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

    for (this.rotationPitch = (float) ((Math.atan2(this.motionY, f3) * 180D) / Math.PI);
        this.rotationPitch - this.prevRotationPitch < -180F;
        this.prevRotationPitch -= 360F) {}

    for (; this.rotationPitch - this.prevRotationPitch >= 180F; this.prevRotationPitch += 360F) {}

    for (; this.rotationYaw - this.prevRotationYaw < -180F; this.prevRotationYaw -= 360F) {}

    for (; this.rotationYaw - this.prevRotationYaw >= 180F; this.prevRotationYaw += 360F) {}

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

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

      f4 = 0.8F;
    }

    this.motionX *= f4;
    this.motionY *= f4;
    this.motionZ *= f4;
    this.motionY -= f6;
    setPosition(this.posX, this.posY, this.posZ);
    func_70017_D();
  }
Exemplo n.º 11
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.getTimeSinceHit() > 0) {
      this.setTimeSinceHit(this.getTimeSinceHit() - 1);
    }

    if (this.getDamageTaken() > 0) {
      this.setDamageTaken(this.getDamageTaken() - 1);
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    byte var1 = 5;
    double var2 = 0.0D;

    for (int var4 = 0; var4 < var1; ++var4) {
      double var5 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 0)
                  / (double) var1
              - 0.125D;
      double var7 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 1)
                  / (double) var1
              - 0.125D;
      AxisAlignedBB var9 =
          AxisAlignedBB.getAABBPool()
              .addOrModifyAABBInPool(
                  this.boundingBox.minX,
                  var5,
                  this.boundingBox.minZ,
                  this.boundingBox.maxX,
                  var7,
                  this.boundingBox.maxZ);

      if (this.worldObj.isAABBInMaterial(var9, Material.water)) {
        var2 += 1.0D / (double) var1;
      }
    }

    double var24 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
    double var6;
    double var8;

    if (var24 > 0.26249999999999996D) {
      var6 = Math.cos((double) this.rotationYaw * Math.PI / 180.0D);
      var8 = Math.sin((double) this.rotationYaw * Math.PI / 180.0D);

      for (int var10 = 0; (double) var10 < 1.0D + var24 * 60.0D; ++var10) {
        double var11 = (double) (this.rand.nextFloat() * 2.0F - 1.0F);
        double var13 = (double) (this.rand.nextInt(2) * 2 - 1) * 0.7D;
        double var15;
        double var17;

        if (this.rand.nextBoolean()) {
          var15 = this.posX - var6 * var11 * 0.8D + var8 * var13;
          var17 = this.posZ - var8 * var11 * 0.8D - var6 * var13;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        } else {
          var15 = this.posX + var6 + var8 * var11 * 0.7D;
          var17 = this.posZ + var8 - var6 * var11 * 0.7D;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        }
      }
    }

    double var12;
    double var26;

    if (this.worldObj.isRemote && this.field_70279_a) {
      if (this.boatPosRotationIncrements > 0) {
        var6 = this.posX + (this.boatX - this.posX) / (double) this.boatPosRotationIncrements;
        var8 = this.posY + (this.boatY - this.posY) / (double) this.boatPosRotationIncrements;
        var26 = this.posZ + (this.boatZ - this.posZ) / (double) this.boatPosRotationIncrements;
        var12 = MathHelper.wrapAngleTo180_double(this.boatYaw - (double) this.rotationYaw);
        this.rotationYaw =
            (float) ((double) this.rotationYaw + var12 / (double) this.boatPosRotationIncrements);
        this.rotationPitch =
            (float)
                ((double) this.rotationPitch
                    + (this.boatPitch - (double) this.rotationPitch)
                        / (double) this.boatPosRotationIncrements);
        --this.boatPosRotationIncrements;
        this.setPosition(var6, var8, var26);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        var6 = this.posX + this.motionX;
        var8 = this.posY + this.motionY;
        var26 = this.posZ + this.motionZ;
        this.setPosition(var6, var8, var26);

        if (this.onGround) {
          this.motionX *= 0.5D;
          this.motionY *= 0.5D;
          this.motionZ *= 0.5D;
        }

        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }
    } else {
      if (var2 < 1.0D) {
        var6 = var2 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var6;
      } else {
        if (this.motionY < 0.0D) {
          this.motionY /= 2.0D;
        }

        this.motionY += 0.007000000216066837D;
      }

      if (this.riddenByEntity != null) {
        this.motionX += this.riddenByEntity.motionX * this.field_70276_b;
        this.motionZ += this.riddenByEntity.motionZ * this.field_70276_b;
      }

      var6 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

      if (var6 > 0.35D) {
        var8 = 0.35D / var6;
        this.motionX *= var8;
        this.motionZ *= var8;
        var6 = 0.35D;
      }

      if (var6 > var24 && this.field_70276_b < 0.35D) {
        this.field_70276_b += (0.35D - this.field_70276_b) / 35.0D;

        if (this.field_70276_b > 0.35D) {
          this.field_70276_b = 0.35D;
        }
      } else {
        this.field_70276_b -= (this.field_70276_b - 0.07D) / 35.0D;

        if (this.field_70276_b < 0.07D) {
          this.field_70276_b = 0.07D;
        }
      }

      if (this.onGround) {
        this.motionX *= 0.5D;
        this.motionY *= 0.5D;
        this.motionZ *= 0.5D;
      }

      this.moveEntity(this.motionX, this.motionY, this.motionZ);

      if (this.isCollidedHorizontally && var24 > 0.2D) {
        if (!this.worldObj.isRemote) {
          this.setDead();
          int var25;

          for (var25 = 0; var25 < 3; ++var25) {
            this.dropItemWithOffset(Block.planks.blockID, 1, 0.0F);
          }

          for (var25 = 0; var25 < 2; ++var25) {
            this.dropItemWithOffset(Item.stick.shiftedIndex, 1, 0.0F);
          }
        }
      } else {
        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }

      this.rotationPitch = 0.0F;
      var8 = (double) this.rotationYaw;
      var26 = this.prevPosX - this.posX;
      var12 = this.prevPosZ - this.posZ;

      if (var26 * var26 + var12 * var12 > 0.001D) {
        var8 = (double) ((float) (Math.atan2(var12, var26) * 180.0D / Math.PI));
      }

      double var14 = MathHelper.wrapAngleTo180_double(var8 - (double) this.rotationYaw);

      if (var14 > 20.0D) {
        var14 = 20.0D;
      }

      if (var14 < -20.0D) {
        var14 = -20.0D;
      }

      this.rotationYaw = (float) ((double) this.rotationYaw + var14);
      this.setRotation(this.rotationYaw, this.rotationPitch);

      if (!this.worldObj.isRemote) {
        List var16 =
            this.worldObj.getEntitiesWithinAABBExcludingEntity(
                this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
        int var27;

        if (var16 != null && !var16.isEmpty()) {
          for (var27 = 0; var27 < var16.size(); ++var27) {
            Entity var18 = (Entity) var16.get(var27);

            if (var18 != this.riddenByEntity
                && var18.canBePushed()
                && var18 instanceof EntityBoat) {
              var18.applyEntityCollision(this);
            }
          }
        }

        for (var27 = 0; var27 < 4; ++var27) {
          int var28 = MathHelper.floor_double(this.posX + ((double) (var27 % 2) - 0.5D) * 0.8D);
          int var19 = MathHelper.floor_double(this.posZ + ((double) (var27 / 2) - 0.5D) * 0.8D);

          for (int var20 = 0; var20 < 2; ++var20) {
            int var21 = MathHelper.floor_double(this.posY) + var20;
            int var22 = this.worldObj.getBlockId(var28, var21, var19);
            int var23 = this.worldObj.getBlockMetadata(var28, var21, var19);

            if (var22 == Block.snow.blockID) {
              this.worldObj.setBlockWithNotify(var28, var21, var19, 0);
            } else if (var22 == Block.waterlily.blockID) {
              Block.waterlily.dropBlockAsItemWithChance(
                  this.worldObj, var28, var21, var19, var23, 0.3F, 0);
              this.worldObj.setBlockWithNotify(var28, var21, var19, 0);
            }
          }
        }

        if (this.riddenByEntity != null && this.riddenByEntity.isDead) {
          this.riddenByEntity = null;
        }
      }
    }
  }
Exemplo n.º 12
0
 public void onUpdate() {
   lastTickPosX = posX;
   lastTickPosY = posY;
   lastTickPosZ = posZ;
   super.onUpdate();
   posX += motionX;
   posY += motionY;
   posZ += motionZ;
   float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
   rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
   for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
       rotationPitch - prevRotationPitch < -180F;
       prevRotationPitch -= 360F) {}
   for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}
   for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}
   for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}
   rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
   rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
   if (!worldObj.multiplayerWorld) {
     double d = field_40094_b - posX;
     double d1 = field_40091_d - posZ;
     float f2 = (float) Math.sqrt(d * d + d1 * d1);
     float f3 = (float) Math.atan2(d1, d);
     double d2 = (double) f + (double) (f2 - f) * 0.0025000000000000001D;
     if (f2 < 1.0F) {
       d2 *= 0.80000000000000004D;
       motionY *= 0.80000000000000004D;
     }
     motionX = Math.cos(f3) * d2;
     motionZ = Math.sin(f3) * d2;
     if (posY < field_40095_c) {
       motionY = motionY + (1.0D - motionY) * 0.014999999664723873D;
     } else {
       motionY = motionY + (-1D - motionY) * 0.014999999664723873D;
     }
   }
   float f1 = 0.25F;
   if (isInWater()) {
     for (int i = 0; i < 4; i++) {
       worldObj.spawnParticle(
           "bubble",
           posX - motionX * (double) f1,
           posY - motionY * (double) f1,
           posZ - motionZ * (double) f1,
           motionX,
           motionY,
           motionZ);
     }
   } else {
     worldObj.spawnParticle(
         "portal",
         ((posX - motionX * (double) f1) + rand.nextDouble() * 0.59999999999999998D)
             - 0.29999999999999999D,
         posY - motionY * (double) f1 - 0.5D,
         ((posZ - motionZ * (double) f1) + rand.nextDouble() * 0.59999999999999998D)
             - 0.29999999999999999D,
         motionX,
         motionY,
         motionZ);
   }
   if (!worldObj.multiplayerWorld) {
     setPosition(posX, posY, posZ);
     despawnTimer++;
     if (despawnTimer > 80 && !worldObj.multiplayerWorld) {
       setEntityDead();
       if (shatterOrDrop) {
         worldObj.spawnEntityInWorld(
             new EntityItem(worldObj, posX, posY, posZ, new ItemStack(Item.eyeOfEnder)));
       } else {
         worldObj.playAuxSFX(
             2003, (int) Math.round(posX), (int) Math.round(posY), (int) Math.round(posZ), 0);
       }
     }
   }
 }
Exemplo n.º 13
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    if (!worldObj.isRemote
        && (shootingEntity != null && shootingEntity.isDead
            || !worldObj.blockExists((int) posX, (int) posY, (int) posZ))) {
      setDead();
      return;
    }

    super.onUpdate();
    setFire(1);

    if (inGround) {
      int i = worldObj.getBlockId(xTile, yTile, zTile);

      if (i != inTile) {
        inGround = false;
        motionX *= rand.nextFloat() * 0.2F;
        motionY *= rand.nextFloat() * 0.2F;
        motionZ *= rand.nextFloat() * 0.2F;
        ticksAlive = 0;
        ticksInAir = 0;
      } else {
        ticksAlive++;

        if (ticksAlive == 600) {
          setDead();
        }

        return;
      }
    } else {
      ticksInAir++;
    }

    Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
    Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3D.createVector(posX, posY, posZ);
    vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);

    if (movingobjectposition != null) {
      vec3d1 =
          Vec3D.createVector(
              movingobjectposition.hitVec.xCoord,
              movingobjectposition.hitVec.yCoord,
              movingobjectposition.hitVec.zCoord);
    }

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

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

      if (!entity1.canBeCollidedWith()
          || entity1.isEntityEqual(shootingEntity) && ticksInAir < 25) {
        continue;
      }

      float f2 = 0.3F;
      AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
      MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);

      if (movingobjectposition1 == null) {
        continue;
      }

      double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);

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

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

    if (movingobjectposition != null) {
      func_40063_a(movingobjectposition);
    }

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

    for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI);
        rotationPitch - prevRotationPitch < -180F;
        prevRotationPitch -= 360F) {}

    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}

    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}

    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}

    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f1 = 0.95F;

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

      f1 = 0.8F;
    }

    motionX += accelerationX;
    motionY += accelerationY;
    motionZ += accelerationZ;
    motionX *= f1;
    motionY *= f1;
    motionZ *= f1;
    worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
    setPosition(posX, posY, posZ);
  }
Exemplo n.º 14
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.fishPosRotationIncrements > 0) {
      double var21 = this.posX + (this.fishX - this.posX) / (double) this.fishPosRotationIncrements;
      double var22 = this.posY + (this.fishY - this.posY) / (double) this.fishPosRotationIncrements;
      double var23 = this.posZ + (this.fishZ - this.posZ) / (double) this.fishPosRotationIncrements;
      double var7;

      for (var7 = this.fishYaw - (double) this.rotationYaw; var7 < -180.0D; var7 += 360.0D) {;
      }

      while (var7 >= 180.0D) {
        var7 -= 360.0D;
      }

      this.rotationYaw =
          (float) ((double) this.rotationYaw + var7 / (double) this.fishPosRotationIncrements);
      this.rotationPitch =
          (float)
              ((double) this.rotationPitch
                  + (this.fishPitch - (double) this.rotationPitch)
                      / (double) this.fishPosRotationIncrements);
      --this.fishPosRotationIncrements;
      this.setPosition(var21, var22, var23);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else {
      if (!this.worldObj.isRemote) {
        ItemStack var1 = this.angler.getCurrentEquippedItem();

        if (this.angler.isDead
            || !this.angler.isEntityAlive()
            || var1 == null
            || var1.getItem() != Item.fishingRod
            || this.getDistanceSqToEntity(this.angler) > 1024.0D) {
          this.setDead();
          this.angler.fishEntity = null;
          return;
        }

        if (this.bobber != null) {
          if (!this.bobber.isDead) {
            this.posX = this.bobber.posX;
            this.posY = this.bobber.boundingBox.minY + (double) this.bobber.height * 0.8D;
            this.posZ = this.bobber.posZ;
            return;
          }

          this.bobber = null;
        }
      }

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

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

        if (var19 == this.inTile) {
          ++this.ticksInGround;

          if (this.ticksInGround == 1200) {
            this.setDead();
          }

          return;
        }

        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;
      }

      Vec3D var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      Vec3D var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var20, var2);
      var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (var3 != null) {
        var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
      }

      Entity var4 = null;
      List var5 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var6 = 0.0D;
      double var13;

      for (int var8 = 0; var8 < var5.size(); ++var8) {
        Entity var9 = (Entity) var5.get(var8);

        if (var9.canBeCollidedWith() && (var9 != this.angler || this.ticksInAir >= 5)) {
          float var10 = 0.3F;
          AxisAlignedBB var11 =
              var9.boundingBox.expand((double) var10, (double) var10, (double) var10);
          MovingObjectPosition var12 = var11.calculateIntercept(var20, var2);

          if (var12 != null) {
            var13 = var20.distanceTo(var12.hitVec);

            if (var13 < var6 || var6 == 0.0D) {
              var4 = var9;
              var6 = var13;
            }
          }
        }
      }

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

      if (var3 != null) {
        if (var3.entityHit != null) {
          if (var3.entityHit.attackEntityFrom(
              DamageSource.causeThrownDamage(this, this.angler), 0)) {
            this.bobber = var3.entityHit;
          }
        } else {
          this.inGround = true;
        }
      }

      if (!this.inGround) {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        float var24 =
            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) var24) * 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 var25 = 0.92F;

        if (this.onGround || this.isCollidedHorizontally) {
          var25 = 0.5F;
        }

        byte var27 = 5;
        double var26 = 0.0D;

        for (int var29 = 0; var29 < var27; ++var29) {
          double var14 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 0)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          double var16 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 1)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          AxisAlignedBB var18 =
              AxisAlignedBB.getBoundingBoxFromPool(
                  this.boundingBox.minX,
                  var14,
                  this.boundingBox.minZ,
                  this.boundingBox.maxX,
                  var16,
                  this.boundingBox.maxZ);

          if (this.worldObj.isAABBInMaterial(var18, Material.water)) {
            var26 += 1.0D / (double) var27;
          }
        }

        if (var26 > 0.0D) {
          if (this.ticksCatchable > 0) {
            --this.ticksCatchable;
          } else {
            short var28 = 500;

            if (this.worldObj.canLightningStrikeAt(
                MathHelper.floor_double(this.posX),
                MathHelper.floor_double(this.posY) + 1,
                MathHelper.floor_double(this.posZ))) {
              var28 = 300;
            }

            if (this.rand.nextInt(var28) == 0) {
              this.ticksCatchable = this.rand.nextInt(30) + 10;
              this.motionY -= 0.20000000298023224D;
              this.worldObj.playSoundAtEntity(
                  this,
                  "random.splash",
                  0.25F,
                  1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
              float var30 = (float) MathHelper.floor_double(this.boundingBox.minY);
              int var15;
              float var17;
              float var31;

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "bubble",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY - (double) (this.rand.nextFloat() * 0.2F),
                    this.motionZ);
              }

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "splash",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY,
                    this.motionZ);
              }
            }
          }
        }

        if (this.ticksCatchable > 0) {
          this.motionY -=
              (double) (this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat())
                  * 0.2D;
        }

        var13 = var26 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var13;

        if (var26 > 0.0D) {
          var25 = (float) ((double) var25 * 0.9D);
          this.motionY *= 0.8D;
        }

        this.motionX *= (double) var25;
        this.motionY *= (double) var25;
        this.motionZ *= (double) var25;
        this.setPosition(this.posX, this.posY, this.posZ);
      }
    }
  }