onEvent('entity.spawned', event => {
    // Piglin and Zombie  pigmen
    for(let mob of mob_list_gold_armor) {
      if (event.entity.type == mob) { 
          // Get the full NBT of the mob.
          var NBT = event.entity.fullNBT;      
          // Loop all HandItems/ArmorItems and modify all vanilla one:
          // Hands
          for (let h in NBT.HandItems){
            // Check if id is present
            if ('id' in NBT.HandItems[h]){
              if (NBT.HandItems[h].id.match(/minecraft:.*_.*/)){
                NBT.HandItems[h].id = "silentgear:machete";
                NBT.HandItems[h].tag = gold_machete_tag;
          }}};
          // Armor
          for (let h in NBT.ArmorItems){
          // Check if id is present
          if ('id' in NBT.ArmorItems[h]){
            if (NBT.ArmorItems[h].id.match(/minecraft:.*_.*/)){
              NBT.ArmorItems[h].id = armor_id[h];
              NBT.ArmorItems[h].tag = gold_armor_tag[h];
          }}};
        // Set the new NBT.
        event.entity.fullNBT = NBT;
    }};
});