Record Class ExplosionEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.ExplosionEffect
Record Components:
chance - The LevelBasedValue governing the probability (0.0 to 1.0) of triggering the explosion.
explosion - The ExplosionDefinition specifying 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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JSON field key for the explosion trigger probability.
    static final com.mojang.serialization.MapCodec<ExplosionEffect>
    MapCodec for serializing and deserializing ExplosionEffect instances from JSON.
    static final String
    JSON field key for the nested explosion definition object.
    static final String
    Registry path identifier for this effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation, combining CHANCE with the keys of ExplosionDefinition.KEY_PROVIDER.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExplosionEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, ExplosionDefinition explosion)
    Creates an instance of a ExplosionEffect record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    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 at origin.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the chance record component.
    com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect>
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the explosion record component.
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect

    onChangedBlock

    Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

    onDeactivated
  • Field Details

  • Constructor Details

    • ExplosionEffect

      public ExplosionEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, ExplosionDefinition explosion)
      Creates an instance of a ExplosionEffect record class.
      Parameters:
      chance - the value for the chance record component
      explosion - the value for the explosion record component
  • 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 at origin.
      Specified by:
      apply in interface net.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:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Specified by:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • chance

      public net.minecraft.world.item.enchantment.LevelBasedValue chance()
      Returns the value of the chance record component.
      Returns:
      the value of the chance record component
    • explosion

      public ExplosionDefinition explosion()
      Returns the value of the explosion record component.
      Returns:
      the value of the explosion record component