mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 11:07:53 +01:00
Allow custom blocks to initialize their data on placement
This commit is contained in:
parent
f00bdc66bf
commit
4c6d31fac1
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user