You can also update an existing train chest item, without getting a new item every time. The player has to hold the chest item, then use one of the following commands:
Put a new train inside the item, spawn sign syntax
Command:
/train chest set mytrain
Permission:
train.command.chest.create
Makes the item empty
Command:
/train chest clear
Permission:
train.command.chest.create
Locks the item, preventing it from picking up trains when clicked
Command:
/train chest lock
Permission:
train.command.chest.create
Unlocks the item so it can pick up trains again
Command:
/train chest unlock
Permission:
train.command.chest.create
Gives the item a human-readable name to identify it
Command:
/train chest name My Train
Permission:
train.command.chest.create
Makes the chest item have finite (1) or infinite number of spawns