function randomChance(ary,chance){
  var ranint = Math.random() * (100 - 0) + 0;
  if (ranint <= chance){
    return ary[Math.floor(Math.random()*ary.length)];
  } else {
    return '';
  }
}

var carryingBlock = ['kubejs:lootblock_magic_floral', 'kubejs:lootblock_builder', 'kubejs:lootblock_magic_druidic'];

onEvent('entity.spawned', event => {

    if(event.entity.type == 'minecraft:enderman') {
        
        event.server.scheduleInTicks(2, cb => {
        
        var UUID = event.entity.getFullNBT().UUID;
	  
	  event.server.runCommandSilent('data merge entity @e[nbt={UUID:'+UUID+'},limit=1] {carriedBlockState:{Name:"'+randomChance(carryingBlock,5.0)+'"}}');
    });
}
})
