Class StorageData
java.lang.Object
net.nullved.pmweatherapi.storage.data.StorageData
- All Implemented Interfaces:
IStorageData
- Direct Known Subclasses:
BlockPosData,MetarStorageData,RadarStorageData,WSRStorageData
A basic
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
When serializing, you should get the
When deserializing, you can call
For some example implementations, view
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.core.BlockPosdeserializeBlockPos(net.minecraft.nbt.CompoundTag tag) Deserialize aBlockPosfrom aCompoundTagstatic <D extends IStorageData>
DdeserializeFromNBT(net.minecraft.nbt.CompoundTag tag, int version) Shorthand forStorageDataManager.get(CompoundTag, int)net.minecraft.core.BlockPosgetPos()Get the position saved in this datanet.minecraft.nbt.CompoundTagSerialize this storage data to NBTMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.nullved.pmweatherapi.storage.data.IStorageData
getId
-
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:
getPosin interfaceIStorageData- Returns:
- A
BlockPos - Since:
- 0.15.3.3
-
serializeToNBT
public net.minecraft.nbt.CompoundTag serializeToNBT()Serialize this storage data to NBT- Specified by:
serializeToNBTin interfaceIStorageData- Returns:
- A
CompoundTagof the serialized data - Since:
- 0.15.3.3
-
deserializeBlockPos
public static net.minecraft.core.BlockPos deserializeBlockPos(net.minecraft.nbt.CompoundTag tag) Deserialize aBlockPosfrom aCompoundTag- Parameters:
tag- TheCompoundTagto get theBlockPosfrom- Returns:
- The found
BlockPos, ornull - Since:
- 0.15.3.3
-
deserializeFromNBT
public static <D extends IStorageData> D deserializeFromNBT(net.minecraft.nbt.CompoundTag tag, int version) Shorthand forStorageDataManager.get(CompoundTag, int)- Type Parameters:
D- The type ofIStorageData- Parameters:
tag- TheCompoundTagversion- The version of the data- Returns:
- An
IStorageDatainstance - Since:
- 0.15.3.3
-