/// <summary> /// Set the metadata of a block in the chunk /// </summary> public virtual bool SetBlockMetadata(int par1, int par2, int par3, int par4) { ExtendedBlockStorage extendedblockstorage = storageArrays[par2 >> 4]; if (extendedblockstorage == null) { return(false); } int i = extendedblockstorage.GetExtBlockMetadata(par1, par2 & 0xf, par3); if (i == par4) { return(false); } IsModified = true; extendedblockstorage.SetExtBlockMetadata(par1, par2 & 0xf, par3, par4); int j = extendedblockstorage.GetExtBlockID(par1, par2 & 0xf, par3); if (j > 0 && (Block.BlocksList[j] is BlockContainer)) { TileEntity tileentity = GetChunkBlockTileEntity(par1, par2, par3); if (tileentity != null) { tileentity.UpdateContainingBlockInfo(); tileentity.BlockMetadata = par4; } } return(true); }
/// <summary> /// Return the ID of a block in the chunk. /// </summary> public virtual int GetBlockID(int par1, int par2, int par3) { if (par2 >> 4 >= storageArrays.Length) { return(0); } ExtendedBlockStorage extendedblockstorage = storageArrays[par2 >> 4]; if (extendedblockstorage != null) { return(extendedblockstorage.GetExtBlockID(par1, par2 & 0xf, par3)); } else { return(0); } }
/// <summary> /// Sets a BlockID of a position within a chunk with metadata. Args: x, y, z, BlockID, metadata /// </summary> public virtual bool SetBlockIDWithMetadata(int par1, int par2, int par3, int par4, int par5) { int i = par3 << 4 | par1; if (par2 >= PrecipitationHeightMap[i] - 1) { PrecipitationHeightMap[i] = -999; } int j = HeightMap[i]; int k = GetBlockID(par1, par2, par3); if (k == par4 && GetBlockMetadata(par1, par2, par3) == par5) { return(false); } ExtendedBlockStorage extendedblockstorage = storageArrays[par2 >> 4]; bool flag = false; if (extendedblockstorage == null) { if (par4 == 0) { return(false); } extendedblockstorage = storageArrays[par2 >> 4] = new ExtendedBlockStorage((par2 >> 4) << 4); flag = par2 >= j; } extendedblockstorage.SetExtBlockID(par1, par2 & 0xf, par3, par4); int l = XPosition * 16 + par1; int i1 = ZPosition * 16 + par3; if (k != 0) { if (!WorldObj.IsRemote) { Block.BlocksList[k].OnBlockRemoval(WorldObj, l, par2, i1); } else if ((Block.BlocksList[k] is BlockContainer) && k != par4) { WorldObj.RemoveBlockTileEntity(l, par2, i1); } } if (extendedblockstorage.GetExtBlockID(par1, par2 & 0xf, par3) != par4) { return(false); } extendedblockstorage.SetExtBlockMetadata(par1, par2 & 0xf, par3, par5); if (flag) { GenerateSkylightMap(); } else { if (Block.LightOpacity[par4 & 0xfff] > 0) { if (par2 >= j) { RelightBlock(par1, par2 + 1, par3); } } else if (par2 == j - 1) { RelightBlock(par1, par2, par3); } PropagateSkylightOcclusion(par1, par3); } if (par4 != 0) { if (!WorldObj.IsRemote) { Block.BlocksList[par4].OnBlockAdded(WorldObj, l, par2, i1); } if (Block.BlocksList[par4] is BlockContainer) { TileEntity tileentity = GetChunkBlockTileEntity(par1, par2, par3); if (tileentity == null) { tileentity = ((BlockContainer)Block.BlocksList[par4]).GetBlockEntity(); WorldObj.SetBlockTileEntity(l, par2, i1, tileentity); } if (tileentity != null) { tileentity.UpdateContainingBlockInfo(); } } } else if (k > 0 && (Block.BlocksList[k] is BlockContainer)) { TileEntity tileentity1 = GetChunkBlockTileEntity(par1, par2, par3); if (tileentity1 != null) { tileentity1.UpdateContainingBlockInfo(); } } IsModified = true; return(true); }