Loot Functions Replace NBT - Tmtravlr/LootOverhaul GitHub Wiki

Loot Functions - Replace NBT

Structure:

Property Type Description
replace String String to replace in the nbt tag.
range Float or Float Range or Integer or Integer Range Possible numbers to replace with (integers or floats). (Optional)
list String or String List Possible strings to replace with. (Optional)
name String Entity target to find the name of, valid options are entity selector (like @p), THIS, KILLER, KILLER_PLAYER, LOOTER. (Optional, defaults to THIS)
uuid String Entity target to find the string uuid of, valid options are entity selector (like @p), THIS, KILLER, KILLER_PLAYER, LOOTER. (Optional, defaults to THIS)
uuid_least String Entity target to find the uuid least of, valid options are entity selector (like @p), THIS, KILLER, KILLER_PLAYER, LOOTER. (Optional, defaults to THIS)
uuid_most String Entity target to find the uuid most of, valid options are entity selector (like @p), THIS, KILLER, KILLER_PLAYER, LOOTER. (Optional, defaults to THIS)
target String Entity target for properties below, valid options are entity selector (like @p), THIS, KILLER, KILLER_PLAYER, LOOTER. (Optional, defaults to THIS)
score String Name of scoreboard score. (Optional)
entity_variable String Name of entity variable. (Optional)
global_variable String Name of global variable. (Optional)

Description:

Replaces the given 'replace' string in the item's nbt tag with one of several options:

  • list - picks a random string in a list
  • range - picks a random integer or float in a range
  • name - name of an entity type
  • uuid - gives a uuid for commands for an entity type
  • uuid least - gives a uuid least long (for nbt tags that need it) for an entity type
  • uuid most - gives a uuid most long (for nbt tags that need it) for an entity type
  • scoreboard - scoreboard value for an entity type with target
  • entity variable - entity variable of the given name for an entity type with target
  • global variable - global variable of the given name

NOTE: If you are using these in commands, the uuid works perfectly! For both entities and players.

Example Usage:

List: Will drop an item with the name 'Eat me, I'm a ' and a random fruit name.

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{display:{Name:\"Eat me, I'm a #Fruit\"}}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#Fruit",
 		"list": [
 			"Banana",
 			"Kiwi",
 			"Watermelon"
 		]
 	}
]

Range: Will drop a randomly colored piece of leather armor.

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{display:{Name:\"Randomly Colored Leather Helmet\",color:\"#RandomColor\"}}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "\"#RandomColor\"",
 		"range": {
 			"min": 0,
 			"max": 16777215
 		}
 	}
]

Command: Will name an item based on the nearest player (works even if the loot isn't activated by a player)

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{display:{Name:\"#NearestPlayer's Stolen Diamond Sword\"}}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#NearestPlayer",
 		"name": "@p"
 	}
]

Name: Will name an item based on the entity's name that dropped it.

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{display:{Name:\"#EntityName's Epic Treasure\"}}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#EntityName",
 		"name": "this"
 	}
]

Selector: If the item is the "lootoverhaul:loot_command" item, runs a command to give the killer of this entity poison for 30 seconds (assuming there is a valid killer).

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{Command:\"effect #EntityName poison 30\"}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#EntityName",
 		"uuid": "killer"
 	}
]

Scoreboard: If the item is the "lootoverhaul:loot_command" item, gives the killer a strength buff that increases duration with each kill.

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{Command:\"effect #killer minecraft:strength #killCount\"}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#killer",
 		"uuid": "killer"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#killCount",
 		"target": "killer",
 		"scoreboard": "killCount"
 	}
]

Entity Variable: If the killer has the variable has_killed_wither set to true, tells everyone.

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{Command:\"say Has #killer killed the wither? #hasKilledWither\"}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#killer",
 		"name": "killer"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#hasKilledWither",
 		"target": "killer",
 		"entity_variable": "has_killed_wither"
 	}
]

Global Variable: If the world has the variable wither_has_died set to true, tells everyone.

"functions": [
 	{
 		"function": "set_nbt",
 		"tag": "{Command:\"say Has the wither died? #witherHasDied\"}"
 	},
 	{
 		"function": "lootoverhaul:replace_nbt",
 		"replace": "#witherHasDied",
 		"global_variable": "wither_has_died"
 	}
]
Previous - Function Group Back Next - Fortune Enchant
⚠️ **GitHub.com Fallback** ⚠️