-
Notifications
You must be signed in to change notification settings - Fork 5
Name Enchanted Item
Commoble edited this page Nov 19, 2020
·
4 revisions
The looot:name_enchanted_item
function randomly generates a name for an enchanted itemstack and applies the name to the itemstack.
If the given itemstack has no enchantments, then no name is generated or applied.
If the given itemstack has one or two enchantments, a name is generated from the enchantments on the item, with cyan text.
If the given itemstack has three or more enchantments, a name is generated randomly from words defined in nameword datapacks, with purple text.
Custom text formats are also supported:
This loot function can be used in a standard loot table function block:
{
"function": "looot:name_enchanted_item", // tells the loot table loader which function this is
"ignore_enchantments": boolean, // optional field, defaults to false
"minor_style": {Formatting}, // optional field, sets the style of 1-2 enchantment names, or defaults to light blue text if not present
"major_style": {Formatting}, // optional field, sets the style of 3+ enchantment names, or defaults to light purple text if not present
}
Where
- If "ignore_enchantments" is true, the item will receive an "epic name" even if the item has fewer than three enchantments or is unenchanted
- "minor_style" and "major_style" are formatting objects
- Further documentation on loot table jsons and loot table functions can be found on the minecraft wiki
An example of a full loot table json that uses this function:
{
"type": "minecraft:block",
"pools":
[
{
"rolls": 1,
"entries":
[
{
"type": "minecraft:loot_table",
"name": "loootexamplemod:subtables/weapons",
"functions":
[
{
"function": "minecraft:enchant_with_levels",
"levels":
{
"min": 1.0,
"max": 50.0,
"type": "minecraft:uniform"
},
"treasure": true
},
{
"function": "looot:name_enchanted_item",
"minor_style":
{
"color": "red",
"bold": true,
"italic": true,
"underlined": true
},
"major_style":
{
"color": "#c7b989",
"font": "minecraft:alt"
}
}
]
}
]
}
]
}