Class CodecProperty<T>

java.lang.Object
net.darkhax.pricklemc.common.api.config.property.ObjectProperty<T>
net.darkhax.pricklemc.common.impl.config.property.CodecProperty<T>
Type Parameters:
T - The type of value serialized by the codec.
All Implemented Interfaces:
IConfigProperty<T>

public class CodecProperty<T> extends ObjectProperty<T>
A config property where the value is serialized using a Minecraft Codec.
  • Field Details

    • RESOURCE_LOCATION

      public static final CodecProperty.Adapter<net.minecraft.resources.ResourceLocation> RESOURCE_LOCATION
      Builtin support for resource locations using Mojang's codec.
    • BLOCK_POS

      public static final CodecProperty.Adapter<net.minecraft.core.BlockPos> BLOCK_POS
      Builtin support for block positions using Mojang's codec.
    • TEXT_COMPONENT

      public static final CodecProperty.Adapter<net.minecraft.network.chat.Component> TEXT_COMPONENT
      Builtin support for text components using Mojang's codec.
    • TEXT_STYLE

      public static final CodecProperty.Adapter<net.minecraft.network.chat.Style> TEXT_STYLE
      Builtin support for text styles using Mojang's codec.
    • EFFECT_INSTANCE

      public static final CodecProperty.Adapter<net.minecraft.world.effect.MobEffectInstance> EFFECT_INSTANCE
      Builtin support for status effects using Mojang's codec.
    • ATTRIBUTE_MODIFIER

      public static final CodecProperty.Adapter<net.minecraft.world.entity.ai.attributes.AttributeModifier> ATTRIBUTE_MODIFIER
      Builtin support for attribute modifiers using Mojang's codec.
    • ITEM_STACK

      public static final CodecProperty.Adapter<net.minecraft.world.item.ItemStack> ITEM_STACK
      Builtin support for item stacks using Mojang's codec.
    • INGREDIENT

      public static final CodecProperty.Adapter<net.minecraft.world.item.crafting.Ingredient> INGREDIENT
      Builtin support for ingredients using Mojang's codec.
  • Constructor Details

    • CodecProperty

      public CodecProperty(Field field, Object parent, T defaultValue, Value valueMeta, IComment comment, com.mojang.serialization.Codec<T> codec)
  • Method Details

    • writeValue

      public void writeValue(T value, com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Description copied from class: ObjectProperty
      Writes a value to the JSON writer.
      Overrides:
      writeValue in class ObjectProperty<T>
      Parameters:
      value - The value to be written.
      writer - A writer to write JSON data to.
      resolver - Resolves properties with GSON or config properties.
      logger - A log instance used to log warnings and errors encountered when saving the value.
      Throws:
      IOException - A fatal exception may be thrown if the value could not be written.
    • readValue

      public T readValue(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Description copied from class: ObjectProperty
      Reads a value from the JSON reader.
      Overrides:
      readValue in class ObjectProperty<T>
      Parameters:
      reader - A reader containing a stream of JSON data.
      resolver - Resolves properties with GSON or config properties.
      logger - A log instance used to log warnings and errors encountered when the value is read.
      Returns:
      The value that was read from the reader.
      Throws:
      IOException - A fatal exception may be thrown if the value could not be read.
    • of

      public static <T> CodecProperty.Adapter<T> of(Type classType, com.mojang.serialization.Codec<T> codec)
      Creates an adapter that will process a given type using a codec.
      Type Parameters:
      T - The type being adapted.
      Parameters:
      classType - The type to serialize using the codec.
      codec - The codec to serialize the value.
      Returns:
      An adapter that uses a codec to serialize data.