Record Class CasterHostileCondition
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.loot.condition.CasterHostileCondition
- All Implemented Interfaces:
Predicate<net.minecraft.world.level.storage.loot.LootContext>,net.minecraft.world.level.storage.loot.LootContextUser,net.minecraft.world.level.storage.loot.predicates.LootItemCondition
public record CasterHostileCondition()
extends Record
implements net.minecraft.world.level.storage.loot.predicates.LootItemCondition
A
LootItemCondition that evaluates to true if the spell field's caster
(or an active SpellFieldAnchorEntity / nearby AbstractFlyingBookEntity)
is actively hostile towards the target entity (LootContextParams.THIS_ENTITY).
Allows offensive spell fields to harm players wearing enchanted armor when the caster has been provoked or is actively targeting them in self-defense, while also allowing offensive spell fields to harm hostile non-player mobs wearing enchanted armor.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.world.level.storage.loot.predicates.LootItemCondition
net.minecraft.world.level.storage.loot.predicates.LootItemCondition.Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringEntity tag prefix applied toSpellFieldAnchorEntityinstances to record the UUID of the target entity the caster was angry at when deploying the anchor.static final com.mojang.serialization.MapCodec<CasterHostileCondition> UnitMapCodecreturningINSTANCEwhen deserializing from JSON.static final CasterHostileConditionSingleton instance ofCasterHostileCondition.Fields inherited from interface net.minecraft.world.level.storage.loot.predicates.LootItemCondition
DIRECT_CODEC, TYPED_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance of aCasterHostileConditionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.level.storage.loot.predicates.LootItemCondition.Builderbuilder()Creates aLootItemCondition.Builderthat suppliesINSTANCE.final booleanIndicates whether some other object is "equal to" this one.@NotNull net.minecraft.world.level.storage.loot.predicates.LootItemConditionTypegetType()Retrieves the registeredLootItemConditionTypefor this condition.final inthashCode()Returns a hash code value for this object.booleantest(net.minecraft.world.level.storage.loot.LootContext context) Evaluates whether the spell caster is actively hostile towardLootContextParams.THIS_ENTITY.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
getReferencedContextParams, validate
-
Field Details
-
INSTANCE
Singleton instance ofCasterHostileCondition. -
CODEC
UnitMapCodecreturningINSTANCEwhen deserializing from JSON. -
ANGRY_AT_TAG_PREFIX
Entity tag prefix applied toSpellFieldAnchorEntityinstances to record the UUID of the target entity the caster was angry at when deploying the anchor.- See Also:
-
-
Constructor Details
-
CasterHostileCondition
public CasterHostileCondition()Creates an instance of aCasterHostileConditionrecord class.
-
-
Method Details
-
builder
public static net.minecraft.world.level.storage.loot.predicates.LootItemCondition.Builder builder()Creates aLootItemCondition.Builderthat suppliesINSTANCE.- Returns:
- A condition builder for
CasterHostileCondition.
-
getType
@NotNull public @NotNull net.minecraft.world.level.storage.loot.predicates.LootItemConditionType getType()Retrieves the registeredLootItemConditionTypefor this condition.- Specified by:
getTypein interfacenet.minecraft.world.level.storage.loot.predicates.LootItemCondition- Returns:
- The
LootItemConditionTypes.CASTER_HOSTILEcondition type.
-
test
public boolean test(net.minecraft.world.level.storage.loot.LootContext context) Evaluates whether the spell caster is actively hostile towardLootContextParams.THIS_ENTITY.Checks the thread-local caster context from
MirageEntity.getCurrentCasterContext(), theLootContextParams.ATTACKING_ENTITYparameter (unwrapping projectiles and mirages), nearby taggedSpellFieldAnchorEntityinstances within 16 blocks, and nearby hostileAbstractFlyingBookEntityinstances within 48 blocks. -
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.
-