Allow custom blocks to initialize their data on placement

This commit is contained in:
jglrxavpok 2020-04-28 13:23:49 +02:00
parent f00bdc66bf
commit 4c6d31fac1
2 changed files with 13 additions and 0 deletions

View File

@ -74,6 +74,7 @@ public class InstanceContainer extends Instance {
// Set the block
if (isCustomBlock) {
data = BLOCK_MANAGER.getCustomBlock(customBlockId).createData(x, y, z, data);
chunk.UNSAFE_setCustomBlock(x, y, z, customBlockId, data);
} else {
chunk.UNSAFE_setBlock(x, y, z, blockId, data);

View File

@ -65,4 +65,16 @@ public abstract class CustomBlock {
public String getIdentifier() {
return identifier;
}
/**
* Initialises data for this block
* @param x X position of the block
* @param y Y position of the block
* @param z Z position of the block
* @param data data given to 'setBlock', can be null
* @return Data for this block. Can be null, 'data', or a new object
*/
public Data createData(int x, int y, int z, Data data) {
return data;
}
}