// Fires every time a villager or wandering trader generates a new trade offer.
// Replaces emeralds with numismatics:spur in all three slots before the offer is saved.
MoreJS.updateOffer(event => {
  const offer = event.getOffer()

  if (offer.firstCost.is('minecraft:emerald')) {
    offer.firstCost = Item.of('numismatics:spur', offer.firstCost.count)
  }

  if (!offer.secondCost.isEmpty() && offer.secondCost.is('minecraft:emerald')) {
    offer.secondCost = Item.of('numismatics:spur', offer.secondCost.count)
  }

  if (offer.output.is('minecraft:emerald')) {
    offer.output = Item.of('numismatics:spur', offer.output.count)
  }
})
