Class FurnaceSmeltFunction

java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootFunction
com.github.darksoulq.abyssallib.world.data.loot.function.FurnaceSmeltFunction

public class FurnaceSmeltFunction extends LootFunction
A loot function that attempts to smelt the generated item stack.

This function iterates through the server's recipe registry to find a FurnaceRecipe that accepts the current item as an input. If a match is found, the item is replaced with the smelting result while maintaining the original stack size.

  • Field Details

    • CODEC

      public static final Codec<FurnaceSmeltFunction> CODEC
      The codec used for serializing and deserializing the furnace smelt function.

      As this function logic is procedural and carries no unique configuration state, it encodes to and decodes from an empty map structure.

    • TYPE

      public static final LootFunctionType<FurnaceSmeltFunction> TYPE
      The registered type definition for the furnace smelt loot function.
  • Constructor Details

    • FurnaceSmeltFunction

      public FurnaceSmeltFunction()
  • Method Details

    • apply

      public org.bukkit.inventory.ItemStack apply(org.bukkit.inventory.ItemStack stack, LootContext context)
      Applies the smelting transformation to the generated ItemStack.

      Scans the global Bukkit.recipeIterator() for a FurnaceRecipe. If the input material of a recipe matches the material of the provided stack, the stack is transformed into the recipe result.

      * @param stack The ItemStack generated by the loot entry.
      Specified by:
      apply in class LootFunction
      Parameters:
      stack - The ItemStack to be modified.
      context - The LootContext providing environmental data.
      Returns:
      The smelted ItemStack if a recipe exists; otherwise, the original stack.
    • getType

      public LootFunctionType<?> getType()
      Retrieves the specific type definition for this loot function. * @return The LootFunctionType associated with FurnaceSmeltFunction.
      Specified by:
      getType in class LootFunction
      Returns:
      The LootFunctionType used for registry identification and serialization.