Class ExplosionDecayFunction
java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootFunction
com.github.darksoulq.abyssallib.world.data.loot.function.ExplosionDecayFunction
A loot function that reduces the amount of items in a stack based on an explosion decay algorithm.
This function simulates the destruction of loot that occurs when a block is broken by an explosion, where each individual item in the stack has a probability of being "destroyed" and removed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Codec<ExplosionDecayFunction> The codec used for serializing and deserializing the explosion decay function.static final LootFunctionType<ExplosionDecayFunction> The registered type definition for this loot function. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.ItemStackapply(org.bukkit.inventory.ItemStack stack, LootContext context) Applies the explosion decay logic to the providedItemStack.getType()Retrieves the specific type definition for this loot function.
-
Field Details
-
CODEC
The codec used for serializing and deserializing the explosion decay function.Since this function maintains no state or configuration parameters, it decodes from and encodes to an empty map structure.
-
TYPE
The registered type definition for this loot function.
-
-
Constructor Details
-
ExplosionDecayFunction
public ExplosionDecayFunction()
-
-
Method Details
-
apply
public org.bukkit.inventory.ItemStack apply(org.bukkit.inventory.ItemStack stack, LootContext context) Applies the explosion decay logic to the providedItemStack.Each item in the original stack is subjected to a random roll against a decay threshold derived from the context's random source. Items that fail the roll are discarded, and the stack's final amount is updated to the remaining count.
* @param stack TheItemStackgenerated by the loot entry.- Specified by:
applyin classLootFunction- Parameters:
stack- TheItemStackto be modified.context- TheLootContextproviding the random source and environmental data.- Returns:
- The modified
ItemStackwith the updated (and potentially reduced) amount.
-
getType
Retrieves the specific type definition for this loot function. * @return TheLootFunctionTypeassociated withExplosionDecayFunction.- Specified by:
getTypein classLootFunction- Returns:
- The
LootFunctionTypeused for registry identification and serialization.
-