-
Notifications
You must be signed in to change notification settings - Fork 0
CustomBlockState
Minecraft uses BlockStates to store its blocks. The same concept is used here. BlockStates are also a parameter in almost every method you can override in the Block class, since they are the only way to get data about the actual block in the world with its properties and entities.
There are multiple ways to obtain a blockstate. Those are:
-
CustomBlocksApi#getStateFromWorld(Location): Returns a CustomBlockState from a location or null if the block at that location is not a CustomBlock -
CustomBlocksApi#getStateFromEntity(Entity): Returns a CustomBlockState from an Interaction/ItemDisplay entity if the entity is part of a CustomBlock
You should never ever create a CustomBlockState using it's Constructor as this will lead to some serious errors
An instance of this class stores all [properties] set for the customBlock, the display and interaction entity the state represents (can be null!) and the location of the block.
After you change the data of a CustomBlockState, you must call the update() method to synchronize the changes with the corresponding entities in the world. If you do not update, the block will not change its appearance and all changes will be lost after the object is discarded