Hey im using this script to spawn a wandering trader dropping a stone in to the water:
EntityEvents.spawned('minecraft:item', event => {
const { entity, level, server } = event
if (entity.item.id != 'minecraft:stone')return
const uid = entity.uuid
server.scheduleInTicks(40, () => {
const item = level.getEntity(UUID.fromString(uid))
if(item === null)return
const x = item.x
const y = item.y
const z = item.z
if(level.getBlock(x, y, z).id == 'minecraft:water'){
const wanderingTrader = level.createEntity('minecraft:wandering_trader')
wanderingTrader.setPosition(x, y + 1, z)
wanderingTrader.spawn()
item.item.shrink(1)
console.log(`Wandering Trader spawned at (${x.toFixed(0)}, ${(y + 1).toFixed(0)}, ${z.toFixed(0)}) in water`);
}
})
})
is it possible to add cooldown so players do not spam this?