Record Class EntityHasScoreCondition
java.lang.Object
java.lang.Record
net.minecraft.world.level.storage.loot.predicates.EntityHasScoreCondition
- All Implemented Interfaces:
Predicate<LootContext>,LootContextUser,LootItemCondition
public record EntityHasScoreCondition(Map<String,IntRange> scores, LootContext.EntityTarget entityTarget)
extends Record
implements LootItemCondition
A LootItemCondition that checks if an Entity selected by a
LootContext.EntityTarget has a given set of scores.
If one of the given objectives does not exist or the entity does not have a score for that objective, the condition fails.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<EntityHasScoreCondition> private final LootContext.EntityTargetThe field for theentityTargetrecord component.The field for thescoresrecord component.Fields inherited from interface net.minecraft.world.level.storage.loot.predicates.LootItemCondition
DIRECT_CODEC, TYPED_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionEntityHasScoreCondition(Map<String, IntRange> scores, LootContext.EntityTarget entityTarget) Creates an instance of aEntityHasScoreConditionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theentityTargetrecord component.final booleanIndicates whether some other object is "equal to" this one.Set<ContextKey<?>> getType()final inthashCode()Returns a hash code value for this object.protected booleanhasScore(LootContext lootContext, Entity targetEntity, Scoreboard scoreboard, String objectiveName, IntRange scoreRange) hasScores(LootContext.EntityTarget entityTarget) scores()Returns the value of thescoresrecord component.booleantest(LootContext context) 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
validate
-
Field Details
-
scores
The field for thescoresrecord component. -
entityTarget
The field for theentityTargetrecord component. -
CODEC
-
-
Constructor Details
-
EntityHasScoreCondition
Creates an instance of aEntityHasScoreConditionrecord class.- Parameters:
scores- the value for thescoresrecord componententityTarget- the value for theentityTargetrecord component
-
-
Method Details
-
getType
- Specified by:
getTypein interfaceLootItemCondition
-
getReferencedContextParams
- Specified by:
getReferencedContextParamsin interfaceLootContextUser
-
test
- Specified by:
testin interfacePredicate<LootContext>
-
hasScore
protected boolean hasScore(LootContext lootContext, Entity targetEntity, Scoreboard scoreboard, String objectiveName, IntRange scoreRange) -
hasScores
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
scores
Returns the value of thescoresrecord component.- Returns:
- the value of the
scoresrecord component
-
entityTarget
Returns the value of theentityTargetrecord component.- Returns:
- the value of the
entityTargetrecord component
-