/**
   * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the
   * blocks for the specified chunk from the map seed and chunk seed
   */
  public Chunk provideChunk(int par1, int par2) {
    Chunk var3 = new Chunk(this.worldObj, par1, par2);

    for (int var4 = 0; var4 < this.field_82700_c.length; ++var4) {
      int var5 = var4 >> 4;
      ExtendedBlockStorage var6 = var3.getBlockStorageArray()[var5];

      if (var6 == null) {
        var6 = new ExtendedBlockStorage(var4, !this.worldObj.provider.hasNoSky);
        var3.getBlockStorageArray()[var5] = var6;
      }

      for (int var7 = 0; var7 < 16; ++var7) {
        for (int var8 = 0; var8 < 16; ++var8) {
          var6.setExtBlockID(var7, var4 & 15, var8, this.field_82700_c[var4] & 255);
          var6.setExtBlockMetadata(var7, var4 & 15, var8, this.field_82698_d[var4]);
        }
      }
    }

    var3.generateSkylightMap();
    BiomeGenBase[] var9 =
        this.worldObj
            .getWorldChunkManager()
            .loadBlockGeneratorData((BiomeGenBase[]) null, par1 * 16, par2 * 16, 16, 16);
    byte[] var10 = var3.getBiomeArray();

    for (int var11 = 0; var11 < var10.length; ++var11) {
      var10[var11] = (byte) var9[var11].biomeID;
    }

    Iterator var12 = this.structureGenerators.iterator();

    while (var12.hasNext()) {
      MapGenStructure var13 = (MapGenStructure) var12.next();
      var13.generate(this, this.worldObj, par1, par2, (byte[]) null);
    }

    var3.generateSkylightMap();
    return var3;
  }
Esempio n. 2
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;
      }
    }
  }