Java Code Examples for net.minecraft.world.chunk.storage.ExtendedBlockStorage#setExtBlockMetadata()

The following examples show how to use net.minecraft.world.chunk.storage.ExtendedBlockStorage#setExtBlockMetadata() . 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: MobileChunk.java    From archimedes-ships with MIT License 6 votes vote down vote up
public boolean setBlockAsFilledAir(int x, int y, int z)
{
	ExtendedBlockStorage storage = getBlockStorage(x, y, z);
	if (storage == null) return true;
	
	Block block = storage.getBlockByExtId(x & 15, y & 15, z & 15);
	int meta = storage.getExtBlockMetadata(x & 15, y & 15, z & 15);
	if (block == Blocks.air && meta == 1)
	{
		return true;
	}
	if (block == null || block.isAir(worldObj, x, y, z))
	{
		storage.func_150818_a(x & 15, y & 15, z & 15, Blocks.air);
		storage.setExtBlockMetadata(x & 15, y & 15, z & 15, 1);
		onSetBlockAsFilledAir(x, y, z);
		return true;
	}
	return false;
}
 
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;
}