Loot Functions Custom Potion Effects - Tmtravlr/LootOverhaul GitHub Wiki

Loot Functions - Custom Potion Effects

Structure:

Property Type Description
potion Potion Object or Potion Object List List of potential potions effects to generate.
potion -> {} -> name String The name of the potion, like minecraft:night_vision.
potion -> {} -> duration Integer The duration of the potion. (Optional, defaults to 1)
potion -> {} -> amplifier Integer The amplifier, where 0 is level 1. (Optional, defaults to 0)
potion -> {} -> is_ambient Boolean If true, has faded particles. (Optional)
potion -> {} -> hide_particles Boolean If true, has no particles. (Optional)
number_to_generate Integer or Integer Range How many potions from the list to generate (Optional, defaults to 1)
replace String Optional string to replace in the nbt instead of generating a new tag. (Optional)

Description:

Adds custom potion effects to the item (potion, tipped arrow, etc.) More of a convenience, since modded potion ids change between worlds, and custom potions still use numerical ids for some reason.

Example Usage:

Adds an instant health 5 effect

"functions": [
 	{
 		"function": "lootoverhaul:custom_potion_effects",
 		"potion": {
         		"name": "minecraft:instant_health",
 			"amplifier": 4
 		}
 	}
]

Also can take a list of potions to choose randomly between. Will add either a strength or swiftness effect to a potion for 30 seconds with no particles:

"functions": [
 	{
 		"function": "lootoverhaul:custom_potion_effects",
 		"potion": [
 			{
 				"name": "minecraft:strength",
				"duration": 600,
				"hide_particles": true
			},
         		{
 				"name": "minecraft:speed",
				"duration": 600,
				"hide_particles": true
			}
		]
 	}
]

If you add number_to_generate, it will randomly choose that number of potions from the list:

"functions": [
 	{
 		"function": "lootoverhaul:custom_potion_effects",
 		"potion": [
 			{
 				"name": "minecraft:wither",
        	 		"duration": {
					"min": 1000,
					"max": 3000
				}
 			},
 			{
 				"name": "minecraft:poison",
        	 		"duration": {
					"min": 1000,
					"max": 3000
				}
 			},
 			{
 				"name": "minecraft:hunger",
        	 		"duration": {
					"min": 1000,
					"max": 3000
				}
 			},
 			{
 				"name": "minecraft:blindness",
        	 		"duration": {
					"min": 1000,
					"max": 3000
				}
 			},
 			{
 				"name": "minecraft:instant_damage",
 				"duration": 1,
 				"amplifier": {
 					"min": 0,
 					"max": 3
 				}
 			}
		],
		"number_to_generate": {
			"min": 2,
			"max": 5
		}
 	}
]

If replace is set, instead of generating a new potion effect tag, it will try replacing the given string in the nbt tag with a potion effect tag. Example: Creating an area effect cloud with effects (assuming the item is lootoverhaul:loot_entity)

"functions": [
	{
		"function": "set_nbt",
		"tag": "{EntityTag:{id:\"minecraft:area_effect_cloud\", Duration:40, RadiusPerTick:0.01, Effects:\"#GeneratedEffects\"}}"
	},
	{
 		"function": "lootoverhaul:custom_potion_effects",
 		"potion": [
 			{
 				"name": "minecraft:regeneration",
        	 		"duration": {
					"min": 60,
					"max": 200
				}
 			},
 			{
 				"name": "minecraft:absorption",
        	 		"duration": {
					"min": 1200,
					"max": 4000
				}
 			},
 			{
 				"name": "minecraft:saturation",
 				"amplifier": 5,
 				"duration": 1
 			}
		],
		"number_to_generate": 2,
		"replace": "\"#GeneratedEffects\""
 	}
]
No Previous Back Next - Enchantments