Record Class ScoreboardValue

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

public record ScoreboardValue(ScoreboardNameProvider target, String score, float scale) extends Record implements NumberProvider
  • Field Details

    • target

      private final ScoreboardNameProvider target
      The field for the target record component.
    • score

      private final String score
      The field for the score record component.
    • scale

      private final float scale
      The field for the scale record component.
    • CODEC

      public static final com.mojang.serialization.Codec<ScoreboardValue> CODEC
  • Constructor Details

    • ScoreboardValue

      public ScoreboardValue(ScoreboardNameProvider target, String score, float scale)
      Creates an instance of a ScoreboardValue record class.
      Parameters:
      target - the value for the target record component
      score - the value for the score record component
      scale - the value for the scale record component
  • Method Details

    • getType

      public LootNumberProviderType getType()
      Specified by:
      getType in interface NumberProvider
    • getReferencedContextParams

      public Set<LootContextParam<?>> getReferencedContextParams()
      Specified by:
      getReferencedContextParams in interface LootContextUser
    • fromScoreboard

      public static ScoreboardValue fromScoreboard(LootContext.EntityTarget p_165750_, String p_165751_)
    • fromScoreboard

      public static ScoreboardValue fromScoreboard(LootContext.EntityTarget p_165753_, String p_165754_, float p_165755_)
    • getFloat

      public float getFloat(LootContext p_165758_)
      Specified by:
      getFloat in interface NumberProvider
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • target

      public ScoreboardNameProvider target()
      Returns the value of the target record component.
      Returns:
      the value of the target record component
    • score

      public String score()
      Returns the value of the score record component.
      Returns:
      the value of the score record component
    • scale

      public float scale()
      Returns the value of the scale record component.
      Returns:
      the value of the scale record component