Class StorageData

java.lang.Object
net.nullved.pmweatherapi.storage.data.StorageData
All Implemented Interfaces:
IStorageData
Direct Known Subclasses:
BlockPosData, MetarStorageData, RadarStorageData, WSRStorageData

public abstract class StorageData extends Object implements IStorageData
A basic IStorageData implementation that stores and handles a BlockPos by default.

By extending this class, you can add additional data that will be saved as part of the "Storages" system.

To register your data for use, you must first register it with StorageDataManager.register(ResourceLocation, BiFunction)

When serializing, you should get the CompoundTag from calling serializeToNBT(). This makes sure that you have both the type and blockpos saved.

When deserializing, you can call deserializeBlockPos(CompoundTag) to automatically read the saved BlockPos

For some example implementations, view RadarStorageData, MetarStorageData, and WSRStorageData
Since:
0.15.3.3
See Also:
  • Field Details

    • pos

      protected final net.minecraft.core.BlockPos pos
  • Constructor Details

    • StorageData

      public StorageData(net.minecraft.core.BlockPos pos)
  • Method Details

    • getPos

      public net.minecraft.core.BlockPos getPos()
      Get the position saved in this data
      Specified by:
      getPos in interface IStorageData
      Returns:
      A BlockPos
      Since:
      0.15.3.3
    • serializeToNBT

      public net.minecraft.nbt.CompoundTag serializeToNBT()
      Serialize this storage data to NBT
      Specified by:
      serializeToNBT in interface IStorageData
      Returns:
      A CompoundTag of the serialized data
      Since:
      0.15.3.3
    • deserializeBlockPos

      public static net.minecraft.core.BlockPos deserializeBlockPos(net.minecraft.nbt.CompoundTag tag)
      Deserialize a BlockPos from a CompoundTag
      Parameters:
      tag - The CompoundTag to get the BlockPos from
      Returns:
      The found BlockPos, or null
      Since:
      0.15.3.3
    • deserializeFromNBT

      public static <D extends IStorageData> D deserializeFromNBT(net.minecraft.nbt.CompoundTag tag, int version)
      Type Parameters:
      D - The type of IStorageData
      Parameters:
      tag - The CompoundTag
      version - The version of the data
      Returns:
      An IStorageData instance
      Since:
      0.15.3.3