Ejemplo n.º 1
0
  public void b(World var1, BlockPosition var2, IBlockData var3, Random var4) {
    super.b(var1, var2, var3, var4);
    if (var1.worldProvider.d()
        && var1.getGameRules().getBoolean("doMobSpawning")
        && var4.nextInt(2000) < var1.getDifficulty().a()) {
      int var5 = var2.getY();

      BlockPosition var6;
      for (var6 = var2;
          !World.a((IBlockAccess) var1, (BlockPosition) var6) && var6.getY() > 0;
          var6 = var6.down()) {;
      }

      if (var5 > 0 && !var1.getType(var6.up()).getBlock().isOccluding()) {
        Entity var7 =
            ItemMonsterEgg.a(
                var1,
                57,
                (double) var6.getX() + 0.5D,
                (double) var6.getY() + 1.1D,
                (double) var6.getZ() + 0.5D);
        if (var7 != null) {
          var7.portalCooldown = var7.aq();
        }
      }
    }
  }
  protected void a(BlockPosition var1, IBlockData var2) {
    this.fallDistance = 0.0F;
    Vec3D var3 = this.k(this.locX, this.locY, this.locZ);
    this.locY = (double) var1.getY();
    boolean var4 = false;
    boolean var5 = false;
    BlockMinecartTrackAbstract var6 = (BlockMinecartTrackAbstract) var2.getBlock();
    if (var6 == Blocks.GOLDEN_RAIL) {
      var4 = ((Boolean) var2.get(BlockPoweredRail.POWERED)).booleanValue();
      var5 = !var4;
    }

    double var7 = 0.0078125D;
    BlockMinecartTrackAbstract.EnumTrackPosition var9 =
        (BlockMinecartTrackAbstract.EnumTrackPosition) var2.get(var6.n());
    switch (EntityMinecartAbstract.SyntheticClass_1.b[var9.ordinal()]) {
      case 1:
        this.motX -= 0.0078125D;
        ++this.locY;
        break;
      case 2:
        this.motX += 0.0078125D;
        ++this.locY;
        break;
      case 3:
        this.motZ += 0.0078125D;
        ++this.locY;
        break;
      case 4:
        this.motZ -= 0.0078125D;
        ++this.locY;
    }

    int[][] var10 = matrix[var9.a()];
    double var11 = (double) (var10[1][0] - var10[0][0]);
    double var13 = (double) (var10[1][2] - var10[0][2]);
    double var15 = Math.sqrt(var11 * var11 + var13 * var13);
    double var17 = this.motX * var11 + this.motZ * var13;
    if (var17 < 0.0D) {
      var11 = -var11;
      var13 = -var13;
    }

    double var19 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
    if (var19 > 2.0D) {
      var19 = 2.0D;
    }

    this.motX = var19 * var11 / var15;
    this.motZ = var19 * var13 / var15;
    double var21;
    double var23;
    double var25;
    double var27;
    if (this.passenger instanceof EntityLiving) {
      var21 = (double) ((EntityLiving) this.passenger).ba;
      if (var21 > 0.0D) {
        var23 = -Math.sin((double) (this.passenger.yaw * 3.1415927F / 180.0F));
        var25 = Math.cos((double) (this.passenger.yaw * 3.1415927F / 180.0F));
        var27 = this.motX * this.motX + this.motZ * this.motZ;
        if (var27 < 0.01D) {
          this.motX += var23 * 0.1D;
          this.motZ += var25 * 0.1D;
          var5 = false;
        }
      }
    }

    if (var5) {
      var21 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      if (var21 < 0.03D) {
        this.motX *= 0.0D;
        this.motY *= 0.0D;
        this.motZ *= 0.0D;
      } else {
        this.motX *= 0.5D;
        this.motY *= 0.0D;
        this.motZ *= 0.5D;
      }
    }

    var21 = 0.0D;
    var23 = (double) var1.getX() + 0.5D + (double) var10[0][0] * 0.5D;
    var25 = (double) var1.getZ() + 0.5D + (double) var10[0][2] * 0.5D;
    var27 = (double) var1.getX() + 0.5D + (double) var10[1][0] * 0.5D;
    double var29 = (double) var1.getZ() + 0.5D + (double) var10[1][2] * 0.5D;
    var11 = var27 - var23;
    var13 = var29 - var25;
    double var31;
    double var33;
    if (var11 == 0.0D) {
      this.locX = (double) var1.getX() + 0.5D;
      var21 = this.locZ - (double) var1.getZ();
    } else if (var13 == 0.0D) {
      this.locZ = (double) var1.getZ() + 0.5D;
      var21 = this.locX - (double) var1.getX();
    } else {
      var31 = this.locX - var23;
      var33 = this.locZ - var25;
      var21 = (var31 * var11 + var33 * var13) * 2.0D;
    }

    this.locX = var23 + var11 * var21;
    this.locZ = var25 + var13 * var21;
    this.setPosition(this.locX, this.locY, this.locZ);
    var31 = this.motX;
    var33 = this.motZ;
    if (this.passenger != null) {
      var31 *= 0.75D;
      var33 *= 0.75D;
    }

    double var35 = this.m();
    var31 = MathHelper.a(var31, -var35, var35);
    var33 = MathHelper.a(var33, -var35, var35);
    this.move(var31, 0.0D, var33);
    if (var10[0][1] != 0
        && MathHelper.floor(this.locX) - var1.getX() == var10[0][0]
        && MathHelper.floor(this.locZ) - var1.getZ() == var10[0][2]) {
      this.setPosition(this.locX, this.locY + (double) var10[0][1], this.locZ);
    } else if (var10[1][1] != 0
        && MathHelper.floor(this.locX) - var1.getX() == var10[1][0]
        && MathHelper.floor(this.locZ) - var1.getZ() == var10[1][2]) {
      this.setPosition(this.locX, this.locY + (double) var10[1][1], this.locZ);
    }

    this.o();
    Vec3D var37 = this.k(this.locX, this.locY, this.locZ);
    if (var37 != null && var3 != null) {
      double var38 = (var3.b - var37.b) * 0.05D;
      var19 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      if (var19 > 0.0D) {
        this.motX = this.motX / var19 * (var19 + var38);
        this.motZ = this.motZ / var19 * (var19 + var38);
      }

      this.setPosition(this.locX, var37.b, this.locZ);
    }

    int var44 = MathHelper.floor(this.locX);
    int var39 = MathHelper.floor(this.locZ);
    if (var44 != var1.getX() || var39 != var1.getZ()) {
      var19 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      this.motX = var19 * (double) (var44 - var1.getX());
      this.motZ = var19 * (double) (var39 - var1.getZ());
    }

    if (var4) {
      double var40 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      if (var40 > 0.01D) {
        double var42 = 0.06D;
        this.motX += this.motX / var40 * var42;
        this.motZ += this.motZ / var40 * var42;
      } else if (var9 == BlockMinecartTrackAbstract.EnumTrackPosition.EAST_WEST) {
        if (this.world.getType(var1.west()).getBlock().isOccluding()) {
          this.motX = 0.02D;
        } else if (this.world.getType(var1.east()).getBlock().isOccluding()) {
          this.motX = -0.02D;
        }
      } else if (var9 == BlockMinecartTrackAbstract.EnumTrackPosition.NORTH_SOUTH) {
        if (this.world.getType(var1.north()).getBlock().isOccluding()) {
          this.motZ = 0.02D;
        } else if (this.world.getType(var1.south()).getBlock().isOccluding()) {
          this.motZ = -0.02D;
        }
      }
    }
  }
Ejemplo n.º 3
0
  private void f(World var1, BlockPosition var2) {
    ShapeDetector.ShapeDetectorCollection var3;
    int var4;
    int var6;
    if ((var3 = this.getDetectorSnowGolem().a(var1, var2)) != null) {
      for (var4 = 0; var4 < this.getDetectorSnowGolem().b(); ++var4) {
        ShapeDetectorBlock var5 = var3.a(0, var4, 0);
        var1.setTypeAndData(var5.d(), Blocks.AIR.getBlockData(), 2);
      }

      EntitySnowman var9 = new EntitySnowman(var1);
      BlockPosition var10 = var3.a(0, 2, 0).d();
      var9.setPositionRotation(
          (double) var10.getX() + 0.5D,
          (double) var10.getY() + 0.05D,
          (double) var10.getZ() + 0.5D,
          0.0F,
          0.0F);
      var1.addEntity(var9);

      for (var6 = 0; var6 < 120; ++var6) {
        var1.addParticle(
            EnumParticle.SNOW_SHOVEL,
            (double) var10.getX() + var1.random.nextDouble(),
            (double) var10.getY() + var1.random.nextDouble() * 2.5D,
            (double) var10.getZ() + var1.random.nextDouble(),
            0.0D,
            0.0D,
            0.0D,
            new int[0]);
      }

      for (var6 = 0; var6 < this.getDetectorSnowGolem().b(); ++var6) {
        ShapeDetectorBlock var7 = var3.a(0, var6, 0);
        var1.update(var7.d(), Blocks.AIR);
      }
    } else if ((var3 = this.getDetectorIronGolem().a(var1, var2)) != null) {
      for (var4 = 0; var4 < this.getDetectorIronGolem().c(); ++var4) {
        for (int var12 = 0; var12 < this.getDetectorIronGolem().b(); ++var12) {
          var1.setTypeAndData(var3.a(var4, var12, 0).d(), Blocks.AIR.getBlockData(), 2);
        }
      }

      BlockPosition var11 = var3.a(1, 2, 0).d();
      EntityIronGolem var13 = new EntityIronGolem(var1);
      var13.setPlayerCreated(true);
      var13.setPositionRotation(
          (double) var11.getX() + 0.5D,
          (double) var11.getY() + 0.05D,
          (double) var11.getZ() + 0.5D,
          0.0F,
          0.0F);
      var1.addEntity(var13);

      for (var6 = 0; var6 < 120; ++var6) {
        var1.addParticle(
            EnumParticle.SNOWBALL,
            (double) var11.getX() + var1.random.nextDouble(),
            (double) var11.getY() + var1.random.nextDouble() * 3.9D,
            (double) var11.getZ() + var1.random.nextDouble(),
            0.0D,
            0.0D,
            0.0D,
            new int[0]);
      }

      for (var6 = 0; var6 < this.getDetectorIronGolem().c(); ++var6) {
        for (int var14 = 0; var14 < this.getDetectorIronGolem().b(); ++var14) {
          ShapeDetectorBlock var8 = var3.a(var6, var14, 0);
          var1.update(var8.d(), Blocks.AIR);
        }
      }
    }
  }