Record Class BonusLootEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.BonusLootEffect
- Record Components:
chance- TheLevelBasedValuegoverning the probability (0.0 to 1.0) of triggering bonus loot.targetBlocks- TheHolderSetof blocks eligible to trigger this bonus loot effect when broken.rewardItems- The pool of candidateItems 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
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the drop trigger probability.static final com.mojang.serialization.Codec<BonusLootEffect> Codec for serializing and deserializingBonusLootEffectinstances from JSON.static final StringRegistry path identifier for this effect component.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation.static final StringJSON field key for toggling bonus experience drops.static final StringJSON field key for the reward item pool.static final StringJSON field key for the eligible target blocks set. -
Constructor Summary
ConstructorsConstructorDescriptionBonusLootEffect(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 aBonusLootEffectrecord class. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.enchantment.LevelBasedValuechance()Returns the value of thechancerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns the value of therewardExperiencerecord component.net.minecraft.core.HolderSet<net.minecraft.world.item.Item> Returns the value of therewardItemsrecord component.net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> Returns the value of thetargetBlocksrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CHANCE
-
TARGET_BLOCKS
JSON field key for the eligible target blocks set.- See Also:
-
REWARD_ITEMS
-
REWARD_EXPERIENCE
JSON field key for toggling bonus experience drops.- See Also:
-
KEY
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
Codec for serializing and deserializingBonusLootEffectinstances 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 aBonusLootEffectrecord class.- Parameters:
chance- the value for thechancerecord componenttargetBlocks- the value for thetargetBlocksrecord componentrewardItems- the value for therewardItemsrecord componentrewardExperience- the value for therewardExperiencerecord component
-
-
Method Details
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
chance
-
targetBlocks
public net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks()Returns the value of thetargetBlocksrecord component.- Returns:
- the value of the
targetBlocksrecord component
-
rewardItems
public net.minecraft.core.HolderSet<net.minecraft.world.item.Item> rewardItems()Returns the value of therewardItemsrecord component.- Returns:
- the value of the
rewardItemsrecord component
-
rewardExperience
public boolean rewardExperience()Returns the value of therewardExperiencerecord component.- Returns:
- the value of the
rewardExperiencerecord component
-