function spawnmob(loc: location, entity: entity type):
spawn {_entity} at {_loc}
on death:
if victim is pig:
if victim's name is "&b&lWorld Border":
cancel event
command /pig:
permission: op
permission message: No
trigger:
spawnmob(location of player, pig)
set name of last spawned entity to "&b&lWorld Border"
set {_entity} to last spawned entity
every 0.1 seconds in world "world":
set {_x} to x-position of {_entity}
set {_z} to z-position of {_entity}
make console execute command "worldborder center {_x} {_z}"