Ejemplo n.º 1
0
  /** Gets the TileEntity for a given block in this chunk */
  public TileEntity getChunkBlockTileEntity(int par1, int par2, int par3) {
    ChunkPosition var4 = new ChunkPosition(par1, par2, par3);
    TileEntity var5 = (TileEntity) this.chunkTileEntityMap.get(var4);

    if (var5 == null) {
      int var6 = this.getBlockID(par1, par2, par3);

      if (var6 <= 0 || !Block.blocksList[var6].hasTileEntity()) {
        return null;
      }

      if (var5 == null) {
        var5 = ((ITileEntityProvider) Block.blocksList[var6]).createNewTileEntity(this.worldObj);
        this.worldObj.setBlockTileEntity(
            this.xPosition * 16 + par1, par2, this.zPosition * 16 + par3, var5);
      }

      var5 = (TileEntity) this.chunkTileEntityMap.get(var4);
    }

    if (var5 != null && var5.isInvalid()) {
      this.chunkTileEntityMap.remove(var4);
      return null;
    } else {
      return var5;
    }
  }