onEvent('chest.loot_tables', event => {
	event.addChest('kubejs:dungeoncrawl/dc4', table => {
		
		//tetraVariables
		
		var tSwordGuard = ['wide_guard', 'forefinger_ring'];
		var tSwordGuardMat = ['manasteel', 'bronze', 'electrum', 'steel', 'obisidan', 'elementium'];
		
		var tSwordBlade = ['basic_blade', 'heavy_blade', 'machete', 'short_blade'];
		var tSwordBladeMat = ['manasteel', 'bronze', 'electrum', 'steel', 'obisidan', 'elementium'];
		
		var tSwordPommel = ['grip_loop', 'counterweight'];
		var tSwordPommelMat = ['manasteel', 'bronze', 'electrum', 'steel', 'obisidan', 'elementium'];
		
		var tSwordHilt = ['basic_hilt'];
		var tSwordHiltMat = ['manasteel', 'bronze', 'electrum', 'steel', 'obisidan', 'elementium'];
		
		table.addPool(pool => {
			pool.rolls = 1
			
			//empty
			pool.addEmpty(2750)
			
			//randomArmor
			Ingredient.of([
			'/.+helmet/', '/.+chestplate/', '/.+leggings/', '/.+boots/'
			]).filter(Ingredient.of([
			'@alexsmobs', '@tropicraft', '@ars_nouveau', '@bloodmagic', '@mutantbeasts', '@pneumaticcraft', '@iceandfire', '@mana-and-artifice', '@psi', '@jellyfishing', '@gaiadimension', '@betterendforge', '@tconstruct', '@twilightforest', '@stalwart_dungeons', '@enigmaticlegacy', '@malum', '@nethers_exoticism', '@blue_skies', '@rats', '@farlanders', '@xreliquary', '@theoneprobe', '@outvoted', '@dungeons_mobs', '@spheric', '@naturesaura', '@undergarden', '@aquaculture', '@occultism', '@atum', '@desolation', '@cyclic', '@psipherals', '/.+book.+/', '/.+utheric.+/', '/.+elementium.+/', '/.+terrasteel.+/', '/.+alfsteel.+/', '/.+tyr.+/', '/.+draco_arcanus.+/', '/.+netherite.+/', '/.+egg/', '/.+arcane.+/', '/.+bone.+/', '/.+leather.+/', '/.+wooden.+/', '/.+stone.+/', '/.+iron.+/', '/.+clay.+/', '/.+bighorn.+/', '/.+tin.+/', '@mob_grinding_utils', '@eidolon', '@byg', '@mowziesmobs'
			]).not()).stacks.forEach(armor => {
            pool.addEntry({
              "type": "minecraft:item",
			  "weight": 300,
			"functions": [
            {
              "function": "minecraft:enchant_with_levels",
              "levels": {
                "min": 30,
                "max": 49
              }
            }
          ],  
              "name": armor.id
            })
			
			//randomTool
			})
			Ingredient.of([
			'/.+sword/', '/.+pickaxe/', '/.+axe/', '/.+shovel/'
			]).filter(Ingredient.of([
			'@alexsmobs', '@tropicraft', '@ars_nouveau', '@bloodmagic', '@mutantbeasts', '@pneumaticcraft', '@iceandfire', '@mana-and-artifice', '@psi', '@jellyfishing', '@gaiadimension', '@betterendforge', '@tconstruct', '@twilightforest', '@stalwart_dungeons', '@enigmaticlegacy', '@malum', '@nethers_exoticism', '@blue_skies', '@rats', '@farlanders', '@xreliquary', '@theoneprobe', '@outvoted', '@dungeons_mobs', '@spheric', '@naturesaura', '@undergarden', '@aquaculture', '@occultism', '@quark', '@tconstruct', '@atum', '@cyclic', '@psipherals', '@botaniaadditions', '@additionalbanners', '@evilcraft', '@mowziesmobs', '@astralsorcery', '/.+book.+/', '/.+utheric.+/', '/.+elementium.+/', '/.+terrasteel.+/', '/.+alfsteel.+/', '/.+tyr.+/', '/.+draco_arcanus.+/', '/.+netherite.+/', '/.+egg/', '/.+bone.+/', '/.+terra.+/', '/botania:glass_pickaxe/', '/.+wooden.+/', '/.+stone.+/', '/.+iron.+/', '/.+clay.+/', '/.+bighorn.+/', '/.+tin.+/', '@mob_grinding_utils', '@eidolon', '@byg'
			]).not()).stacks.forEach(weapon => {
			pool.addEntry({
              "type": "minecraft:item",
			  "weight": 200,
			"functions": [
            {
              "function": "minecraft:enchant_with_levels",
              "levels": {
                "min": 30,
                "max": 49
              }
            }
          ],  
              "name": weapon.id
            })
			})
			
	//randomTetraSword
	tSwordGuard.forEach(tSG => {
	tSwordGuardMat.forEach(tSGM => {
			
	tSwordBlade.forEach(tSB => {
		tSwordBladeMat.forEach(tSBM => {
			
	tSwordPommel.forEach(tSP => {
		tSwordPommelMat.forEach(tSPM => {
			
	tSwordHilt.forEach(tSH => {
		tSwordHiltMat.forEach(tSHM => {
			
	const itemnbt = 
	`
	{
	HideFlags:1,
	Damage:0,

	"sword/guard":"sword/${tSG}",
	"sword/${tSG}_material":"${tSG}/${tSGM}",
	
	"sword/blade":"sword/${tSB}",
	"sword/${tSB}_material":"${tSB}/${tSBM}",
	
	"sword/pommel":"sword/${tSP}",
	"sword/${tSP}_material":"${tSP}/${tSPM}",

	"sword/hilt":"sword/${tSH}",
	"sword/${tSH}_material":"${tSH}/${tSHM}"
	}
	`
	Ingredient.of(['tetra:modular_sword']).stacks.forEach(item => {
            pool.addEntry({
          "type": "minecraft:item",
		  "weight": 1,
          "name": item.id,
          "functions": [
            {
              "function": "minecraft:set_nbt",
              "tag": itemnbt
            }
			]
				})
			})
			
				}) }) }) }) }) }) }) })
		})
	})
})