Record Class ConfigKey<TYPE>

java.lang.Object
java.lang.Record
com.wildfire.common.config.value.ConfigKey<TYPE>

public record ConfigKey<TYPE>(com.mojang.datafixers.util.Either<TYPE, Supplier<TYPE>> defaultValueSupplier, com.mojang.serialization.Codec<TYPE> codec, net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, TYPE> streamCodec, ConfigValidator<TYPE> validator) extends Record
  • Field Details

  • Constructor Details

    • ConfigKey

      public ConfigKey(com.mojang.datafixers.util.Either<TYPE, Supplier<TYPE>> defaultValueSupplier, com.mojang.serialization.Codec<TYPE> codec, net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, TYPE> streamCodec, ConfigValidator<TYPE> validator)
      Creates an instance of a ConfigKey record class.
      Parameters:
      defaultValueSupplier - the value for the defaultValueSupplier record component
      codec - the value for the codec record component
      streamCodec - the value for the streamCodec record component
      validator - the value for the validator record component
    • ConfigKey

      public ConfigKey(TYPE defaultValue, com.mojang.serialization.Codec<TYPE> baseCodec, net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, TYPE> streamCodec)
    • ConfigKey

      public ConfigKey(TYPE defaultValue, com.mojang.serialization.Codec<TYPE> baseCodec, net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, TYPE> streamCodec, ConfigValidator<TYPE> range)
    • ConfigKey

      public ConfigKey(Supplier<TYPE> defaultValueSupplier, com.mojang.serialization.Codec<TYPE> baseCodec, net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, TYPE> streamCodec)
    • ConfigKey

      public ConfigKey(Supplier<TYPE> defaultValueSupplier, com.mojang.serialization.Codec<TYPE> baseCodec, net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, TYPE> streamCodec, ConfigValidator<TYPE> range)
  • Method Details

    • alwaysTrueValidator

      public static <TYPE> ConfigValidator<TYPE> alwaysTrueValidator()
    • defaultValue

      public TYPE defaultValue()
    • validate

      @Contract("null -> false") public boolean validate(@Nullable TYPE value)
    • codecOrDefault

      public com.mojang.serialization.MapCodec<TYPE> codecOrDefault(String key)
    • createValueHandler

      public ConfigValue<TYPE> createValueHandler(TYPE value)
    • create

      public static ConfigKey<Float> create(float defaultValue, float minInclusive, float maxInclusive)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • defaultValueSupplier

      public com.mojang.datafixers.util.Either<TYPE, Supplier<TYPE>> defaultValueSupplier()
      Returns the value of the defaultValueSupplier record component.
      Returns:
      the value of the defaultValueSupplier record component
    • codec

      public com.mojang.serialization.Codec<TYPE> codec()
      Returns the value of the codec record component.
      Returns:
      the value of the codec record component
    • streamCodec

      public net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, TYPE> streamCodec()
      Returns the value of the streamCodec record component.
      Returns:
      the value of the streamCodec record component
    • validator

      public ConfigValidator<TYPE> validator()
      Returns the value of the validator record component.
      Returns:
      the value of the validator record component