Record Class BonusLootEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.BonusLootEffect
Record Components:
chance - The LevelBasedValue governing the probability (0.0 to 1.0) of triggering bonus loot.
targetBlocks - The HolderSet of blocks eligible to trigger this bonus loot effect when broken.
rewardItems - The pool of candidate Items from which a random bonus drop is selected.
rewardExperience - Whether triggering bonus loot also awards a small amount of experience.

public record BonusLootEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks, net.minecraft.core.HolderSet<net.minecraft.world.item.Item> rewardItems, boolean rewardExperience) extends Record
Data-driven enchantment effect component that grants a probability to roll bonus item drops and experience orbs when breaking blocks matching a specified HolderSet.

Evaluated during block drop generation in EnchantmentEventsMixin, where bonus item quantities also scale with the tool's Fortune level if present.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JSON field key for the drop trigger probability.
    static final com.mojang.serialization.Codec<BonusLootEffect>
    Codec for serializing and deserializing BonusLootEffect instances from JSON.
    static final String
    Registry path identifier for this effect component.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for toggling bonus experience drops.
    static final String
    JSON field key for the reward item pool.
    static final String
    JSON field key for the eligible target blocks set.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BonusLootEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks, net.minecraft.core.HolderSet<net.minecraft.world.item.Item> rewardItems, boolean rewardExperience)
    Creates an instance of a BonusLootEffect record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the chance record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the rewardExperience record component.
    net.minecraft.core.HolderSet<net.minecraft.world.item.Item>
    Returns the value of the rewardItems record component.
    net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>
    Returns the value of the targetBlocks record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CHANCE

      public static final String CHANCE
      JSON field key for the drop trigger probability.
      See Also:
    • TARGET_BLOCKS

      public static final String TARGET_BLOCKS
      JSON field key for the eligible target blocks set.
      See Also:
    • REWARD_ITEMS

      public static final String REWARD_ITEMS
      JSON field key for the reward item pool.
      See Also:
    • REWARD_EXPERIENCE

      public static final String REWARD_EXPERIENCE
      JSON field key for toggling bonus experience drops.
      See Also:
    • KEY

      public static final String KEY
      Registry path identifier for this effect component.
      See Also:
    • KEY_PROVIDER

      public static final LevelBasedKeyProvider KEY_PROVIDER
      Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    • CODEC

      public static final com.mojang.serialization.Codec<BonusLootEffect> CODEC
      Codec for serializing and deserializing BonusLootEffect instances from JSON.
  • Constructor Details

    • BonusLootEffect

      public BonusLootEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance, net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks, net.minecraft.core.HolderSet<net.minecraft.world.item.Item> rewardItems, boolean rewardExperience)
      Creates an instance of a BonusLootEffect record class.
      Parameters:
      chance - the value for the chance record component
      targetBlocks - the value for the targetBlocks record component
      rewardItems - the value for the rewardItems record component
      rewardExperience - the value for the rewardExperience record component
  • Method Details

    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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
    • targetBlocks

      public net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks()
      Returns the value of the targetBlocks record component.
      Returns:
      the value of the targetBlocks record component
    • rewardItems

      public net.minecraft.core.HolderSet<net.minecraft.world.item.Item> rewardItems()
      Returns the value of the rewardItems record component.
      Returns:
      the value of the rewardItems record component
    • rewardExperience

      public boolean rewardExperience()
      Returns the value of the rewardExperience record component.
      Returns:
      the value of the rewardExperience record component