How do i get my custom mob to drop items with lores and have 2 diffrent attributes? (Minecraft 1.16.4 java)
Im making a boss type of a mob in my server and i couldnt find how to make a mob drop items with lores and 2 attributes. ( i need an illusioner to drop a skeleton head that is named "skull of the chosen) has a lore (Potassium) and has attributes (8 max_health, 3.1 attack_damage)) pls help
Solution 1:
You can modify the mob's DeathLootTable
NBT to reference a custom loot table. Inside that loot table, you can then use the minecraft:set_attributes
, minecraft:set_name
and minecraft:set_lore
item modifiers to apply attribute modifiers and change the name and lore of the skull item.
Here's an example: let's say that you have a loot table named boss_mob.json
inside your data/example/loot_tables/entities
folder (you would refer to the loot table as example:entities/boss_mob
), and that your mob (in this case, an illusioner) has the example.boss_mob
tag (either added by the /tag
command or the Tags
NBT)
Here's how the setup would look like:
(the command to modify the DeathLootTable
NBT of all the entities that have the example.boss_mob
tag)
execute as @e[tag = example.boss_mob] run data modify entity @s DeathLootTable set value "example:entities/boss_mob"
(the contents of the data/example/loot_tables/entities/boss_mob.json
loot table)
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:skeleton_skull",
"functions": [
{
"function": "minecraft:set_attributes",
"modifiers": [
{
"attribute": "minecraft:generic.max_health",
"name": "",
"amount": 8,
"operation": "addition",
"slot": "head"
},
{
"attribute": "minecraft:generic.attack_damage",
"name": "",
"amount": 3.1,
"operation": "addition",
"slot": "head"
}
]
},
{
"function": "minecraft:set_name",
"name": {
"text": "Skull of the Chosen",
"italic": false
}
},
{
"function": "minecraft:set_lore",
"lore": [
{
"text": "Potassium",
"color": "gray",
"italic": false
}
]
}
]
}
]
}
]
}