
記錄附魔的等級│Records the Level of Enchantments
For Players
If you're using a data pack that requires this data pack as a dependency, simply add it to your world's data pack folder.
For Data Pack Creators
This data pack provides useful functions for working with enchantments in your own modifications:
Looting Enchantment: The level of the Looting enchantment on the item in the mob's main hand is stored in the scoreboard objective looting_level
. If there's no item with this enchantment in the main hand, the value will be 0.
Fortune Enchantment: The level of the Fortune enchantment on the item in the mob's main hand is recorded in the scoreboard objective fortune_level
. When there's no corresponding enchanted item, the value will also be 0.
Usage Example
Here's how you can apply this data in loot tables:
{
"type": "minecraft:entity",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:tag",
"expand":true,
"name": "minecraft:bee_loot"
}
],
"rolls": {
"type":"minecraft:uniform",
"min":0,
"max":2
}
},
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:tag",
"expand":true,
"name": "minecraft:bee_loot"
}
],
"rolls": {
"type":"minecraft:uniform",
"min":0,
"max":{
"type":"score",
"target":"attacker",
"score":"looting_level"
}
}
}
],
"random_sequence": "minecraft:entities/bee"
}
In this example from my data pack, the second loot pool is configured so that the maximum number of item drops depends on the Looting enchantment level on the attacker's weapon. The minimum value is set to 0, while the maximum corresponds to the looting_level
score of the attacking mob.