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 == 'forbidden_arcanus:rune_bag') {
	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 COMMON '+random(lootType)); 
	  })

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