function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.round(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
}

	
	
		    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:cryo_tool_merge')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
				let merge = 0
				if (entity.mainHandItem == "heroes:cryo_sword_2" || entity.offHandItem == "heroes:cryo_sword_2") {
					if(entity.mainHandItem == "heroes:cryo_sword_2" && entity.offHandItem == "heroes:cryo_sword_2") {
					entity.mainHandItem = "heroes:cryo_greatsword"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_sickle_2" || entity.offHandItem == "heroes:cryo_sickle_2") {
					entity.mainHandItem = "heroes:cryo_scimitar"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_axe_2" || entity.offHandItem == "heroes:cryo_axe_2") {
					entity.mainHandItem = "heroes:cryo_coral_blade"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_rapier_2" || entity.offHandItem == "heroes:cryo_rapier_2") {
					entity.mainHandItem = "heroes:cryo_glaive"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_shield_2" || entity.offHandItem == "heroes:cryo_shield_2") {
					entity.mainHandItem = "heroes:cryo_cutlass"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
				}


				
				
				if (entity.mainHandItem == "heroes:cryo_sickle_2" || entity.offHandItem == "heroes:cryo_sickle_2") {
					if(entity.mainHandItem == "heroes:cryo_sickle_2" && entity.offHandItem == "heroes:cryo_sickle_2") {
					entity.mainHandItem = "heroes:cryo_bow"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_axe_2" || entity.offHandItem == "heroes:cryo_axe_2") {
					entity.mainHandItem = "heroes:cryo_dagger"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_rapier_2" || entity.offHandItem == "heroes:cryo_rapier_2") {
					entity.mainHandItem = "heroes:cryo_scythe"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_shield_2" || entity.offHandItem == "heroes:cryo_shield_2") {
					entity.mainHandItem = "heroes:cryo_claw"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
				}



				
				
				if (entity.mainHandItem == "heroes:cryo_axe_2" || entity.offHandItem == "heroes:cryo_axe_2") {
					if(entity.mainHandItem == "heroes:cryo_axe_2" && entity.offHandItem == "heroes:cryo_axe_2") {
					entity.mainHandItem = "heroes:cryo_double_axe"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_rapier_2" || entity.offHandItem == "heroes:cryo_rapier_2") {
					entity.mainHandItem = "heroes:cryo_halberd"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_shield_2" || entity.offHandItem == "heroes:cryo_shield_2") {
					entity.mainHandItem = "heroes:cryo_mace"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
				}
				
				if (entity.mainHandItem == "heroes:cryo_rapier_2" || entity.offHandItem == "heroes:cryo_rapier_2") {
					if(entity.mainHandItem == "heroes:cryo_rapier_2" && entity.offHandItem == "heroes:cryo_rapier_2") {
					entity.mainHandItem = "heroes:cryo_trident"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
					if(entity.mainHandItem == "heroes:cryo_shield_2" || entity.offHandItem == "heroes:cryo_shield_2") {
					entity.mainHandItem = "heroes:cryo_lance"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
				}
				
				if (entity.mainHandItem == "heroes:cryo_shield_2" || entity.offHandItem == "heroes:cryo_shield_2") {
					if(entity.mainHandItem == "heroes:cryo_shield_2" && entity.offHandItem == "heroes:cryo_shield_2") {
					entity.mainHandItem = "heroes:cryo_gauntlet"
					entity.offHandItem = "minecraft:air"
					merge = 1
					}
				}
				if (merge == 1) {
					entity.server.runCommandSilent("execute as " + entity.uuid + " at @s run particle minecraft:snowflake ~ ~1 ~ 0.4 0.4 0.4 0 250");
					entity.server.runCommandSilent("execute as " + entity.uuid + " at @s run playsound minecraft:block.glass.break player @a ~ ~ ~ 1 1.2");
				}


				}
            });
    });
	
	StartupEvents.registry('palladium:condition_serializer', (event) => {
event.create('heroes:holding_cryo_tool')
  .addProperty("mainhand", "boolean", true, " ")
  .test((entity, props) => {
    let mainhand = props.get("mainhand")

			let Hand_Type = null
					
					if (mainhand == true) {
					Hand_Type = "mainHandItem"
					} else {
					Hand_Type = "offHandItem"
					}
	return entity[Hand_Type] == "heroes:cryo_shield_0" || entity[Hand_Type] == "heroes:cryo_shield_1" || entity[Hand_Type] == "heroes:cryo_shield_2" || entity[Hand_Type] == "heroes:cryo_rapier_0" || entity[Hand_Type] == "heroes:cryo_rapier_1" || entity[Hand_Type] == "heroes:cryo_rapier_2" || entity[Hand_Type] == "heroes:cryo_axe_0" || entity[Hand_Type] == "heroes:cryo_axe_1" || entity[Hand_Type] == "heroes:cryo_axe_2" || entity[Hand_Type] == "heroes:cryo_axe_3" || entity[Hand_Type] == "heroes:cryo_sickle_0" || entity[Hand_Type] == "heroes:cryo_sickle_1" || entity[Hand_Type] == "heroes:cryo_sickle_2" || entity[Hand_Type] == "heroes:cryo_sword_-2" || entity[Hand_Type] == "heroes:cryo_sword_-1" || entity[Hand_Type] == "heroes:cryo_sword_0" || entity[Hand_Type] == "heroes:cryo_sword_1" || entity[Hand_Type] == "heroes:cryo_sword_2"
})
});
	
