Interface NbtValued

All Known Subinterfaces:
TileEntityBlock
All Known Implementing Classes:
BaseBlock, BaseEntity, BaseItem, BaseItemStack, MobSpawnerBlock, SignBlock, SkullBlock

public interface NbtValued
Indicates an object that contains extra data identified as an NBT structure. This interface is used when saving and loading objects to a serialized format, but may be used in other cases.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the object's NBT data (tile entity data).
    boolean
    Returns whether the block contains NBT data.
    void
    Set the object's NBT data (tile entity data).
  • Method Details

    • hasNbtData

      boolean hasNbtData()
      Returns whether the block contains NBT data. getNbtData() must not return null if this method returns true.
      Returns:
      true if there is NBT data
    • getNbtData

      @Nullable CompoundTag getNbtData()
      Get the object's NBT data (tile entity data). The returned tag, if modified in any way, should be sent to setNbtData(CompoundTag) so that the instance knows of the changes. Making changes without calling setNbtData(CompoundTag) could have unintended consequences.

      hasNbtData() must return true if and only if method does not return null.

      Returns:
      compound tag, or null
    • setNbtData

      void setNbtData(@Nullable CompoundTag nbtData)
      Set the object's NBT data (tile entity data).
      Parameters:
      nbtData - NBT data, or null if no data