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
ConstructorDescriptionBlockDataService
(Plugin plugin, String key) This creates a newBlockDataService
for the givenPlugin
. -
Method Summary
Modifier and TypeMethodDescriptionThis method returns the NBT data previously stored inside thisBlock
.getKey()
boolean
isTileEntity
(Material type) This method checks whether the givenMaterial
is a Tile Entity.void
setBlockData
(Block b, String value)
-
Constructor Details
-
BlockDataService
This creates a newBlockDataService
for the givenPlugin
. ThePlugin
and key will together form aNamespacedKey
used to store data on aTileState
.- Parameters:
plugin
- ThePlugin
responsible for this servicekey
- The key under which to store data
-
-
Method Details
-
getKey
-
setBlockData
- Parameters:
b
- TheBlock
in which to store the given valuevalue
- The value to store
-
getBlockData
This method returns the NBT data previously stored inside thisBlock
.- Parameters:
b
- TheBlock
to retrieve data from- Returns:
- The stored value
-
isTileEntity
This method checks whether the givenMaterial
is a Tile Entity. This is used to determine whether theBlock
produced by thisMaterial
produces aTileState
, making it useable as aPersistentDataHolder
. Due toBlock.getState()
being a very expensive call performance-wise though, this simple lookup method is used instead.
-