Record Class LootDataType<T>

java.lang.Object
java.lang.Record
net.minecraft.world.level.storage.loot.LootDataType<T>

public record LootDataType<T>(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, LootDataType.Validator<T> validator, T defaultValue, com.mojang.serialization.Codec<Optional<T>> conditionalCodec, BiConsumer<T,ResourceLocation> idSetter) extends Record
  • Field Details

    • registryKey

      private final ResourceKey<Registry<T>> registryKey
      The field for the registryKey record component.
    • codec

      private final com.mojang.serialization.Codec<T> codec
      The field for the codec record component.
    • validator

      private final LootDataType.Validator<T> validator
      The field for the validator record component.
    • defaultValue

      @Nullable private final T defaultValue
      The field for the defaultValue record component.
    • conditionalCodec

      private final com.mojang.serialization.Codec<Optional<T>> conditionalCodec
      The field for the conditionalCodec record component.
    • idSetter

      private final BiConsumer<T,ResourceLocation> idSetter
      The field for the idSetter record component.
    • PREDICATE

      public static final LootDataType<LootItemCondition> PREDICATE
    • MODIFIER

      public static final LootDataType<LootItemFunction> MODIFIER
    • TABLE

      public static final LootDataType<LootTable> TABLE
  • Constructor Details

    • LootDataType

      @Deprecated private LootDataType(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, LootDataType.Validator<T> validator)
      Deprecated.
      Neo: use the constructor
      invalid reference
      with a default value and id setter
      to support conditions
    • LootDataType

      private LootDataType(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, LootDataType.Validator<T> validator, @Nullable T defaultValue, BiConsumer<T,ResourceLocation> idSetter)
    • LootDataType

      public LootDataType(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, LootDataType.Validator<T> validator, @Nullable T defaultValue, com.mojang.serialization.Codec<Optional<T>> conditionalCodec, BiConsumer<T,ResourceLocation> idSetter)
      Creates an instance of a LootDataType record class.
      Parameters:
      registryKey - the value for the registryKey record component
      codec - the value for the codec record component
      validator - the value for the validator record component
      defaultValue - the value for the defaultValue record component
      conditionalCodec - the value for the conditionalCodec record component
      idSetter - the value for the idSetter record component
  • Method Details

    • runValidation

      public void runValidation(ValidationContext context, ResourceKey<T> key, T value)
    • values

      public static Stream<LootDataType<?>> values()
    • createSimpleValidator

      private static <T extends LootContextUser> LootDataType.Validator<T> createSimpleValidator()
    • createLootTableValidator

      private static LootDataType.Validator<LootTable> createLootTableValidator()
    • 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.
    • registryKey

      public ResourceKey<Registry<T>> registryKey()
      Returns the value of the registryKey record component.
      Returns:
      the value of the registryKey record component
    • codec

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

      public LootDataType.Validator<T> validator()
      Returns the value of the validator record component.
      Returns:
      the value of the validator record component
    • defaultValue

      @Nullable public T defaultValue()
      Returns the value of the defaultValue record component.
      Returns:
      the value of the defaultValue record component
    • conditionalCodec

      public com.mojang.serialization.Codec<Optional<T>> conditionalCodec()
      Returns the value of the conditionalCodec record component.
      Returns:
      the value of the conditionalCodec record component
    • idSetter

      public BiConsumer<T,ResourceLocation> idSetter()
      Returns the value of the idSetter record component.
      Returns:
      the value of the idSetter record component