Record Class AirSupplyEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.AirSupplyEffect
- Record Components:
amount- TheLevelBasedValuechange in air supply ticks before topological scaling.entityFilter- OptionalContextAwarePredicaterestricting which entities are affected.
- All Implemented Interfaces:
SpellFieldEffect,SpellFieldEntityEffect
public record AirSupplyEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that replenishes (when positive) or depletes (when negative) a
target entity's oxygen air supply ticks, scaled by the entity's local topological multiplier.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the air supply tick delta.static final com.mojang.serialization.MapCodec<AirSupplyEffect> MapCodec for serializing and deserializingAirSupplyEffectinstances from JSON.static final StringJSON field key for the optional entity filter predicate.static final StringRegistry path identifier for this spell field entity effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
Constructor Summary
ConstructorsConstructorDescriptionAirSupplyEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount) Constructs an unfilteredAirSupplyEffect.AirSupplyEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter) Creates an instance of aAirSupplyEffectrecord class.AirSupplyEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter) Constructs anAirSupplyEffectrestricted by the given entity predicate filter. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.enchantment.LevelBasedValueamount()Returns the value of theamountrecord component.voidapply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.world.entity.Entity victim, float volumeScalar) Modifiesvictim's air supply by $\text{amount} \cdot \text{volumeScalar}$, clamped between-20(drowning damage threshold) andEntity.getMaxAirSupply().com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> Returns the value of theentityFilterrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
AMOUNT
JSON field key for the air supply tick delta.- See Also:
-
ENTITY_FILTER
JSON field key for the optional entity filter predicate.- See Also:
-
KEY
Registry path identifier for this spell field entity effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingAirSupplyEffectinstances from JSON.
-
-
Constructor Details
-
AirSupplyEffect
public AirSupplyEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount) Constructs an unfilteredAirSupplyEffect.- Parameters:
amount- TheLevelBasedValueair supply tick change.
-
AirSupplyEffect
public AirSupplyEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter) Constructs anAirSupplyEffectrestricted by the given entity predicate filter.- Parameters:
amount- TheLevelBasedValueair supply tick change.entityFilter- The predicate filter to match against candidate entities.
-
AirSupplyEffect
public AirSupplyEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter) Creates an instance of aAirSupplyEffectrecord class.- Parameters:
amount- the value for theamountrecord componententityFilter- the value for theentityFilterrecord component
-
-
Method Details
-
apply
public void apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.world.entity.Entity victim, float volumeScalar) Modifiesvictim's air supply by $\text{amount} \cdot \text{volumeScalar}$, clamped between-20(drowning damage threshold) andEntity.getMaxAirSupply().- Specified by:
applyin interfaceSpellFieldEntityEffect- Parameters:
level- The executing server level.enchantmentLevel- The active level of the spell field enchantment.context- The item usage context triggering the spell field.spatialReference- The anchor entity or focal point of the spell field.epicenter- The exact spatial origin vector of the spell field.victim- The target entity intersecting the spell field.volumeScalar- The active topological multiplier forvictim.
-
codec
Description copied from interface:SpellFieldEffectRetrieves theMapCodecresponsible for serializing and deserializing this effect.- Specified by:
codecin interfaceSpellFieldEffect- Returns:
- The registered
MapCodecinstance.
-
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). -
amount
public net.minecraft.world.item.enchantment.LevelBasedValue amount()Returns the value of theamountrecord component.- Returns:
- the value of the
amountrecord component
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-