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>
A config property where the value is serialized using a Minecraft Codec.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA type adapter that will use a Codec to serialize a given type. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CodecProperty.Adapter<net.minecraft.world.entity.ai.attributes.AttributeModifier> Builtin support for attribute modifiers using Mojang's codec.static final CodecProperty.Adapter<net.minecraft.core.BlockPos> Builtin support for block positions using Mojang's codec.static final CodecProperty.Adapter<net.minecraft.world.effect.MobEffectInstance> Builtin support for status effects using Mojang's codec.static final CodecProperty.Adapter<net.minecraft.world.item.crafting.Ingredient> Builtin support for ingredients using Mojang's codec.static final CodecProperty.Adapter<net.minecraft.world.item.ItemStack> Builtin support for item stacks using Mojang's codec.static final CodecProperty.Adapter<net.minecraft.resources.ResourceLocation> Builtin support for resource locations using Mojang's codec.static final CodecProperty.Adapter<net.minecraft.network.chat.Component> Builtin support for text components using Mojang's codec.static final CodecProperty.Adapter<net.minecraft.network.chat.Style> Builtin support for text styles using Mojang's codec.Fields inherited from class net.darkhax.pricklemc.common.api.config.property.ObjectProperty
FALLBACK_ADAPTER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CodecProperty.Adapter<T> Creates an adapter that will process a given type using a codec.readValue(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger) Reads a value from the JSON reader.voidwriteValue(T value, com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) Writes a value to the JSON writer.Methods inherited from class net.darkhax.pricklemc.common.api.config.property.ObjectProperty
comment, defaultValue, read, validate, value, write, writeAdditionalComments, writeDefaultValue, writeDefaultValue
-
Field Details
-
RESOURCE_LOCATION
public static final CodecProperty.Adapter<net.minecraft.resources.ResourceLocation> RESOURCE_LOCATIONBuiltin support for resource locations using Mojang's codec. -
BLOCK_POS
Builtin support for block positions using Mojang's codec. -
TEXT_COMPONENT
Builtin support for text components using Mojang's codec. -
TEXT_STYLE
Builtin support for text styles using Mojang's codec. -
EFFECT_INSTANCE
public static final CodecProperty.Adapter<net.minecraft.world.effect.MobEffectInstance> EFFECT_INSTANCEBuiltin support for status effects using Mojang's codec. -
ATTRIBUTE_MODIFIER
public static final CodecProperty.Adapter<net.minecraft.world.entity.ai.attributes.AttributeModifier> ATTRIBUTE_MODIFIERBuiltin support for attribute modifiers using Mojang's codec. -
ITEM_STACK
Builtin support for item stacks using Mojang's codec. -
INGREDIENT
Builtin support for ingredients using Mojang's codec.
-
-
Constructor Details
-
CodecProperty
-
-
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:ObjectPropertyWrites a value to the JSON writer.- Overrides:
writeValuein classObjectProperty<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:ObjectPropertyReads a value from the JSON reader.- Overrides:
readValuein classObjectProperty<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.
-