Beispiel #1
0
  /** Gets called every tick from main Entity class */
  public void onEntityUpdate() {
    Profiler.startSection("entityBaseTick");

    if (ridingEntity != null && ridingEntity.isDead) {
      ridingEntity = null;
    }

    ticksExisted++;
    prevDistanceWalkedModified = distanceWalkedModified;
    prevPosX = posX;
    prevPosY = posY;
    prevPosZ = posZ;
    prevRotationPitch = rotationPitch;
    prevRotationYaw = rotationYaw;

    if (isSprinting() && !isInWater()) {
      int i = MathHelper.floor_double(posX);
      int j = MathHelper.floor_double(posY - 0.2D - (double) yOffset);
      int k = MathHelper.floor_double(posZ);
      int j1 = worldObj.getBlockId(i, j, k);

      if (j1 > 0) {
        worldObj.spawnParticle(
            (new StringBuilder()).append("tilecrack_").append(j1).toString(),
            posX + ((double) rand.nextFloat() - 0.5D) * (double) width,
            boundingBox.minY + 0.1D,
            posZ + ((double) rand.nextFloat() - 0.5D) * (double) width,
            -motionX * 4D,
            1.5D,
            -motionZ * 4D);
      }
    }

    if (handleWaterMovement()) {
      if (!inWater && !firstUpdate) {
        float f =
            MathHelper.sqrt_double(
                    motionX * motionX * 0.2D + motionY * motionY + motionZ * motionZ * 0.2D)
                * 0.2F;

        if (f > 1.0F) {
          f = 1.0F;
        }

        worldObj.playSoundAtEntity(
            this, "random.splash", f, 1.0F + (rand.nextFloat() - rand.nextFloat()) * 0.4F);
        float f1 = MathHelper.floor_double(boundingBox.minY);

        for (int l = 0; (float) l < 1.0F + width * 20F; l++) {
          float f2 = (rand.nextFloat() * 2.0F - 1.0F) * width;
          float f4 = (rand.nextFloat() * 2.0F - 1.0F) * width;
          worldObj.spawnParticle(
              "bubble",
              posX + (double) f2,
              f1 + 1.0F,
              posZ + (double) f4,
              motionX,
              motionY - (double) (rand.nextFloat() * 0.2F),
              motionZ);
        }

        for (int i1 = 0; (float) i1 < 1.0F + width * 20F; i1++) {
          float f3 = (rand.nextFloat() * 2.0F - 1.0F) * width;
          float f5 = (rand.nextFloat() * 2.0F - 1.0F) * width;
          worldObj.spawnParticle(
              "splash",
              posX + (double) f3,
              f1 + 1.0F,
              posZ + (double) f5,
              motionX,
              motionY,
              motionZ);
        }
      }

      fallDistance = 0.0F;
      inWater = true;
      fire = 0;
    } else {
      inWater = false;
    }

    if (worldObj.isRemote) {
      fire = 0;
    } else if (fire > 0) {
      if (isImmuneToFire) {
        fire -= 4;

        if (fire < 0) {
          fire = 0;
        }
      } else {
        if (fire % 20 == 0) {
          attackEntityFrom(DamageSource.onFire, 1);
        }

        fire--;
      }
    }

    if (handleLavaMovement()) {
      setOnFireFromLava();
      fallDistance *= 0.5F;
    }

    if (posY < -64D) {
      kill();
    }

    if (!worldObj.isRemote) {
      setFlag(0, fire > 0);
      setFlag(2, ridingEntity != null);
    }

    firstUpdate = false;
    Profiler.endSection();
  }
Beispiel #2
0
 public void setEating(boolean par1) {
   setFlag(4, par1);
 }
Beispiel #3
0
 public void func_48078_c(boolean par1) {
   setFlag(1, par1);
 }
Beispiel #4
0
 /** Sets the player's sprinting state. */
 public void setSprinting(boolean par1) {
   setFlag(3, par1);
 }
Beispiel #5
0
 /** Sets the sneaking flag. */
 public void setSneaking(boolean par1) {
   setFlag(1, par1);
 }