Record Class RandomTeleportEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.RandomTeleportEffect
- Record Components:
range- TheLevelBasedValuemaximum horizontal and vertical teleportation radius in blocks.entityFilter- OptionalContextAwarePredicaterestricting which entities are teleported.
- All Implemented Interfaces:
SpellFieldEffect,SpellFieldEntityEffect
public record RandomTeleportEffect(net.minecraft.world.item.enchantment.LevelBasedValue range, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that teleports targeted LivingEntity instances to a random
safe location within range() blocks (similar to chorus fruit consumption), dismounting
passengers and playing teleportation sound effects.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<RandomTeleportEffect> MapCodec for serializing and deserializingRandomTeleportEffectinstances 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.static final StringJSON field key for the teleportation radius in blocks. -
Constructor Summary
ConstructorsConstructorDescriptionRandomTeleportEffect(net.minecraft.world.item.enchantment.LevelBasedValue range) Constructs an unfilteredRandomTeleportEffect.RandomTeleportEffect(net.minecraft.world.item.enchantment.LevelBasedValue range, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter) Creates an instance of aRandomTeleportEffectrecord class.RandomTeleportEffect(net.minecraft.world.item.enchantment.LevelBasedValue range, net.minecraft.advancements.critereon.ContextAwarePredicate entityFilter) Constructs aRandomTeleportEffectrestricted by the given entity predicate filter. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(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) Attempts up to 16 times to teleportvictimto a random valid coordinate withinrange()blocks viaLivingEntity.randomTeleport(double, double, double, boolean).com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.Optional<net.minecraft.advancements.critereon.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.net.minecraft.world.item.enchantment.LevelBasedValuerange()Returns the value of therangerecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
RANGE
JSON field key for the teleportation radius in blocks.- 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 deserializingRandomTeleportEffectinstances from JSON.
-
-
Constructor Details
-
RandomTeleportEffect
public RandomTeleportEffect(net.minecraft.world.item.enchantment.LevelBasedValue range) Constructs an unfilteredRandomTeleportEffect.- Parameters:
range- TheLevelBasedValueteleportation radius in blocks.
-
RandomTeleportEffect
public RandomTeleportEffect(net.minecraft.world.item.enchantment.LevelBasedValue range, net.minecraft.advancements.critereon.ContextAwarePredicate entityFilter) Constructs aRandomTeleportEffectrestricted by the given entity predicate filter.- Parameters:
range- TheLevelBasedValueteleportation radius in blocks.entityFilter- The predicate filter to match against candidate entities.
-
RandomTeleportEffect
public RandomTeleportEffect(net.minecraft.world.item.enchantment.LevelBasedValue range, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter) Creates an instance of aRandomTeleportEffectrecord class.- Parameters:
range- the value for therangerecord 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) Attempts up to 16 times to teleportvictimto a random valid coordinate withinrange()blocks viaLivingEntity.randomTeleport(double, double, double, boolean).- 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). -
range
public net.minecraft.world.item.enchantment.LevelBasedValue range()Returns the value of therangerecord component.- Returns:
- the value of the
rangerecord component
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-