Add Instance#setBlockData

This commit is contained in:
Nesaak 2020-09-10 16:14:39 -04:00
parent 952668efc0
commit 81c5f957c3

View File

@ -611,6 +611,30 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
return getBlockData(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
}
/**
* Set the block data at the given position
*
* @param x the X position
* @param y the Y position
* @param z the Z position
* @param data the data to be set
*/
public void setBlockData(int x, int y, int z, Data data) {
final Chunk chunk = getChunkAt(x, z);
Check.notNull(chunk, "The chunk at " + x + ":" + z + " is not loaded");
chunk.setBlockData(x, (byte) y, z, data);
}
/**
* Set the block data at the given position
*
* @param blockPosition the block position
* @param data the data to be set
*/
public void setBlockData(BlockPosition blockPosition, Data data) {
setBlockData(blockPosition.getX(), (byte) blockPosition.getY(), blockPosition.getZ(), data);
}
/**
* Get the chunk at the given position, null if not loaded
*