function random(ary){
    return ary[Math.floor(Math.random()*ary.length)];
}

var lootType = ['ARMOR', 'AXE', 'PICKAXE', 'RANGED', 'SHIELD', 'SHOVEL', 'SWORD']

events.listen('item.right_click', event => {
	
  if (event.item.id == 'kubejs:affixgear6') {
	event.player.playSound('mana-and-artifice:entity_pixie_attack');
		
	event.server.schedule(10, event.server, function (callback) {
	callback.server.runCommandSilent('execute as ' + event.player.name + ' run affixloot ANCIENT '+random(lootType)); 
	  })

	  
	if (!event.player.isCreativeMode()) {
	
	event.item.setCount(event.item.getCount() - 1)
	}
	}
});