Class SetLoreFunction
java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootFunction
com.github.darksoulq.abyssallib.world.data.loot.function.SetLoreFunction
A loot function that overrides the lore (description) of a generated item.
This function utilizes Adventure Components to support modern text formatting,
including RGB colors, gradients, and translatable strings. The lore is applied via
the DataComponentTypes.LORE data component.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Codec<SetLoreFunction> The codec used for serializing and deserializing the set lore function.static final LootFunctionType<SetLoreFunction> The registered type definition for the set lore loot function. -
Constructor Summary
ConstructorsConstructorDescriptionSetLoreFunction(List<net.kyori.adventure.text.Component> lore) Constructs a new SetLoreFunction with the specified lore lines. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.ItemStackapply(org.bukkit.inventory.ItemStack stack, LootContext context) Applies the configured lore to the providedItemStack.getType()Retrieves the specific type definition for this loot function.
-
Field Details
-
CODEC
The codec used for serializing and deserializing the set lore function.It expects a "lore" field containing a list of serialized text components.
-
TYPE
The registered type definition for the set lore loot function.
-
-
Constructor Details
-
SetLoreFunction
-
-
Method Details
-
apply
public org.bukkit.inventory.ItemStack apply(org.bukkit.inventory.ItemStack stack, LootContext context) Applies the configured lore to the providedItemStack.This method wraps the component list into an
ItemLoreinstance and sets it as the item's lore data component.- Specified by:
applyin classLootFunction- Parameters:
stack- TheItemStackgenerated by the loot entry.context- TheLootContextproviding environmental data.- Returns:
- The modified
ItemStackwith the new lore applied.
-
getType
Retrieves the specific type definition for this loot function.- Specified by:
getTypein classLootFunction- Returns:
- The
LootFunctionTypeassociated withSetLoreFunction.
-