Class PropertyType<T>
java.lang.Object
com.binaris.wizardry.api.content.spell.properties.PropertyType<T>
- All Implemented Interfaces:
IPropertyType<T>
Generic implementation of the
IPropertyType interface using functional interfaces for serialization and
deserialization. This class allows for flexible handling of different property types by providing custom functions
for converting between JSON, NBT, and the property value type. We use this because the main Electroblob's Wizardry
mod codebase only needs a few primitive types, but addons might want to implement more complex types, in those cases
you need to implement your own IPropertyType and register it on PropertyTypes.-
Constructor Summary
ConstructorsConstructorDescriptionPropertyType(BiFunction<com.google.gson.JsonElement, String, SpellProperty<T>> jsonDeserializer, BiFunction<net.minecraft.nbt.CompoundTag, String, SpellProperty<T>> tagDeserializer, BiConsumer<com.google.gson.JsonObject, SpellProperty<T>> jsonSerializer, BiConsumer<net.minecraft.nbt.CompoundTag, SpellProperty<T>> tagSerializer) -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(com.google.gson.JsonElement json, String loc) Deserializes a spell property from a JSON element.deserialize(net.minecraft.nbt.CompoundTag tag, String loc) Deserializes a spell property from a compound NBT tag.voidserialize(com.google.gson.JsonObject json, SpellProperty<T> prop) Serializes a spell property to a JSON object.voidserialize(net.minecraft.nbt.CompoundTag tag, SpellProperty<T> prop) Serializes a spell property to a compound NBT tag.
-
Constructor Details
-
PropertyType
public PropertyType(BiFunction<com.google.gson.JsonElement, String, SpellProperty<T>> jsonDeserializer, BiFunction<net.minecraft.nbt.CompoundTag, String, SpellProperty<T>> tagDeserializer, BiConsumer<com.google.gson.JsonObject, SpellProperty<T>> jsonSerializer, BiConsumer<net.minecraft.nbt.CompoundTag, SpellProperty<T>> tagSerializer)
-
-
Method Details
-
deserialize
Description copied from interface:IPropertyTypeDeserializes a spell property from a JSON element.- Specified by:
deserializein interfaceIPropertyType<T>- Parameters:
json- The JSON element to deserialize from.loc- The location or identifier for the property.- Returns:
- The deserialized spell property.
-
deserialize
Description copied from interface:IPropertyTypeDeserializes a spell property from a compound NBT tag.- Specified by:
deserializein interfaceIPropertyType<T>- Parameters:
tag- The NBT tag to deserialize from.loc- The location or identifier for the property.- Returns:
- The deserialized spell property.
-
serialize
Description copied from interface:IPropertyTypeSerializes a spell property to a JSON object.- Specified by:
serializein interfaceIPropertyType<T>- Parameters:
json- The JSON object to serialize to.prop- The spell property to serialize.
-
serialize
Description copied from interface:IPropertyTypeSerializes a spell property to a compound NBT tag.- Specified by:
serializein interfaceIPropertyType<T>- Parameters:
tag- The NBT tag to serialize to.prop- The spell property to serialize.
-