//SERVER

onEvent('recipes', event => {

	event.remove({ id: 'farmersdelight:wheat_dough' })
	event.remove({ id: 'farmersdelight:bread_from_smelting' })
	event.remove({ id: 'farmersdelight:bread_from_smoking' })
	event.remove({ id: 'quark:oddities/crafting/backpack' })
	event.remove({ id: 'magicfeather:magicfeather' })
	event.remove({ output: Item.of('patchouli:guide_book', '{"patchouli:book":"twilightforest:guide"}')})
	event.remove({ id: 'alexsmobs:tarantula_hawk_elytra' })
	event.remove({ id: 'comforts:rope_and_nail' })
	event.remove({ id: 'naturescompass:natures_compass' })
	event.remove({ id: 'moreminecarts:hard_light_lens_emerald' })
	event.remove({ id: 'create:crafting/logistics/redstone_link' })

	//pipe recipe
	event.remove({ id: 'quark:oddities/crafting/pipe' })
	event.shaped('6x quark:pipe', [
		' C ',
		'LGL',
		' C '
	], {
		C: 'minecraft:copper_ingot',
		G: '#forge:glass',
		L: 'moreminecarts:levitation_powder'
	})

	//backpack recipe
	event.remove({ id: 'backpacked:backpack' })
	event.shaped('backpacked:backpack', [
		' H ',
		'RCR',
		' I '
	], {
		H: 'quark:ravager_hide',
		C: '#forge:chests/wooden',
		R: 'minecraft:rabbit_hide',
		I: 'minecraft:iron_ingot'
	})

	//pumpkin pie recipe
	event.remove({ id: 'minecraft:pumpkin_pie' })
	event.shaped('minecraft:pumpkin_pie', [
		'   ',
		'EPS',
		' C '
	], {
		P: 'minecraft:pumpkin',
		S: 'minecraft:sugar',
		E: 'minecraft:egg',
		C: 'farmersdelight:pie_crust'
	})

	//eggnog recipe
	event.remove({ id: 'snowyspirit:eggnog' })
	event.shapeless('snowyspirit:eggnog', ['snowyspirit:ginger', 'minecraft:egg', 'farmersdelight:milk_bottle'])

	//drill recipe
	event.remove({ id: 'create:crafting/kinetics/mechanical_drill' })
	event.shaped('create:mechanical_drill', [
		' S ',
		'SIS',
		' C '
	], {
		C: 'create:andesite_casing',
		I: 'alloyed:steel_ingot',
		S: 'minecraft:iron_ingot'
	})


	//saw recipe
	event.remove({ id: 'create:crafting/kinetics/mechanical_saw' })
	event.shaped('create:mechanical_saw', [
		' S ',
		'SIS',
		' C '
	], {
		C: 'create:andesite_casing',
		I: 'alloyed:steel_ingot',
		S: 'create:iron_sheet'
	})

	//copper nugget consolidation
	event.remove({ id: 'copperized:copper_nugget' })
	event.remove({ id: 'copperized:copper_ingot_from_nuggets' })
	event.remove({ id: 'copperized:copper_nugget_from_blasting' })
	event.remove({ id: 'copperized:copper_nugget_from_smelting' })

	let multiSmelt = (output, input, includeBlasting) => {
		event.smelting(output, input)
		
		if (includeBlasting) {
			event.blasting(output, input)
		}
	}

	multiSmelt('create:copper_nugget', 'copperized:copper_helmet', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_chestplate', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_leggings', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_boots', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_sword', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_pickaxe', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_axe', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_hoe', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_shovel', true)
	multiSmelt('create:copper_nugget', 'copperized:copper_horse_armor', true)

	//enchanted golden apple
	event.shapeless('minecraft:enchanted_golden_apple', ['overweight_farming:overweight_golden_apple_block', 'quark:diamond_heart', 'minecraft:heart_of_the_sea'])

	//matrix enchanting table
	event.shapeless('quark:matrix_enchanter', ['minecraft:enchanting_table'])
	event.shapeless('minecraft:enchanting_table', ['quark:matrix_enchanter'])

	//cobble from deepslate
	event.recipes.createCrushing(['2x minecraft:cobblestone'], 'minecraft:deepslate')
	event.recipes.createCrushing(['2x minecraft:cobblestone'], 'minecraft:cobbled_deepslate')

	//netherite rework
	event.remove({ id: 'minecraft:netherite_ingot' })
	event.recipes.createCrushing(['minecraft:netherite_scrap'], 'minecraft:ancient_debris')
	event.recipes.createMixing('minecraft:netherite_ingot', ['4x minecraft:netherite_scrap', '2x alloyed:bronze_ingot', 'minecraft:gold_ingot']).superheated()

	//silica steel rework
	event.remove({ id: 'moreminecarts:silica_steel_mix' })
	event.remove({ id: 'moreminecarts:silica_steel_blasting' })
	event.remove({ id: 'moreminecarts:silica_steel_smelting' })
	event.remove({ id: 'moreminecarts:create/silica_steel_mixing' })
	event.recipes.createMixing('moreminecarts:silica_steel', ['alloyed:steel_ingot', '3x minecraft:quartz']).superheated()

	//cheaper chains
	event.remove({ id: 'minecraft:chain' })
	event.shaped('minecraft:chain', [
		'N',
		'N',
		'N'
	], {
		N: 'minecraft:iron_nugget'
	})

	//chainmail armor set
	event.shaped('minecraft:chainmail_helmet', [
		'CCC',
		'C C'
	], {
		C: 'minecraft:chain'
	})

	event.shaped('minecraft:chainmail_chestplate', [
		'C C',
		'CCC',
		'CCC'
	], {
		C: 'minecraft:chain'
	})

	event.shaped('minecraft:chainmail_leggings', [
		'CCC',
		'C C',
		'C C'
	], {
		C: 'minecraft:chain'
	})

	event.shaped('minecraft:chainmail_boots', [
		'C C',
		'C C'
	], {
		C: 'minecraft:chain'
	})

	//milling lubricant
	event.recipes.createMilling([ 'moreminecarts:levitation_powder', Item.of('moreminecarts:levitation_powder').withChance(0.5) ], 'minecraft:phantom_membrane')
	event.recipes.createMilling(Item.of('moreminecarts:levitation_powder').withChance(0.12) , 'minecraft:popped_chorus_fruit')
	event.recipes.createMilling('20x moreminecarts:levitation_powder', 'minecraft:shulker_shell')

	//adds supplementaries soap compatibility to an item 
	const colors = ['white', 'orange', 'magenta', 'light_blue', 'yellow', 'lime', 'pink', 'gray', 'light_gray', 'cyan', 'purple', 'blue', 'brown', 'green', 'red', 'black']
	let soapWash = (mod_id, item_id_minus_color, default_color, color_is_suffix) => {
		for (let i = 0, len = colors.length; i < len; i++) {
			if (colors[i] != default_color && color_is_suffix) {

				event.shapeless(mod_id + ':' + item_id_minus_color + '_' + default_color, [mod_id + ':' + item_id_minus_color + '_' + colors[i], 'supplementaries:soap'])

			} else if (colors[i] != default_color && !color_is_suffix) {

				event.shapeless(mod_id + ':' + default_color + '_' + item_id_minus_color, [mod_id + ':' + colors[i] + '_' + item_id_minus_color, 'supplementaries:soap'])

			}
		}
	}

	soapWash('create', 'toolbox', 'brown', false)  //default item is called create:brown_toolbox, so color_is_suffix = false
	soapWash('comforts', 'sleeping_bag', 'white', true) //default item is called comforts:sleeping_bag_white, so color_is_suffix = true
	soapWash('comforts', 'hammock', 'white', true) //default item is called comforts:hammock_white, so color_is_suffix = true


	//add create compacting recipes for turning slabs back into blocks
	event.forEachRecipe({type: 'minecraft:crafting_shaped', output: '#minecraft:slabs' }, r => {
		var slab = r.outputItems[0]
		var block = r.inputItems[0]
				
		event.remove({output: block, input: slab})
		event.custom({
			type: "create:compacting",
			ingredients: [Ingredient.of(slab, 2).toJson()],
			results: [Item.of(block, 1).toResultJson()]
		})
	})


	//add create cutting recipes to turn blocks into slabs
	// event.forEachRecipe({type: 'minecraft:crafting_shaped', output: '#minecraft:wooden_slabs' }, r => {
	// 	var slab = r.outputItems[0]
	// 	var block = r.inputItems[0]
				
	// 	event.custom({
	// 		type: "create:cutting",
	// 		ingredients: [Item.of(block, 1).toResultJson()],
	// 		results: [Ingredient.of(slab, 2).toJson()]
	// 	})
	// })

	//remove ingot smelting
	event.remove({ id: 'minecraft:iron_ingot_from_blasting_raw_iron' })
	event.remove({ id: 'minecraft:iron_ingot_from_blasting_deepslate_iron_ore' })
	event.remove({ id: 'minecraft:iron_ingot_from_blasting_iron_ore' })
	event.remove({ id: 'minecraft:iron_ingot_from_smelting_raw_iron' })
	event.remove({ id: 'minecraft:iron_ingot_from_smelting_deepslate_iron_ore' })
	event.remove({ id: 'minecraft:iron_ingot_from_smelting_iron_ore' })
	event.remove({ id: 'create:blasting/iron_ingot_from_crushed' })
	event.remove({ id: 'create:smelting/iron_ingot_from_crushed' })
	event.remove({ id: 'minecraft:copper_ingot_from_blasting_raw_copper' })
	event.remove({ id: 'minecraft:copper_ingot_from_blasting_deepslate_copper_ore' })
	event.remove({ id: 'minecraft:copper_ingot_from_blasting_copper_ore' })
	event.remove({ id: 'minecraft:copper_ingot_from_smelting_raw_copper' })
	event.remove({ id: 'minecraft:copper_ingot_from_smelting_deepslate_copper_ore' })
	event.remove({ id: 'minecraft:copper_ingot_from_smelting_copper_ore' })
	event.remove({ id: 'create:blasting/copper_ingot_from_crushed' })
	event.remove({ id: 'create:smelting/copper_ingot_from_crushed' })
	event.remove({ id: 'minecraft:gold_ingot_from_blasting_raw_gold' })
	event.remove({ id: 'minecraft:gold_ingot_from_blasting_nether_gold_ore' })
	event.remove({ id: 'minecraft:gold_ingot_from_blasting_deepslate_gold_ore' })
	event.remove({ id: 'minecraft:gold_ingot_from_blasting_gold_ore' })
	event.remove({ id: 'minecraft:gold_ingot_from_smelting_raw_gold' })
	event.remove({ id: 'minecraft:gold_ingot_from_smelting_nether_gold_ore' })
	event.remove({ id: 'minecraft:gold_ingot_from_smelting_deepslate_gold_ore' })
	event.remove({ id: 'minecraft:gold_ingot_from_smelting_gold_ore' })
	event.remove({ id: 'create:blasting/gold_ingot_from_crushed' })
	event.remove({ id: 'create:smelting/gold_ingot_from_crushed' })
	event.remove({ id: 'create:blasting/zinc_ingot_from_raw_ore' })
	event.remove({ id: 'create:blasting/zinc_ingot_from_ore' })
	event.remove({ id: 'create:smelting/zinc_ingot_from_raw_ore' })
	event.remove({ id: 'create:smelting/zinc_ingot_from_ore' })
	event.remove({ id: 'create:blasting/zinc_ingot_from_crushed' })
	event.remove({ id: 'create:smelting/zinc_ingot_from_crushed' })
	
	//add ore block milling recipes
	event.recipes.createMilling(['minecraft:raw_iron', Item.of('minecraft:raw_iron').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'minecraft:iron_ore')
	event.recipes.createMilling(['minecraft:raw_iron', Item.of('minecraft:raw_iron').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'minecraft:deepslate_iron_ore')
	event.recipes.createMilling(['minecraft:raw_copper', Item.of('minecraft:raw_copper').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'minecraft:copper_ore')
	event.recipes.createMilling(['minecraft:raw_copper', Item.of('minecraft:raw_copper').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'minecraft:deepslate_copper_ore')
	event.recipes.createMilling(['minecraft:raw_gold', Item.of('minecraft:raw_gold').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'minecraft:gold_ore')
	event.recipes.createMilling(['minecraft:raw_gold', Item.of('minecraft:raw_gold').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'minecraft:deepslate_gold_ore')
	event.recipes.createMilling(['create:raw_zinc', Item.of('create:raw_zinc').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'create:zinc_ore')
	event.recipes.createMilling(['create:raw_zinc', Item.of('create:raw_zinc').withChance(0.5), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'create:deepslate_zinc_ore') 

	//overhaul crushing recipes
	event.remove({ id: 'create:crushing/iron_ore' })
	event.remove({ id: 'create:crushing/deepslate_iron_ore' })
	event.remove({ id: 'create:crushing/copper_ore' })
	event.remove({ id: 'create:crushing/deepslate_copper_ore' })
	event.remove({ id: 'create:crushing/gold_ore' })
	event.remove({ id: 'create:crushing/deepslate_gold_ore' })
	event.remove({ id: 'create:crushing/nether_gold_ore' })
	event.remove({ id: 'create:crushing/zinc_ore' })
	event.remove({ id: 'create:crushing/deepslate_zinc_ore' })
	event.remove({ id: 'create:crushing/deepslate_diamond_ore' })

	event.remove({ id: 'create:crushing/raw_iron' })
	event.remove({ id: 'create:crushing/raw_iron_block' })
	event.remove({ id: 'create:crushing/raw_copper' })
	event.remove({ id: 'create:crushing/raw_copper_block' })
	event.remove({ id: 'create:crushing/raw_gold' })
	event.remove({ id: 'create:crushing/raw_gold_block' })
	event.remove({ id: 'create:crushing/raw_zinc' })
	event.remove({ id: 'create:crushing/raw_zinc_block' })

	event.recipes.createCrushing(['2x create:crushed_iron_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'minecraft:iron_ore')
	event.recipes.createCrushing(['2x create:crushed_iron_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'minecraft:deepslate_iron_ore')
	event.recipes.createCrushing(['2x create:crushed_copper_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'minecraft:copper_ore')
	event.recipes.createCrushing(['2x create:crushed_copper_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'minecraft:deepslate_copper_ore')
	event.recipes.createCrushing(['2x create:crushed_gold_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'minecraft:gold_ore')
	event.recipes.createCrushing(['2x create:crushed_gold_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'minecraft:deepslate_gold_ore')
	event.recipes.createCrushing(['6x minecraft:gold_nugget', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:netherrack').withChance(0.12)], 'minecraft:nether_gold_ore')
	event.recipes.createCrushing(['2x create:crushed_zinc_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobblestone').withChance(0.12)], 'create:zinc_ore')
	event.recipes.createCrushing(['2x create:crushed_zinc_ore', Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'create:deepslate_zinc_ore')
	event.recipes.createCrushing(['minecraft:diamond', Item.of('minecraft:diamond').withChance(0.75), Item.of('create:experience_nugget').withChance(0.75), Item.of('minecraft:cobbled_deepslate').withChance(0.12)], 'minecraft:deepslate_diamond_ore')

	event.recipes.createCrushing(['2x create:crushed_iron_ore'], 'minecraft:raw_iron')
	event.recipes.createCrushing(['18x create:crushed_iron_ore'], 'minecraft:raw_iron_block')
	event.recipes.createCrushing(['2x create:crushed_copper_ore'], 'minecraft:raw_copper')
	event.recipes.createCrushing(['18x create:crushed_copper_ore'], 'minecraft:raw_copper_block')
	event.recipes.createCrushing(['2x create:crushed_gold_ore'], 'minecraft:raw_gold')
	event.recipes.createCrushing(['18x create:crushed_gold_ore'], 'minecraft:raw_gold_block')
	event.recipes.createCrushing(['2x create:crushed_zinc_ore'], 'create:raw_zinc')
	event.recipes.createCrushing(['18x create:crushed_zinc_ore'], 'create:raw_zinc_block')


	//crushed ore splashing overhaul
	event.remove({ id: 'create:splashing/crushed_iron_ore' })
	event.remove({ id: 'create:splashing/crushed_copper_ore' })
	event.remove({ id: 'create:splashing/crushed_gold_ore' })
	event.remove({ id: 'create:splashing/crushed_zinc_ore' })

	event.recipes.createSplashing(['5x minecraft:iron_nugget', Item.of('minecraft:redstone').withChance(0.75)], 'create:crushed_iron_ore')
	event.recipes.createSplashing(['5x create:copper_nugget', Item.of('minecraft:clay_ball').withChance(0.5)], 'create:crushed_copper_ore')
	event.recipes.createSplashing(['5x minecraft:gold_nugget', Item.of('minecraft:quartz').withChance(0.5)], 'create:crushed_gold_ore')
	event.recipes.createSplashing(['5x create:zinc_nugget', Item.of('minecraft:gunpowder').withChance(0.25)], 'create:crushed_zinc_ore')


	//add nugget smelting recipes
	multiSmelt = (output, input, includeBlasting) => {
		event.smelting(output, input)
		
		if (includeBlasting) {
			event.blasting(output, input)
		}
	}

	//smelt raw and crushed to nuggets
	multiSmelt('4x minecraft:iron_nugget', 'minecraft:raw_iron', true)
	multiSmelt('4x create:copper_nugget', 'minecraft:raw_copper', true)
	multiSmelt('4x minecraft:gold_nugget', 'minecraft:raw_gold', true)
	multiSmelt('4x create:zinc_nugget', 'create:raw_zinc', true)
	multiSmelt('4x minecraft:iron_nugget', 'create:crushed_iron_ore', true)
	multiSmelt('4x create:copper_nugget', 'create:crushed_copper_ore', true)
	multiSmelt('4x minecraft:gold_nugget', 'create:crushed_gold_ore', true)
	multiSmelt('4x create:zinc_nugget', 'create:crushed_zinc_ore', true)

})


//reduced raw ore drops
onEvent('block.loot_tables', event => {

	let nerf_ore = (mod, ore, drop) => {

		event.addJson(mod + ':' + ore + '_ore', metal_ores_drops(mod + ':' + ore + '_ore', drop))
		event.addJson(mod + ':' + 'deepslate_' + ore + '_ore', metal_ores_drops(mod + ':' + 'deepslate_' + ore + '_ore', drop))
		event.addJson('excavated_variants:red_sandstone_' + ore + '_ore', metal_ores_drops('excavated_variants:red_sandstone_' + ore + '_ore', drop))
		event.addJson('excavated_variants:create_crimsite_' + ore + '_ore', metal_ores_drops('excavated_variants:create_crimsite_' + ore + '_ore', drop))
		event.addJson('excavated_variants:create_limestone_' + ore + '_ore', metal_ores_drops('excavated_variants:create_limestone_' + ore + '_ore', drop))
		event.addJson('excavated_variants:calcite_' + ore + '_ore', metal_ores_drops('excavated_variants:calcite_' + ore + '_ore', drop))
		event.addJson('excavated_variants:sandstone_' + ore + '_ore', metal_ores_drops('excavated_variants:sandstone_' + ore + '_ore', drop))
		event.addJson('excavated_variants:create_scoria_' + ore + '_ore', metal_ores_drops('excavated_variants:create_scoria_' + ore + '_ore', drop))
		event.addJson('excavated_variants:quark_shale_' + ore + '_ore', metal_ores_drops('excavated_variants:quark_shale_' + ore + '_ore', drop))
		event.addJson('excavated_variants:quark_jasper_' + ore + '_ore', metal_ores_drops('excavated_variants:quark_jasper_' + ore + '_ore', drop))
		event.addJson('excavated_variants:smooth_basalt_' + ore + '_ore', metal_ores_drops('excavated_variants:smooth_basalt_' + ore + '_ore', drop))
		event.addJson('excavated_variants:quark_limestone_' + ore + '_ore', metal_ores_drops('excavated_variants:quark_limestone_' + ore + '_ore', drop))
		event.addJson('excavated_variants:create_ochrum_' + ore + '_ore', metal_ores_drops('excavated_variants:create_ochrum_' + ore + '_ore', drop))
		event.addJson('excavated_variants:granite_' + ore + '_ore', metal_ores_drops('excavated_variants:granite_' + ore + '_ore', drop))
		event.addJson('excavated_variants:dripstone_' + ore + '_ore', metal_ores_drops('excavated_variants:dripstone_' + ore + '_ore', drop))
		event.addJson('excavated_variants:tuff_' + ore + '_ore', metal_ores_drops('excavated_variants:tuff_' + ore + '_ore', drop))
		event.addJson('excavated_variants:create_veridium_' + ore + '_ore', metal_ores_drops('excavated_variants:create_veridium_' + ore + '_ore', drop))
		event.addJson('excavated_variants:diorite_' + ore + '_ore', metal_ores_drops('excavated_variants:diorite_' + ore + '_ore', drop))
		event.addJson('excavated_variants:andesite_' + ore + '_ore', metal_ores_drops('excavated_variants:andesite_' + ore + '_ore', drop))
		event.addJson('excavated_variants:create_asurine_' + ore + '_ore', metal_ores_drops('excavated_variants:create_asurine_' + ore + '_ore', drop))
		event.addJson('excavated_variants:create_scorchia_' + ore + '_ore', metal_ores_drops('excavated_variants:create_scorchia_' + ore + '_ore', drop))

	}

	nerf_ore('minecraft', 'iron', 'minecraft:raw_iron')
	nerf_ore('minecraft', 'copper', 'minecraft:raw_copper')
	nerf_ore('minecraft', 'gold', 'minecraft:raw_gold')
	nerf_ore('minecraft', 'diamond', 'minecraft:diamond')
	nerf_ore('create', 'zinc', 'create:raw_zinc')

})


//semi-hardcore death functionality
onEvent('entity.death', event => {

	//set flag that player died
	if (event.entity.isPlayer()) {
	  event.entity.player.data.funnyFlag = true
	}

})


//semi-hardcore death functionality
onEvent('player.tick', event => {

	//reduce health and send message on respawn
	if (event.player.data.funnyFlag == true && event.player.isAlive()) {
		event.entity.player.data.funnyFlag = false
		event.server.runCommandSilent(`semihardcore ${event.player} health set 12`)
		event.player.tell([Text.red('You died!'), Text.green(' Eat a '), Text.lightPurple('Crystal Apple'), Text.green(' to recover your lost health.')])
	}

})


//semi-hardcore death functionality
onEvent('item.food_eaten', (event) => {

	//restore maximum health if player eats enchanted golden apple
    if (event.item.id == Item.of('minecraft:enchanted_golden_apple')) {
        event.server.runCommandSilent(`semihardcore ${event.player} health set 20`)
    }

})


//function for changing block drops
let metal_ores_drops = (id, product_id) => ({
    "type": "minecraft:block",
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "minecraft:alternatives",
                    "children": [
                        {
                            "type": "minecraft:item",
                            "conditions": [
                                {
                                    "condition": "minecraft:match_tool",
                                    "predicate": {
                                        "enchantments": [
                                            {
                                                "enchantment": "minecraft:silk_touch",
                                                "levels": {
                                                    "min": 1
                                                }
                                            }
                                        ]
                                    }
                                }
                            ],
                            "name": id
                        },
                        {
                            "type": "minecraft:item",
                            "name": product_id,
                            "functions": [
                                {
                                    "function": "minecraft:explosion_decay"
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "minecraft:item",
                    "conditions": [
                        {
                            "condition": "minecraft:table_bonus",
                            "enchantment": "minecraft:fortune",
                            "chances": [
                                0.0,
                                0.15,
                                0.3,
                                0.5,
                                0.75
                            ]
                        }
                    ],
                    "name": product_id
                }
            ]
        }
    ]
})