Java Code Examples for net.minecraft.tileentity.TileEntity#updateContainingBlockInfo()

The following examples show how to use net.minecraft.tileentity.TileEntity#updateContainingBlockInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockTofuChest.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
    super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityTofuChest) {
        tileentity.updateContainingBlockInfo();
    }
}
 
Example 2
Source File: MobileChunk.java    From archimedes-ships with MIT License 5 votes vote down vote up
public boolean setBlockMetadata(int x, int y, int z, int meta)
{
	ExtendedBlockStorage storage = getBlockStorage(x, y, z);
	if (storage == null) return false;
	
	int currentmeta = storage.getExtBlockMetadata(x, y & 15, z);
	if (currentmeta == meta)
	{
		return false;
	}
	
	setChunkModified();
	storage.setExtBlockMetadata(x & 15, y & 15, z & 15, meta);
	Block block = storage.getBlockByExtId(x & 15, y & 15, z & 15);
	
	if (block != null && block.hasTileEntity(meta))
	{
		TileEntity tileentity = getTileEntity(x, y, z);
		
		if (tileentity != null)
		{
			tileentity.updateContainingBlockInfo();
			tileentity.blockMetadata = meta;
		}
	}
	
	return true;
}
 
Example 3
Source File: MobileChunk.java    From archimedes-ships with MIT License 4 votes vote down vote up
public boolean setBlockIDWithMetadata(int x, int y, int z, Block block, int meta)
{
	if (block == null) return false;
	
	ExtendedBlockStorage storage = getBlockStorageOrCreate(x, y, z);
	int i = x & 15;
	int j = y & 15;
	int k = z & 15;
	
	Block currentblock = storage.getBlockByExtId(i, j, k);
	int currentmeta = storage.getExtBlockMetadata(i, j, k);
	if (currentblock == block && currentmeta == meta)
	{
		return false;
	}
	
	storage.func_150818_a(i, j, k, block);
	storage.setExtBlockMetadata(i, j, k, meta);
	
	if (boundsInit)
	{
		minX = Math.min(minX, x);
		minY = Math.min(minY, y);
		minZ = Math.min(minZ, z);
		maxX = Math.max(maxX, x + 1);
		maxY = Math.max(maxY, y + 1);
		maxZ = Math.max(maxZ, z + 1);
	} else
	{
		boundsInit = true;
		minX = x;
		minY = y;
		minZ = z;
		maxX = x + 1;
		maxY = y + 1;
		maxZ = z + 1;
	}
	blockCount++;
	setChunkModified();
	
	TileEntity tileentity;
	if (block.hasTileEntity(meta))
	{
		tileentity = getTileEntity(x, y, z);
		
		if (tileentity == null)
		{
			setTileEntity(x, y, z, tileentity);
		}
		
		if (tileentity != null)
		{
			tileentity.updateContainingBlockInfo();
			tileentity.blockType = block;
			tileentity.blockMetadata = meta;
		}
	}
	
	return true;
}