Record Class Sum

java.lang.Object
java.lang.Record
net.minecraft.world.level.storage.loot.providers.number.Sum
All Implemented Interfaces:
LootContextUser, NumberProvider, Validatable

public record Sum(List<NumberProvider> summands) extends Record implements NumberProvider
  • Field Details

    • summands

      private final List<NumberProvider> summands
      The field for the summands record component.
    • MAP_CODEC

      public static final com.mojang.serialization.MapCodec<Sum> MAP_CODEC
  • Constructor Details

    • Sum

      public Sum(List<NumberProvider> summands)
      Creates an instance of a Sum record class.
      Parameters:
      summands - the value for the summands record component
  • Method Details

    • sum

      public static Sum sum(NumberProvider... summands)
    • codec

      public com.mojang.serialization.MapCodec<Sum> codec()
      Specified by:
      codec in interface NumberProvider
    • getInt

      public int getInt(LootContext context)
      Specified by:
      getInt in interface NumberProvider
    • getFloat

      public float getFloat(LootContext context)
      Specified by:
      getFloat in interface NumberProvider
    • validate

      public void validate(ValidationContext context)
      Description copied from interface: LootContextUser
      Validate that this object is used correctly according to the given ValidationContext.
      Specified by:
      validate in interface LootContextUser
      Specified by:
      validate in interface Validatable
    • 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.
    • summands

      public List<NumberProvider> summands()
      Returns the value of the summands record component.
      Returns:
      the value of the summands record component