Exemple #1
0
  /** Moves a minecart that is not attached to a rail */
  protected void moveDerailedMinecart() {
    double d0 = this.getMaximumSpeed();
    this.motionX = MathHelper.clamp_double(this.motionX, -d0, d0);
    this.motionZ = MathHelper.clamp_double(this.motionZ, -d0, d0);

    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.onGround) {
      this.motionX *= 0.949999988079071D;
      this.motionY *= 0.949999988079071D;
      this.motionZ *= 0.949999988079071D;
    }
  }
Exemple #2
0
  @SuppressWarnings("incomplete-switch")
  protected void func_180460_a(BlockPos p_180460_1_, IBlockState p_180460_2_) {
    this.fallDistance = 0.0F;
    Vec3 vec3 = this.func_70489_a(this.posX, this.posY, this.posZ);
    this.posY = (double) p_180460_1_.getY();
    boolean flag = false;
    boolean flag1 = false;
    BlockRailBase blockrailbase = (BlockRailBase) p_180460_2_.getBlock();

    if (blockrailbase == Blocks.golden_rail) {
      flag = ((Boolean) p_180460_2_.getValue(BlockRailPowered.POWERED)).booleanValue();
      flag1 = !flag;
    }

    double d0 = 0.0078125D;
    BlockRailBase.EnumRailDirection blockrailbase$enumraildirection =
        (BlockRailBase.EnumRailDirection) p_180460_2_.getValue(blockrailbase.getShapeProperty());

    switch (blockrailbase$enumraildirection) {
      case ASCENDING_EAST:
        this.motionX -= 0.0078125D;
        ++this.posY;
        break;

      case ASCENDING_WEST:
        this.motionX += 0.0078125D;
        ++this.posY;
        break;

      case ASCENDING_NORTH:
        this.motionZ += 0.0078125D;
        ++this.posY;
        break;

      case ASCENDING_SOUTH:
        this.motionZ -= 0.0078125D;
        ++this.posY;
    }

    int[][] aint = matrix[blockrailbase$enumraildirection.getMetadata()];
    double d1 = (double) (aint[1][0] - aint[0][0]);
    double d2 = (double) (aint[1][2] - aint[0][2]);
    double d3 = Math.sqrt(d1 * d1 + d2 * d2);
    double d4 = this.motionX * d1 + this.motionZ * d2;

    if (d4 < 0.0D) {
      d1 = -d1;
      d2 = -d2;
    }

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

    if (d5 > 2.0D) {
      d5 = 2.0D;
    }

    this.motionX = d5 * d1 / d3;
    this.motionZ = d5 * d2 / d3;

    if (this.riddenByEntity instanceof EntityLivingBase) {
      double d6 = (double) ((EntityLivingBase) this.riddenByEntity).moveForward;

      if (d6 > 0.0D) {
        double d7 =
            -Math.sin((double) (this.riddenByEntity.rotationYaw * (float) Math.PI / 180.0F));
        double d8 = Math.cos((double) (this.riddenByEntity.rotationYaw * (float) Math.PI / 180.0F));
        double d9 = this.motionX * this.motionX + this.motionZ * this.motionZ;

        if (d9 < 0.01D) {
          this.motionX += d7 * 0.1D;
          this.motionZ += d8 * 0.1D;
          flag1 = false;
        }
      }
    }

    if (flag1) {
      double d17 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

      if (d17 < 0.03D) {
        this.motionX *= 0.0D;
        this.motionY *= 0.0D;
        this.motionZ *= 0.0D;
      } else {
        this.motionX *= 0.5D;
        this.motionY *= 0.0D;
        this.motionZ *= 0.5D;
      }
    }

    double d18 = 0.0D;
    double d19 = (double) p_180460_1_.getX() + 0.5D + (double) aint[0][0] * 0.5D;
    double d20 = (double) p_180460_1_.getZ() + 0.5D + (double) aint[0][2] * 0.5D;
    double d21 = (double) p_180460_1_.getX() + 0.5D + (double) aint[1][0] * 0.5D;
    double d10 = (double) p_180460_1_.getZ() + 0.5D + (double) aint[1][2] * 0.5D;
    d1 = d21 - d19;
    d2 = d10 - d20;

    if (d1 == 0.0D) {
      this.posX = (double) p_180460_1_.getX() + 0.5D;
      d18 = this.posZ - (double) p_180460_1_.getZ();
    } else if (d2 == 0.0D) {
      this.posZ = (double) p_180460_1_.getZ() + 0.5D;
      d18 = this.posX - (double) p_180460_1_.getX();
    } else {
      double d11 = this.posX - d19;
      double d12 = this.posZ - d20;
      d18 = (d11 * d1 + d12 * d2) * 2.0D;
    }

    this.posX = d19 + d1 * d18;
    this.posZ = d20 + d2 * d18;
    this.setPosition(this.posX, this.posY, this.posZ);
    double d22 = this.motionX;
    double d23 = this.motionZ;

    if (this.riddenByEntity != null) {
      d22 *= 0.75D;
      d23 *= 0.75D;
    }

    double d13 = this.getMaximumSpeed();
    d22 = MathHelper.clamp_double(d22, -d13, d13);
    d23 = MathHelper.clamp_double(d23, -d13, d13);
    this.moveEntity(d22, 0.0D, d23);

    if (aint[0][1] != 0
        && MathHelper.floor_double(this.posX) - p_180460_1_.getX() == aint[0][0]
        && MathHelper.floor_double(this.posZ) - p_180460_1_.getZ() == aint[0][2]) {
      this.setPosition(this.posX, this.posY + (double) aint[0][1], this.posZ);
    } else if (aint[1][1] != 0
        && MathHelper.floor_double(this.posX) - p_180460_1_.getX() == aint[1][0]
        && MathHelper.floor_double(this.posZ) - p_180460_1_.getZ() == aint[1][2]) {
      this.setPosition(this.posX, this.posY + (double) aint[1][1], this.posZ);
    }

    this.applyDrag();
    Vec3 vec31 = this.func_70489_a(this.posX, this.posY, this.posZ);

    if (vec31 != null && vec3 != null) {
      double d14 = (vec3.yCoord - vec31.yCoord) * 0.05D;
      d5 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

      if (d5 > 0.0D) {
        this.motionX = this.motionX / d5 * (d5 + d14);
        this.motionZ = this.motionZ / d5 * (d5 + d14);
      }

      this.setPosition(this.posX, vec31.yCoord, this.posZ);
    }

    int j = MathHelper.floor_double(this.posX);
    int i = MathHelper.floor_double(this.posZ);

    if (j != p_180460_1_.getX() || i != p_180460_1_.getZ()) {
      d5 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.motionX = d5 * (double) (j - p_180460_1_.getX());
      this.motionZ = d5 * (double) (i - p_180460_1_.getZ());
    }

    if (flag) {
      double d15 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

      if (d15 > 0.01D) {
        double d16 = 0.06D;
        this.motionX += this.motionX / d15 * d16;
        this.motionZ += this.motionZ / d15 * d16;
      } else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST) {
        if (this.worldObj.getBlockState(p_180460_1_.west()).getBlock().isNormalCube()) {
          this.motionX = 0.02D;
        } else if (this.worldObj.getBlockState(p_180460_1_.east()).getBlock().isNormalCube()) {
          this.motionX = -0.02D;
        }
      } else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH) {
        if (this.worldObj.getBlockState(p_180460_1_.north()).getBlock().isNormalCube()) {
          this.motionZ = 0.02D;
        } else if (this.worldObj.getBlockState(p_180460_1_.south()).getBlock().isNormalCube()) {
          this.motionZ = -0.02D;
        }
      }
    }
  }
  @SideOnly(Side.CLIENT)
  private void spawnParticles(World world, int x, int y, int z) {
    double px = x + particleX;
    double py = y + particleY;
    double pz = z;

    int color = CrystalElement.getBlendedColor(this.getTicksExisted(), 40);

    EntityBlurFX fx =
        new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    px = x + 1 - particleX;
    py = y + 1 - particleY;
    fx = new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    pz = z + 1;
    px = x + 1 - particleX;
    py = y + particleY;
    fx = new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    px = x + particleX;
    py = y + 1 - particleY;
    fx = new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    px = x;
    pz = z + particleX;
    py = y + particleY;
    fx = new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    pz = z + 1 - particleX;
    py = y + 1 - particleY;
    fx = new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    px = x + 1;
    pz = z + 1 - particleX;
    py = y + particleY;
    fx = new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    pz = z + particleX;
    py = y + 1 - particleY;
    fx = new EntityBlurFX(world, px, py, pz).setScale(0.5F).setLife(40).setColor(color);
    Minecraft.getMinecraft().effectRenderer.addEffect(fx);

    double d = 0.05;
    particleX += particleVX;
    particleY += particleVY;
    particleX = MathHelper.clamp_double(particleX, 0, 1);
    particleY = MathHelper.clamp_double(particleY, 0, 1);

    if (particleX == 1 && particleY == 0) {
      particleVX = 0;
      particleVY = d;
    }
    if (particleY == 1 && particleY == 1) {
      particleVX = -d;
      particleVY = 0;
    }
    if (particleX == 0 && particleY == 1) {
      particleVX = 0;
      particleVY = -d;
    }
    if (particleX == 0 && particleY == 0) {
      particleVX = d;
      particleVY = 0;
    }
  }
  /** Transfers an entity from a world to another world. */
  public void transferEntityToWorld(
      Entity entityIn, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_) {
    double var5 = entityIn.posX;
    double var7 = entityIn.posZ;
    double var9 = 8.0D;
    float var11 = entityIn.rotationYaw;
    p_82448_3_.theProfiler.startSection("moving");

    if (entityIn.dimension == -1) {
      var5 =
          MathHelper.clamp_double(
              var5 / var9,
              p_82448_4_.getWorldBorder().minX() + 16.0D,
              p_82448_4_.getWorldBorder().maxX() - 16.0D);
      var7 =
          MathHelper.clamp_double(
              var7 / var9,
              p_82448_4_.getWorldBorder().minZ() + 16.0D,
              p_82448_4_.getWorldBorder().maxZ() - 16.0D);
      entityIn.setLocationAndAngles(
          var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    } else if (entityIn.dimension == 0) {
      var5 =
          MathHelper.clamp_double(
              var5 * var9,
              p_82448_4_.getWorldBorder().minX() + 16.0D,
              p_82448_4_.getWorldBorder().maxX() - 16.0D);
      var7 =
          MathHelper.clamp_double(
              var7 * var9,
              p_82448_4_.getWorldBorder().minZ() + 16.0D,
              p_82448_4_.getWorldBorder().maxZ() - 16.0D);
      entityIn.setLocationAndAngles(
          var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    } else {
      BlockPos var12;

      if (p_82448_2_ == 1) {
        var12 = p_82448_4_.getSpawnPoint();
      } else {
        var12 = p_82448_4_.func_180504_m();
      }

      var5 = (double) var12.getX();
      entityIn.posY = (double) var12.getY();
      var7 = (double) var12.getZ();
      entityIn.setLocationAndAngles(var5, entityIn.posY, var7, 90.0F, 0.0F);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    }

    p_82448_3_.theProfiler.endSection();

    if (p_82448_2_ != 1) {
      p_82448_3_.theProfiler.startSection("placing");
      var5 = (double) MathHelper.clamp_int((int) var5, -29999872, 29999872);
      var7 = (double) MathHelper.clamp_int((int) var7, -29999872, 29999872);

      if (entityIn.isEntityAlive()) {
        entityIn.setLocationAndAngles(
            var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);
        p_82448_4_.getDefaultTeleporter().func_180266_a(entityIn, var11);
        p_82448_4_.spawnEntityInWorld(entityIn);
        p_82448_4_.updateEntityWithOptionalForce(entityIn, false);
      }

      p_82448_3_.theProfiler.endSection();
    }

    entityIn.setWorld(p_82448_4_);
  }
 @ModDependent(ModList.MINECHEM)
 public double getDecomposerMultiplier(ItemStack is) {
   return MathHelper.clamp_double(1 - this.getBrokenFraction(is), 0, 1);
 }
 public double clampValue(double p_111109_1_) {
   p_111109_1_ = MathHelper.clamp_double(p_111109_1_, this.minimumValue, this.maximumValue);
   return p_111109_1_;
 }
 /**
  * Returns the amount of cook time completed on the currently cooking item.
  *
  * @return fraction remaining, between 0 - 1
  */
 public double fractionOfCookTimeComplete() {
   double fraction = cookTime / (double) COOK_TIME_FOR_COMPLETION;
   return MathHelper.clamp_double(fraction, 0.0, 1.0);
 }
 /**
  * Returns the amount of fuel remaining on the currently burning item in the given fuel slot.
  *
  * @fuelSlot the number of the fuel slot (0..3)
  * @return fraction remaining, between 0 - 1
  */
 public double fractionOfFuelRemaining(int fuelSlot) {
   if (burnTimeInitialValue[fuelSlot] <= 0) return 0;
   double fraction = burnTimeRemaining[fuelSlot] / (double) burnTimeInitialValue[fuelSlot];
   return MathHelper.clamp_double(fraction, 0.0, 1.0);
 }