Пример #1
0
 /** A randomly called display update to be able to add particles or other items for display */
 public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
   if (par1World.canLightningStrikeAt(par2, par3 + 1, par4)
       && !par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
       && par5Random.nextInt(15) == 1) {
     double var6 = (double) ((float) par2 + par5Random.nextFloat());
     double var8 = (double) par3 - 0.05D;
     double var10 = (double) ((float) par4 + par5Random.nextFloat());
     par1World.spawnParticle("dripWater", var6, var8, var10, 0.0D, 0.0D, 0.0D);
   }
 }
Пример #2
0
 /** Gets if we can place a torch on a block. */
 private boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4) {
   if (par1World.doesBlockHaveSolidTopSurface(par2, par3, par4)) {
     return true;
   } else {
     int var5 = par1World.getBlockId(par2, par3, par4);
     return var5 == Block.fence.blockID
         || var5 == Block.netherFence.blockID
         || var5 == Block.glass.blockID
         || var5 == Block.cobblestoneWall.blockID;
   }
 }
Пример #3
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    if (par1World.provider.dimensionId <= 0
        && par1World.getBlockId(par2, par3 - 1, par4) == Block.obsidian.blockID
        && Block.portal.tryToCreatePortal(par1World, par2, par3, par4)) {
      return;
    }

    if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
        && !canNeighborBurn(par1World, par2, par3, par4)) {
      par1World.setBlockToAir(par2, par3, par4);
      return;
    } else {
      par1World.scheduleBlockUpdate(
          par2, par3, par4, blockID, tickRate(par1World) + par1World.rand.nextInt(10));
      return;
    }
  }
Пример #4
0
  /** Returns whether or not the specified creature type can spawn at the specified location. */
  public static boolean canCreatureTypeSpawnAtLocation(
      EnumCreatureType par0EnumCreatureType, World par1World, int par2, int par3, int par4) {
    if (par0EnumCreatureType.getCreatureMaterial() == Material.water) {
      return par1World.getBlockMaterial(par2, par3, par4).isLiquid()
          && par1World.getBlockMaterial(par2, par3 - 1, par4).isLiquid()
          && !par1World.isBlockNormalCube(par2, par3 + 1, par4);
    }

    if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)) {
      return false;
    } else {
      int i = par1World.getBlockId(par2, par3 - 1, par4);
      return i != Block.bedrock.blockID
          && !par1World.isBlockNormalCube(par2, par3, par4)
          && !par1World.getBlockMaterial(par2, par3, par4).isLiquid()
          && !par1World.isBlockNormalCube(par2, par3 + 1, par4);
    }
  }
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    super.updateTick(par1World, par2, par3, par4, par5Random);

    if (par1World.provider.isSurfaceWorld()
        && par5Random.nextInt(2000) < par1World.difficultySetting) {
      int var6;

      for (var6 = par3;
          !par1World.doesBlockHaveSolidTopSurface(par2, var6, par4) && var6 > 0;
          --var6) {;
      }

      if (var6 > 0 && !par1World.isBlockNormalCube(par2, var6 + 1, par4)) {
        Entity var7 =
            ItemMonsterPlacer.spawnCreature(
                par1World, 57, (double) par2 + 0.5D, (double) var6 + 1.1D, (double) par4 + 0.5D);

        if (var7 != null) {
          var7.timeUntilPortal = var7.getPortalCooldown();
        }
      }
    }
  }
Пример #6
0
  /** A randomly called display update to be able to add particles or other items for display */
  public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    int var6;

    if (this.blockMaterial == Material.water) {
      if (par5Random.nextInt(10) == 0) {
        var6 = par1World.getBlockMetadata(par2, par3, par4);

        if (var6 <= 0 || var6 >= 8) {
          par1World.spawnParticle(
              "suspended",
              (double) ((float) par2 + par5Random.nextFloat()),
              (double) ((float) par3 + par5Random.nextFloat()),
              (double) ((float) par4 + par5Random.nextFloat()),
              0.0D,
              0.0D,
              0.0D);
        }
      }

      for (var6 = 0; var6 < 0; ++var6) {
        int var7 = par5Random.nextInt(4);
        int var8 = par2;
        int var9 = par4;

        if (var7 == 0) {
          var8 = par2 - 1;
        }

        if (var7 == 1) {
          ++var8;
        }

        if (var7 == 2) {
          var9 = par4 - 1;
        }

        if (var7 == 3) {
          ++var9;
        }

        if (par1World.getBlockMaterial(var8, par3, var9) == Material.air
            && (par1World.getBlockMaterial(var8, par3 - 1, var9).blocksMovement()
                || par1World.getBlockMaterial(var8, par3 - 1, var9).isLiquid())) {
          float var10 = 0.0625F;
          double var11 = (double) ((float) par2 + par5Random.nextFloat());
          double var13 = (double) ((float) par3 + par5Random.nextFloat());
          double var15 = (double) ((float) par4 + par5Random.nextFloat());

          if (var7 == 0) {
            var11 = (double) ((float) par2 - var10);
          }

          if (var7 == 1) {
            var11 = (double) ((float) (par2 + 1) + var10);
          }

          if (var7 == 2) {
            var15 = (double) ((float) par4 - var10);
          }

          if (var7 == 3) {
            var15 = (double) ((float) (par4 + 1) + var10);
          }

          double var17 = 0.0D;
          double var19 = 0.0D;

          if (var7 == 0) {
            var17 = (double) (-var10);
          }

          if (var7 == 1) {
            var17 = (double) var10;
          }

          if (var7 == 2) {
            var19 = (double) (-var10);
          }

          if (var7 == 3) {
            var19 = (double) var10;
          }

          par1World.spawnParticle("splash", var11, var13, var15, var17, 0.0D, var19);
        }
      }
    }

    if (this.blockMaterial == Material.water && par5Random.nextInt(64) == 0) {
      var6 = par1World.getBlockMetadata(par2, par3, par4);

      if (var6 > 0 && var6 < 8) {
        par1World.playSound(
            (double) ((float) par2 + 0.5F),
            (double) ((float) par3 + 0.5F),
            (double) ((float) par4 + 0.5F),
            "liquid.water",
            par5Random.nextFloat() * 0.25F + 0.75F,
            par5Random.nextFloat() * 1.0F + 0.5F);
      }
    }

    double var21;
    double var23;
    double var22;

    if (this.blockMaterial == Material.lava
        && par1World.getBlockMaterial(par2, par3 + 1, par4) == Material.air
        && !par1World.isBlockOpaqueCube(par2, par3 + 1, par4)) {
      if (par5Random.nextInt(100) == 0) {
        var21 = (double) ((float) par2 + par5Random.nextFloat());
        var22 = (double) par3 + this.maxY;
        var23 = (double) ((float) par4 + par5Random.nextFloat());
        par1World.spawnParticle("lava", var21, var22, var23, 0.0D, 0.0D, 0.0D);
        par1World.playSound(
            var21,
            var22,
            var23,
            "liquid.lavapop",
            0.2F + par5Random.nextFloat() * 0.2F,
            0.9F + par5Random.nextFloat() * 0.15F);
      }

      if (par5Random.nextInt(200) == 0) {
        par1World.playSound(
            (double) par2,
            (double) par3,
            (double) par4,
            "liquid.lava",
            0.2F + par5Random.nextFloat() * 0.2F,
            0.9F + par5Random.nextFloat() * 0.15F);
      }
    }

    if (par5Random.nextInt(10) == 0
        && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
        && !par1World.getBlockMaterial(par2, par3 - 2, par4).blocksMovement()) {
      var21 = (double) ((float) par2 + par5Random.nextFloat());
      var22 = (double) par3 - 1.05D;
      var23 = (double) ((float) par4 + par5Random.nextFloat());

      if (this.blockMaterial == Material.water) {
        par1World.spawnParticle("dripWater", var21, var22, var23, 0.0D, 0.0D, 0.0D);
      } else {
        par1World.spawnParticle("dripLava", var21, var22, var23, 0.0D, 0.0D, 0.0D);
      }
    }
  }
Пример #7
0
 /**
  * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with
  * plants.
  */
 public boolean canBlockStay(World par1World, int par2, int par3, int par4) {
   return !par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
       ? false
       : super.canBlockStay(par1World, par2, par3, par4);
 }
Пример #8
0
  /** A randomly called display update to be able to add particles or other items for display */
  public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (par5Random.nextInt(24) == 0) {
      par1World.playSound(
          (float) par2 + 0.5F,
          (float) par3 + 0.5F,
          (float) par4 + 0.5F,
          "fire.fire",
          1.0F + par5Random.nextFloat(),
          par5Random.nextFloat() * 0.7F + 0.3F,
          false);
    }

    if (par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
        || Block.fire.canBlockCatchFire(par1World, par2, par3 - 1, par4)) {
      for (int i = 0; i < 3; i++) {
        float f = (float) par2 + par5Random.nextFloat();
        float f6 = (float) par3 + par5Random.nextFloat() * 0.5F + 0.5F;
        float f12 = (float) par4 + par5Random.nextFloat();
        par1World.spawnParticle("largesmoke", f, f6, f12, 0.0D, 0.0D, 0.0D);
      }
    } else {
      if (Block.fire.canBlockCatchFire(par1World, par2 - 1, par3, par4)) {
        for (int j = 0; j < 2; j++) {
          float f1 = (float) par2 + par5Random.nextFloat() * 0.1F;
          float f7 = (float) par3 + par5Random.nextFloat();
          float f13 = (float) par4 + par5Random.nextFloat();
          par1World.spawnParticle("largesmoke", f1, f7, f13, 0.0D, 0.0D, 0.0D);
        }
      }

      if (Block.fire.canBlockCatchFire(par1World, par2 + 1, par3, par4)) {
        for (int k = 0; k < 2; k++) {
          float f2 = (float) (par2 + 1) - par5Random.nextFloat() * 0.1F;
          float f8 = (float) par3 + par5Random.nextFloat();
          float f14 = (float) par4 + par5Random.nextFloat();
          par1World.spawnParticle("largesmoke", f2, f8, f14, 0.0D, 0.0D, 0.0D);
        }
      }

      if (Block.fire.canBlockCatchFire(par1World, par2, par3, par4 - 1)) {
        for (int l = 0; l < 2; l++) {
          float f3 = (float) par2 + par5Random.nextFloat();
          float f9 = (float) par3 + par5Random.nextFloat();
          float f15 = (float) par4 + par5Random.nextFloat() * 0.1F;
          par1World.spawnParticle("largesmoke", f3, f9, f15, 0.0D, 0.0D, 0.0D);
        }
      }

      if (Block.fire.canBlockCatchFire(par1World, par2, par3, par4 + 1)) {
        for (int i1 = 0; i1 < 2; i1++) {
          float f4 = (float) par2 + par5Random.nextFloat();
          float f10 = (float) par3 + par5Random.nextFloat();
          float f16 = (float) (par4 + 1) - par5Random.nextFloat() * 0.1F;
          par1World.spawnParticle("largesmoke", f4, f10, f16, 0.0D, 0.0D, 0.0D);
        }
      }

      if (Block.fire.canBlockCatchFire(par1World, par2, par3 + 1, par4)) {
        for (int j1 = 0; j1 < 2; j1++) {
          float f5 = (float) par2 + par5Random.nextFloat();
          float f11 = (float) (par3 + 1) - par5Random.nextFloat() * 0.1F;
          float f17 = (float) par4 + par5Random.nextFloat();
          par1World.spawnParticle("largesmoke", f5, f11, f17, 0.0D, 0.0D, 0.0D);
        }
      }
    }
  }
Пример #9
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor blockID
  */
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
       && !canNeighborBurn(par1World, par2, par3, par4)) {
     par1World.setBlockToAir(par2, par3, par4);
   }
 }
Пример #10
0
 /**
  * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  */
 public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
   return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
       || canNeighborBurn(par1World, par2, par3, par4);
 }
Пример #11
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (!par1World.getGameRules().getGameRuleBooleanValue("doFireTick")) {
      return;
    }
    if (oldFire) {
      updateTickOld(par1World, par2, par3, par4, par5Random);
      return;
    }

    boolean flag = par1World.getBlockId(par2, par3 - 1, par4) == Block.netherrack.blockID;

    if ((par1World.provider instanceof WorldProviderEnd)
        && par1World.getBlockId(par2, par3 - 1, par4) == Block.bedrock.blockID) {
      flag = true;
    }

    if (!canPlaceBlockAt(par1World, par2, par3, par4)) {
      par1World.setBlockToAir(par2, par3, par4);
    }

    if (!flag
        && par1World.isRaining()
        && (par1World.canLightningStrikeAt(par2, par3, par4)
            || par1World.canLightningStrikeAt(par2 - 1, par3, par4)
            || par1World.canLightningStrikeAt(par2 + 1, par3, par4)
            || par1World.canLightningStrikeAt(par2, par3, par4 - 1)
            || par1World.canLightningStrikeAt(par2, par3, par4 + 1))) {
      par1World.setBlockToAir(par2, par3, par4);
      return;
    }

    int i = par1World.getBlockMetadata(par2, par3, par4);

    if (i < 15) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, i + par5Random.nextInt(3) / 2, 4);
    }

    par1World.scheduleBlockUpdate(
        par2, par3, par4, blockID, tickRate(par1World) + par5Random.nextInt(10));

    if (!flag && !canNeighborBurn(par1World, par2, par3, par4)) {
      if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || i > 3) {
        par1World.setBlockToAir(par2, par3, par4);
      }

      return;
    }

    if (!flag
        && !canBlockCatchFire(par1World, par2, par3 - 1, par4)
        && i == 15
        && par5Random.nextInt(4) == 0) {
      par1World.setBlockToAir(par2, par3, par4);
      return;
    }

    boolean flag1 = par1World.isBlockHighHumidity(par2, par3, par4);
    byte byte0 = 0;

    if (flag1) {
      byte0 = -50;
    }

    tryToCatchBlockOnFire(par1World, par2 + 1, par3, par4, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2 - 1, par3, par4, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3 - 1, par4, 250 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3 + 1, par4, 250 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3, par4 - 1, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3, par4 + 1, 300 + byte0, par5Random, i);

    for (int j = par2 - 1; j <= par2 + 1; j++) {
      for (int k = par4 - 1; k <= par4 + 1; k++) {
        for (int l = par3 - 1; l <= par3 + 4; l++) {
          if (j == par2 && l == par3 && k == par4) {
            continue;
          }

          int i1 = 100;

          if (l > par3 + 1) {
            i1 += (l - (par3 + 1)) * 100;
          }

          int j1 = getChanceOfNeighborsEncouragingFire(par1World, j, l, k);

          if (j1 <= 0) {
            continue;
          }

          int k1 = (j1 + 40 + (fixedDamage ? 0 : par1World.difficultySetting * 7)) / (i + 30);

          if (flag1) {
            k1 /= 2;
          }

          if (k1 <= 0
              || par5Random.nextInt(i1) > k1
              || par1World.isRaining() && par1World.canLightningStrikeAt(j, l, k)
              || par1World.canLightningStrikeAt(j - 1, l, par4)
              || par1World.canLightningStrikeAt(j + 1, l, k)
              || par1World.canLightningStrikeAt(j, l, k - 1)
              || par1World.canLightningStrikeAt(j, l, k + 1)) {
            continue;
          }

          int l1 = i + par5Random.nextInt(5) / 4;

          if (l1 > 15) {
            l1 = 15;
          }

          par1World.setBlock(j, l, k, blockID, l1, 3);
        }
      }
    }
  }
Пример #12
0
 /**
  * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  */
 public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
   return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
       || par1World.getBlockId(par2, par3 - 1, par4) == Block.glowStone.blockID;
 }