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
Provides a number by reading the score of a scoreboard member whose name is provided by a
ScoreboardNameProvider.
Additionally a scale can be provided, which will be multiplied with the score.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ScoreboardValue> private final floatThe field for thescalerecord component.private final StringThe field for thescorerecord component.private final ScoreboardNameProviderThe field for thetargetrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionScoreboardValue(ScoreboardNameProvider target, String score, float scale) Creates an instance of aScoreboardValuerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static ScoreboardValuefromScoreboard(LootContext.EntityTarget entityTarget, String score) static ScoreboardValuefromScoreboard(LootContext.EntityTarget entityTarget, String score, float scale) floatgetFloat(LootContext lootContext) Set<ContextKey<?>> getType()final inthashCode()Returns a hash code value for this object.floatscale()Returns the value of thescalerecord component.score()Returns the value of thescorerecord component.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.world.level.storage.loot.LootContextUser
validateMethods inherited from interface net.minecraft.world.level.storage.loot.providers.number.NumberProvider
getInt
-
Field Details
-
target
The field for thetargetrecord component. -
score
The field for thescorerecord component. -
scale
private final float scaleThe field for thescalerecord component. -
CODEC
-
-
Constructor Details
-
ScoreboardValue
Creates an instance of aScoreboardValuerecord class.- Parameters:
target- the value for thetargetrecord componentscore- the value for thescorerecord componentscale- the value for thescalerecord component
-
-
Method Details
-
getType
- Specified by:
getTypein interfaceNumberProvider
-
getReferencedContextParams
- Specified by:
getReferencedContextParamsin interfaceLootContextUser
-
fromScoreboard
-
fromScoreboard
public static ScoreboardValue fromScoreboard(LootContext.EntityTarget entityTarget, String score, float scale) -
getFloat
- Specified by:
getFloatin interfaceNumberProvider
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
score
Returns the value of thescorerecord component.- Returns:
- the value of the
scorerecord component
-
scale
public float scale()Returns the value of thescalerecord component.- Returns:
- the value of the
scalerecord component
-