Class BlockDataService

java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.BlockDataService
All Implemented Interfaces:
Keyed

public class BlockDataService extends Object implements 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 Details

  • Method Details

    • getKey

      public NamespacedKey getKey()
      Specified by:
      getKey in interface Keyed
    • setBlockData

      public void setBlockData(@Nonnull Block b, @Nonnull String value)
      This will store the given String inside the NBT data of the given Block
      Parameters:
      b - The Block in which to store the given value
      value - The value to store
    • getBlockData

      public Optional<String> getBlockData(@Nonnull Block b)
      This method returns the NBT data previously stored inside this Block.
      Parameters:
      b - The Block to retrieve data from
      Returns:
      The stored value
    • isTileEntity

      public boolean isTileEntity(@Nullable Material type)
      This method checks whether the given Material is a Tile Entity. This is used to determine whether the Block produced by this Material produces a TileState, making it useable as a PersistentDataHolder. Due to Block.getState() being a very expensive call performance-wise though, this simple lookup method is used instead.
      Parameters:
      type - The Material to check for
      Returns:
      Whether the given Material is considered a Tile Entity