Record Class DisarmEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.DisarmEffect
- Record Components:
dropChance- TheLevelBasedValuebase probability (0.0 to 1.0) of disarming each slot before topological scaling.slots- The list ofEquipmentSlots evaluated for disarming.entityFilter- OptionalContextAwarePredicaterestricting which entities can be disarmed.
- All Implemented Interfaces:
SpellFieldEffect,SpellFieldEntityEffect
public record DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, List<net.minecraft.world.entity.EquipmentSlot> slots, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that probabilistically forces targeted LivingEntity instances
to drop items equipped in specified EquipmentSlots into the world with a 40-tick pickup delay
and a randomized outward scatter impulse.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<DisarmEffect> MapCodec for serializing and deserializingDisarmEffectinstances from JSON.static final StringJSON field key for the base disarm probability.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.static final StringJSON field key for the list of targeted equipment slots. -
Constructor Summary
ConstructorsConstructorDescriptionDisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance) Constructs aDisarmEffectwith an initially empty slot list for fluent builder-style configuration.DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, List<net.minecraft.world.entity.EquipmentSlot> slots, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter) Creates an instance of aDisarmEffectrecord class.DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots) Constructs an unfilteredDisarmEffecttargeting a single equipment slot.DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter) Constructs aDisarmEffecttargeting a single equipment slot and restricted by an entity filter. -
Method Summary
Modifier and TypeMethodDescriptionaddSlot(net.minecraft.world.entity.EquipmentSlot... slot) Returns a copy of this effect with the specifiedEquipmentSlots appended to the target list.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) Evaluates the scaled disarm probability ($\text{dropChance} \cdot \text{volumeScalar}$) for each populated slot inslots()onvictim, spawning anItemEntityand clearing the slot whenever the roll succeeds.com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.net.minecraft.world.item.enchantment.LevelBasedValueReturns the value of thedropChancerecord component.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.List<net.minecraft.world.entity.EquipmentSlot> slots()Returns the value of theslotsrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DROP_CHANCE
JSON field key for the base disarm probability.- See Also:
-
SLOTS
JSON field key for the list of targeted equipment slots.- 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 deserializingDisarmEffectinstances from JSON.
-
-
Constructor Details
-
DisarmEffect
public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots) Constructs an unfilteredDisarmEffecttargeting a single equipment slot.- Parameters:
dropChance- TheLevelBasedValuedisarm probability.slots- The singleEquipmentSlotto target.
-
DisarmEffect
public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter) Constructs aDisarmEffecttargeting a single equipment slot and restricted by an entity filter.- Parameters:
dropChance- TheLevelBasedValuedisarm probability.slots- The singleEquipmentSlotto target.entityFilter- The predicate filter to match against candidate entities.
-
DisarmEffect
public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance) Constructs aDisarmEffectwith an initially empty slot list for fluent builder-style configuration.- Parameters:
dropChance- TheLevelBasedValuedisarm probability.
-
DisarmEffect
public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, List<net.minecraft.world.entity.EquipmentSlot> slots, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter) Creates an instance of aDisarmEffectrecord class.- Parameters:
dropChance- the value for thedropChancerecord componentslots- the value for theslotsrecord 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) Evaluates the scaled disarm probability ($\text{dropChance} \cdot \text{volumeScalar}$) for each populated slot inslots()onvictim, spawning anItemEntityand clearing the slot whenever the roll succeeds.- 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.
-
addSlot
Returns a copy of this effect with the specifiedEquipmentSlots appended to the target list.- Parameters:
slot- One or moreEquipmentSlots to append.- Returns:
- A new
DisarmEffectinstance containing the combined slot list.
-
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). -
dropChance
public net.minecraft.world.item.enchantment.LevelBasedValue dropChance()Returns the value of thedropChancerecord component.- Returns:
- the value of the
dropChancerecord component
-
slots
Returns the value of theslotsrecord component.- Returns:
- the value of the
slotsrecord component
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-