Record Class Weighted<T>

java.lang.Object
java.lang.Record
net.minecraft.util.collection.Weighted<T>
Record Components:
value -
weight -

public record Weighted<T>(T value, int weight) extends Record
A data value with an associated weight. Weighted values are used in pools.
Mappings:
Namespace Name
named net/minecraft/util/collection/Weighted
intermediary net/minecraft/class_6010
official bvs
named value
intermediary comp_2542
official a
named weight
intermediary comp_2543
official b
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Logger
     
    private final T
    The field for the value record component.
    private final int
    The field for the weight record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Weighted(T value, int weight)
    Creates an instance of a Weighted record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E> com.mojang.serialization.Codec<Weighted<E>>
    createCodec(com.mojang.serialization.Codec<E> dataCodec)
     
    static <E> com.mojang.serialization.Codec<Weighted<E>>
    createCodec(com.mojang.serialization.MapCodec<E> dataCodec)
     
    final boolean
    equals(Object object)
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.
    <U> Weighted<U>
    transform(Function<T,U> function)
     
    Returns the value of the value record component.
    int
    Returns the value of the weight record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • value

      private final T value
      The field for the value record component.
    • weight

      private final int weight
      The field for the weight record component.
    • LOGGER

      private static final Logger LOGGER
      Mappings:
      Namespace Name Mixin selector
      named LOGGER Lnet/minecraft/util/collection/Weighted;LOGGER:Lorg/slf4j/Logger;
      intermediary field_55645 Lnet/minecraft/class_6010;field_55645:Lorg/slf4j/Logger;
      official c Lbvs;c:Lorg/slf4j/Logger;
  • Constructor Details

    • Weighted

      public Weighted(T value, int weight)
      Creates an instance of a Weighted record class.
      Parameters:
      value - the value for the value record component
      weight - the value for the weight record component
  • Method Details

    • createCodec

      public static <E> com.mojang.serialization.Codec<Weighted<E>> createCodec(com.mojang.serialization.Codec<E> dataCodec)
      Mappings:
      Namespace Name Mixin selector
      named createCodec Lnet/minecraft/util/collection/Weighted;createCodec(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
      intermediary method_34981 Lnet/minecraft/class_6010;method_34981(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
      official a Lbvs;a(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
    • createCodec

      public static <E> com.mojang.serialization.Codec<Weighted<E>> createCodec(com.mojang.serialization.MapCodec<E> dataCodec)
      Mappings:
      Namespace Name Mixin selector
      named createCodec Lnet/minecraft/util/collection/Weighted;createCodec(Lcom/mojang/serialization/MapCodec;)Lcom/mojang/serialization/Codec;
      intermediary method_66211 Lnet/minecraft/class_6010;method_66211(Lcom/mojang/serialization/MapCodec;)Lcom/mojang/serialization/Codec;
      official a Lbvs;a(Lcom/mojang/serialization/MapCodec;)Lcom/mojang/serialization/Codec;
    • transform

      public <U> Weighted<U> transform(Function<T,U> function)
      Mappings:
      Namespace Name Mixin selector
      named transform Lnet/minecraft/util/collection/Weighted;transform(Ljava/util/function/Function;)Lnet/minecraft/util/collection/Weighted;
      intermediary method_68255 Lnet/minecraft/class_6010;method_68255(Ljava/util/function/Function;)Lnet/minecraft/class_6010;
      official a Lbvs;a(Ljava/util/function/Function;)Lbvs;
    • 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 object)
      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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      object - the object with which to compare
      Returns:
      true if this object is the same as the object argument; false otherwise.
    • value

      public T value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • weight

      public int weight()
      Returns the value of the weight record component.
      Returns:
      the value of the weight record component