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

public abstract class LootFunction extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final Codec<LootFunction>
    Polymorphic codec for serializing and deserializing loot functions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.bukkit.inventory.ItemStack
    apply(org.bukkit.inventory.ItemStack stack, LootContext context)
    Applies this function's logic to the provided item stack.
    abstract LootFunctionType<?>
    Retrieves the specific type definition associated with this function.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CODEC

      public static final Codec<LootFunction> CODEC
      Polymorphic codec for serializing and deserializing loot functions.

      Decodes the function by looking up the "type" field in the Registries.LOOT_FUNCTIONS and 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 - The ItemStack to be modified.
      context - The LootContext providing environmental data for the application.
      Returns:
      The resulting modified ItemStack.
    • getType

      public abstract LootFunctionType<?> getType()
      Retrieves the specific type definition associated with this function.
      Returns:
      The LootFunctionType used for registry identification and serialization.