Class NBTClassType<T>
java.lang.Object
org.cyclops.cyclopscore.persist.nbt.NBTClassType<T>
- Type Parameters:
T
- The field class type.
- Direct Known Subclasses:
INBTSerializable.SelfNBTClassType
Types of NBT field classes used for persistence of fields in
CyclopsBlockEntity
.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic Map<Class<?>,
NBTClassType<?>> A map of all the types to their persist actions. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> NBTClassType<T>
getClassType
(Class<T> clazz) Get the serialization class for the given object.abstract T
static NBTClassType
static void
performActionForField
(INBTProvider provider, Field field, net.minecraft.nbt.CompoundTag tag, boolean write) Perform a field persist action.void
persistedFieldAction
(INBTProvider provider, Field field, net.minecraft.nbt.CompoundTag tag, boolean write) Called to read or write a field.static <T> T
Read an object from NBT.abstract T
readPersistedField
(String name, net.minecraft.nbt.CompoundTag tag) static <T,
I extends T>
voidWrite the given object to NBT.abstract void
writePersistedField
(String name, T object, net.minecraft.nbt.CompoundTag tag)
-
Field Details
-
NBTYPES
A map of all the types to their persist actions.
-
-
Constructor Details
-
NBTClassType
public NBTClassType()
-
-
Method Details
-
getClassType
Get the serialization class for the given object.- Type Parameters:
T
- The object type- Parameters:
clazz
- The class of the object.- Returns:
- The serialization class.
-
writeNbt
public static <T,I extends T> void writeNbt(Class<T> clazz, String name, I instance, net.minecraft.nbt.CompoundTag tag) Write the given object to NBT.- Type Parameters:
T
- The class type.I
- The object type.- Parameters:
clazz
- The class of the object.name
- The NBT key name to write to.instance
- The instance to serialize.tag
- The NBT tag to write in.
-
readNbt
Read an object from NBT.- Type Parameters:
T
- The class type.- Parameters:
clazz
- The class of the object.name
- The NBT key name to read from.tag
- The NBT tag to read in.- Returns:
- The read object.
-
getType
-
performActionForField
public static void performActionForField(INBTProvider provider, Field field, net.minecraft.nbt.CompoundTag tag, boolean write) Perform a field persist action.- Parameters:
provider
- The provider that has the field.field
- The field to persist or read.tag
- The tag compound to read or write to.write
- If there should be written, otherwise there will be read.
-
persistedFieldAction
public void persistedFieldAction(INBTProvider provider, Field field, net.minecraft.nbt.CompoundTag tag, boolean write) throws IllegalAccessException Called to read or write a field.- Parameters:
provider
- The provider that has the field.field
- The field to persist or read.tag
- The tag compound to read or write to.write
- If there should be written, otherwise there will be read.- Throws:
IllegalArgumentException
- Argument exception;IllegalAccessException
- Access exception;
-
writePersistedField
-
readPersistedField
-
getDefaultValue
-