Interface INBTHandler<T>

All Known Implementing Classes:
BlockPosNBTHandler, BooleanNBTHandler, DoubleNBTHandler, EnumDyeColorNBTHandler, EnumNBTHandler, FloatNBTHandler, IntegerNBTHandler, ItemStackHandlerNBTHandler, ItemStackNBTHandler, LongNBTHandler, NBTSerializableNBTHandler, ShortNBTHandler, StringNBTHandler, TankNBTHandler, UUIDNBTHandler

public interface INBTHandler<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isClassValid(Class<?> aClass)
    Checks if the NBTHandler can handle a class.
    readFromNBT(net.minecraft.nbt.CompoundTag compound, String name, T currentValue)
    Reads the value from the NBT to be stored in the Field.
    boolean
    storeToNBT(net.minecraft.nbt.CompoundTag compound, String name, T object)
    Stores a value as the given name in the NBT.
  • Method Details

    • isClassValid

      boolean isClassValid(Class<?> aClass)
      Checks if the NBTHandler can handle a class.
      Parameters:
      aClass - The class that wants to be checked.
      Returns:
      true if the capability can handle the class or false if it can't.
    • storeToNBT

      boolean storeToNBT(@Nonnull net.minecraft.nbt.CompoundTag compound, @Nonnull String name, @Nonnull T object)
      Stores a value as the given name in the NBT.
      Parameters:
      compound - The NBT where the object needs to be stored.
      name - The name as it will be stored.
      object - The object value to be stored.
      Returns:
      true if the Object was successfully stored in the NBT
    • readFromNBT

      T readFromNBT(@Nonnull net.minecraft.nbt.CompoundTag compound, @Nonnull String name, @Nullable T currentValue)
      Reads the value from the NBT to be stored in the Field.
      Parameters:
      compound - The NBT that stores all the information.
      name - The name of the object stored in the NBT.
      currentValue - The current value of the object
      Returns:
      The object if it was successfully stored or null if it wasn't giving the next handlers a chance to store the value.