Record Class ExplosionEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.ExplosionEffect
- Record Components:
chance- TheLevelBasedValuegoverning the probability (0.0 to 1.0) of triggering the explosion.explosion- TheExplosionDefinitionspecifying radius, block interaction, fire, and particle parameters.
- All Implemented Interfaces:
net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect, net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
public record ExplosionEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, ExplosionDefinition explosion)
extends Record
implements net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect, net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
Dual-purpose enchantment effect implementing both
EnchantmentEntityEffect and
EnchantmentLocationBasedEffect that triggers an explosion defined by an ExplosionDefinition
when a random roll succeeds against chance().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the explosion trigger probability.static final com.mojang.serialization.MapCodec<ExplosionEffect> MapCodec for serializing and deserializingExplosionEffectinstances from JSON.static final StringJSON field key for the nested explosion definition object.static final StringRegistry path identifier for this effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation, combiningCHANCEwith the keys ofExplosionDefinition.KEY_PROVIDER. -
Constructor Summary
ConstructorsConstructorDescriptionExplosionEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, ExplosionDefinition explosion) Creates an instance of aExplosionEffectrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse item, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 origin) Evaluates the trigger probability and detonates the configured explosion atorigin.net.minecraft.world.item.enchantment.LevelBasedValuechance()Returns the value of thechancerecord component.com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect> codec()final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexplosionrecord component.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
onChangedBlockMethods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
onDeactivated
-
Field Details
-
CHANCE
-
EXPLOSION
JSON field key for the nested explosion definition object.- See Also:
-
KEY
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation, combiningCHANCEwith the keys ofExplosionDefinition.KEY_PROVIDER. -
CODEC
MapCodec for serializing and deserializingExplosionEffectinstances from JSON.
-
-
Constructor Details
-
ExplosionEffect
public ExplosionEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, ExplosionDefinition explosion) Creates an instance of aExplosionEffectrecord class.
-
-
Method Details
-
apply
public void apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse item, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 origin) Evaluates the trigger probability and detonates the configured explosion atorigin.- Specified by:
applyin interfacenet.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect- Parameters:
level- The server level in which the effect is triggered.enchantmentLevel- The level of the source enchantment.item- The context of the enchanted item in use.entity- The target or context entity.origin- The world coordinate where the explosion is centered.
-
codec
public com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect> codec()- Specified by:
codecin interfacenet.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect- Specified by:
codecin interfacenet.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
-
toString
-
hashCode
-
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). -
chance
-
explosion
-