Esempio n. 1
0
  /** Set the metadata of a block in the chunk */
  public boolean setBlockMetadata(int par1, int par2, int par3, int par4) {
    ExtendedBlockStorage var5 = this.storageArrays[par2 >> 4];

    if (var5 == null) {
      return false;
    } else {
      int var6 = var5.getExtBlockMetadata(par1, par2 & 15, par3);

      if (var6 == par4) {
        return false;
      } else {
        this.isModified = true;
        var5.setExtBlockMetadata(par1, par2 & 15, par3, par4);
        int var7 = var5.getExtBlockID(par1, par2 & 15, par3);

        if (var7 > 0 && Block.blocksList[var7] instanceof ITileEntityProvider) {
          TileEntity var8 = this.getChunkBlockTileEntity(par1, par2, par3);

          if (var8 != null) {
            var8.updateContainingBlockInfo();
            var8.blockMetadata = par4;
          }
        }

        return true;
      }
    }
  }
Esempio n. 2
0
 /** Return the ID of a block in the chunk. */
 public int getBlockID(int par1, int par2, int par3) {
   if (par2 >> 4 >= this.storageArrays.length) {
     return 0;
   } else {
     ExtendedBlockStorage var4 = this.storageArrays[par2 >> 4];
     return var4 != null ? var4.getExtBlockID(par1, par2 & 15, par3) : 0;
   }
 }
Esempio n. 3
0
  /** Sets a blockID of a position within a chunk with metadata. Args: x, y, z, blockID, metadata */
  public boolean setBlockIDWithMetadata(int par1, int par2, int par3, int par4, int par5) {
    int var6 = par3 << 4 | par1;

    if (par2 >= this.precipitationHeightMap[var6] - 1) {
      this.precipitationHeightMap[var6] = -999;
    }

    int var7 = this.heightMap[var6];
    int var8 = this.getBlockID(par1, par2, par3);
    int var9 = this.getBlockMetadata(par1, par2, par3);

    if (var8 == par4 && var9 == par5) {
      return false;
    } else {
      ExtendedBlockStorage var10 = this.storageArrays[par2 >> 4];
      boolean var11 = false;

      if (var10 == null) {
        if (par4 == 0) {
          return false;
        }

        var10 =
            this.storageArrays[par2 >> 4] =
                new ExtendedBlockStorage(par2 >> 4 << 4, !this.worldObj.provider.hasNoSky);
        var11 = par2 >= var7;
      }

      int var12 = this.xPosition * 16 + par1;
      int var13 = this.zPosition * 16 + par3;

      if (var8 != 0 && !this.worldObj.isRemote) {
        Block.blocksList[var8].onSetBlockIDWithMetaData(this.worldObj, var12, par2, var13, var9);
      }

      var10.setExtBlockID(par1, par2 & 15, par3, par4);

      if (var8 != 0) {
        if (!this.worldObj.isRemote) {
          Block.blocksList[var8].breakBlock(this.worldObj, var12, par2, var13, var8, var9);
        } else if (Block.blocksList[var8] instanceof ITileEntityProvider && var8 != par4) {
          this.worldObj.removeBlockTileEntity(var12, par2, var13);
        }
      }

      if (var10.getExtBlockID(par1, par2 & 15, par3) != par4) {
        return false;
      } else {
        var10.setExtBlockMetadata(par1, par2 & 15, par3, par5);

        if (var11) {
          this.generateSkylightMap();
        } else {
          if (Block.lightOpacity[par4 & 4095] > 0) {
            if (par2 >= var7) {
              this.relightBlock(par1, par2 + 1, par3);
            }
          } else if (par2 == var7 - 1) {
            this.relightBlock(par1, par2, par3);
          }

          this.propagateSkylightOcclusion(par1, par3);
        }

        TileEntity var14;

        if (par4 != 0) {
          if (!this.worldObj.isRemote) {
            Block.blocksList[par4].onBlockAdded(this.worldObj, var12, par2, var13);
          }

          if (Block.blocksList[par4] instanceof ITileEntityProvider) {
            var14 = this.getChunkBlockTileEntity(par1, par2, par3);

            if (var14 == null) {
              var14 =
                  ((ITileEntityProvider) Block.blocksList[par4]).createNewTileEntity(this.worldObj);
              this.worldObj.setBlockTileEntity(var12, par2, var13, var14);
            }

            if (var14 != null) {
              var14.updateContainingBlockInfo();
            }
          }
        } else if (var8 > 0 && Block.blocksList[var8] instanceof ITileEntityProvider) {
          var14 = this.getChunkBlockTileEntity(par1, par2, par3);

          if (var14 != null) {
            var14.updateContainingBlockInfo();
          }
        }

        this.isModified = true;
        return true;
      }
    }
  }
Esempio n. 4
0
  /**
   * plays random cave ambient sounds and runs updateTick on random blocks within each chunk in the
   * vacinity of a player
   */
  protected void tickBlocksAndAmbiance() {
    super.tickBlocksAndAmbiance();
    int var1 = 0;
    int var2 = 0;
    Iterator var3 = this.activeChunkSet.iterator();

    while (var3.hasNext()) {
      ChunkCoordIntPair var4 = (ChunkCoordIntPair) var3.next();
      int var5 = var4.chunkXPos * 16;
      int var6 = var4.chunkZPos * 16;
      this.theProfiler.startSection("getChunk");
      Chunk var7 = this.getChunkFromChunkCoords(var4.chunkXPos, var4.chunkZPos);
      this.moodSoundAndLightCheck(var5, var6, var7);
      this.theProfiler.endStartSection("tickChunk");
      var7.updateSkylight();
      this.theProfiler.endStartSection("thunder");
      int var8;
      int var9;
      int var10;
      int var11;

      if (this.rand.nextInt(100000) == 0 && this.isRaining() && this.isThundering()) {
        this.updateLCG = this.updateLCG * 3 + 1013904223;
        var8 = this.updateLCG >> 2;
        var9 = var5 + (var8 & 15);
        var10 = var6 + (var8 >> 8 & 15);
        var11 = this.getPrecipitationHeight(var9, var10);

        if (this.canLightningStrikeAt(var9, var11, var10)) {
          this.addWeatherEffect(
              new EntityLightningBolt(this, (double) var9, (double) var11, (double) var10));
        }
      }

      this.theProfiler.endStartSection("iceandsnow");
      int var13;

      if (this.rand.nextInt(16) == 0) {
        this.updateLCG = this.updateLCG * 3 + 1013904223;
        var8 = this.updateLCG >> 2;
        var9 = var8 & 15;
        var10 = var8 >> 8 & 15;
        var11 = this.getPrecipitationHeight(var9 + var5, var10 + var6);

        if (this.isBlockFreezableNaturally(var9 + var5, var11 - 1, var10 + var6)) {
          this.setBlock(var9 + var5, var11 - 1, var10 + var6, Block.ice.blockID);
        }

        if (this.isRaining() && this.canSnowAt(var9 + var5, var11, var10 + var6)) {
          this.setBlock(var9 + var5, var11, var10 + var6, Block.snow.blockID);
        }

        if (this.isRaining()) {
          BiomeGenBase var12 = this.getBiomeGenForCoords(var9 + var5, var10 + var6);

          if (var12.canSpawnLightningBolt()) {
            var13 = this.getBlockId(var9 + var5, var11 - 1, var10 + var6);

            if (var13 != 0) {
              Block.blocksList[var13].fillWithRain(this, var9 + var5, var11 - 1, var10 + var6);
            }
          }
        }
      }

      this.theProfiler.endStartSection("tickTiles");
      ExtendedBlockStorage[] var19 = var7.getBlockStorageArray();
      var9 = var19.length;

      for (var10 = 0; var10 < var9; ++var10) {
        ExtendedBlockStorage var21 = var19[var10];

        if (var21 != null && var21.getNeedsRandomTick()) {
          for (int var20 = 0; var20 < 3; ++var20) {
            this.updateLCG = this.updateLCG * 3 + 1013904223;
            var13 = this.updateLCG >> 2;
            int var14 = var13 & 15;
            int var15 = var13 >> 8 & 15;
            int var16 = var13 >> 16 & 15;
            int var17 = var21.getExtBlockID(var14, var16, var15);
            ++var2;
            Block var18 = Block.blocksList[var17];

            if (var18 != null && var18.getTickRandomly()) {
              ++var1;
              var18.updateTick(
                  this, var14 + var5, var16 + var21.getYLocation(), var15 + var6, this.rand);
            }
          }
        }
      }

      this.theProfiler.endSection();
    }
  }