Class BlockDataService
java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.BlockDataService
- All Implemented Interfaces:
Keyed
The
BlockDataService is similar to the CustomItemDataService,
it is responsible for storing NBT data inside a TileState.
This is used to speed up performance and prevent- Author:
- TheBusyBiscuit
-
Constructor Summary
ConstructorsConstructorDescriptionBlockDataService(Plugin plugin, String key) This creates a newBlockDataServicefor the givenPlugin. -
Method Summary
Modifier and TypeMethodDescriptionThis method returns the NBT data previously stored inside thisBlock.getKey()booleanisTileEntity(Material type) This method checks whether the givenMaterialis a Tile Entity.voidsetBlockData(Block b, String value)
-
Constructor Details
-
BlockDataService
This creates a newBlockDataServicefor the givenPlugin. ThePluginand key will together form aNamespacedKeyused to store data on aTileState.- Parameters:
plugin- ThePluginresponsible for this servicekey- The key under which to store data
-
-
Method Details
-
getKey
-
setBlockData
- Parameters:
b- TheBlockin which to store the given valuevalue- The value to store
-
getBlockData
This method returns the NBT data previously stored inside thisBlock.- Parameters:
b- TheBlockto retrieve data from- Returns:
- The stored value
-
isTileEntity
This method checks whether the givenMaterialis a Tile Entity. This is used to determine whether theBlockproduced by thisMaterialproduces aTileState, making it useable as aPersistentDataHolder. Due toBlock.getState()being a very expensive call performance-wise though, this simple lookup method is used instead.
-