Class LootFunction
java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootFunction
- Direct Known Subclasses:
EnchantRandomlyFunction, ExplosionDecayFunction, FurnaceSmeltFunction, LimitCountFunction, LootingEnchantFunction, SetCountFunction, SetDamageFunction, SetLoreFunction, SetNameFunction
An abstract base class for functions that modify an
ItemStack generated by a loot table.
Functions are applied sequentially to a loot entry. Common uses include setting item amounts, applying enchantments, or modifying display names.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Codec<LootFunction> Polymorphic codec for serializing and deserializing loot functions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.bukkit.inventory.ItemStackapply(org.bukkit.inventory.ItemStack stack, LootContext context) Applies this function's logic to the provided item stack.abstract LootFunctionType<?> getType()Retrieves the specific type definition associated with this function.
-
Field Details
-
CODEC
Polymorphic codec for serializing and deserializing loot functions.Decodes the function by looking up the "type" field in the
Registries.LOOT_FUNCTIONSand delegating the rest of the object to that specific type's codec.
-
-
Constructor Details
-
LootFunction
public LootFunction()
-
-
Method Details
-
apply
public abstract org.bukkit.inventory.ItemStack apply(org.bukkit.inventory.ItemStack stack, LootContext context) Applies this function's logic to the provided item stack.- Parameters:
stack- TheItemStackto be modified.context- TheLootContextproviding environmental data for the application.- Returns:
- The resulting modified
ItemStack.
-
getType
Retrieves the specific type definition associated with this function.- Returns:
- The
LootFunctionTypeused for registry identification and serialization.
-