Class PropertyType<T>

java.lang.Object
com.binaris.wizardry.api.content.spell.properties.PropertyType<T>
All Implemented Interfaces:
IPropertyType<T>

public class PropertyType<T> extends Object implements 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 Details

  • Method Details

    • deserialize

      public SpellProperty<T> deserialize(com.google.gson.JsonElement json, String loc)
      Description copied from interface: IPropertyType
      Deserializes a spell property from a JSON element.
      Specified by:
      deserialize in interface IPropertyType<T>
      Parameters:
      json - The JSON element to deserialize from.
      loc - The location or identifier for the property.
      Returns:
      The deserialized spell property.
    • deserialize

      public SpellProperty<T> deserialize(net.minecraft.nbt.CompoundTag tag, String loc)
      Description copied from interface: IPropertyType
      Deserializes a spell property from a compound NBT tag.
      Specified by:
      deserialize in interface IPropertyType<T>
      Parameters:
      tag - The NBT tag to deserialize from.
      loc - The location or identifier for the property.
      Returns:
      The deserialized spell property.
    • serialize

      public void serialize(com.google.gson.JsonObject json, SpellProperty<T> prop)
      Description copied from interface: IPropertyType
      Serializes a spell property to a JSON object.
      Specified by:
      serialize in interface IPropertyType<T>
      Parameters:
      json - The JSON object to serialize to.
      prop - The spell property to serialize.
    • serialize

      public void serialize(net.minecraft.nbt.CompoundTag tag, SpellProperty<T> prop)
      Description copied from interface: IPropertyType
      Serializes a spell property to a compound NBT tag.
      Specified by:
      serialize in interface IPropertyType<T>
      Parameters:
      tag - The NBT tag to serialize to.
      prop - The spell property to serialize.