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:affixgear4') {
	event.player.playSound('mana-and-artifice:entity_pixie_hurt');
		
	event.server.schedule(10, event.server, function (callback) {
	callback.server.runCommandSilent('execute as ' + event.player.name + ' run affixloot EPIC '+random(lootType)); 
	  })

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