TrainCarts
TrainCarts Development has moved to SpigotMC.
You can get the new versions at the following URL:
https://www.spigotmc.org/resources/traincarts.39592/
This page is no longer being actively monitored, please seek for support on SpigotMC.
Plugin: TrainCarts - Linked Minecarts, sign-redstone systems, easy to use and realistic
Version: v1.73.0
Build: 1.7.2 R0.1/R0.2
Incompatible with: RailCraft
Description
This plugin looks for suitable Minecarts and links them together if possible. When two Minecarts are being "linked", the Minecarts will act as one single moving train.
Once carts are successfully linked, an effect is played and their velocity is shared in combination with an individual factor for each Minecart, which is used to remain a steady gap between carts. This gap is adjustable, the force at which this happens as well.
End result: a train! You can move it, make a roller-coaster out of it, split it in half, watch trains collide, whatever you want to do with trains. :)
As for 1.21, it is also possible to safely exit your train by setting an exit offset with a (sideways) push factor for the train. This feature is disabled by default. (only affects dropped items). If you want to display arrival times on signs (see redstone circuit part) you need SignLink, see the downloads on the bottom of the page.
As for 1.35 you can set train properties to make 'special' trains, or to 'finalize' a train

Links
For configuration, permissions and how-to's, see the Wikipedia page (it is rather long):
Note that I would prefer having comments, bug reports and others in the main Bukkit page, since I visit that site the most. :)
Addons
Special Addons for TrainCarts
Features
- Link minecarts using collision: no commands needed to make a train
- Move trains as easily as you would with single Minecarts
- Store trains to file for persistence during reloads and server restarts
- Use sign-redstone circuits for subway systems, complete railroads and much more
- Station to gracefully stop and launch trains
- Spawn
- Teleport
- Property setters
- Tag systems to switch certain tracks based on tags on the train
- Destination systems to make your train travel to far-away lands all on it's own
- Supports Minecart Mania's features
- Infinite minecart speeds are possible
- Push-away: Push mobs, players and items away from your trains to keep them running
- Everything is configurable, if something proves not to be, I will make it that way
FAQ
When players are near, trains reach their destinations. With no one near, they don't. What do I do?
By default trains do not keep chunks loaded, and they will unload once they move into unloaded chunks. To make trains keep the chunk area (and themselves) around them loaded, set the 'keepchunksloaded' property to True. This can be done using the /train keepchunksloaded true command, using a property sign or by changing it to true in the DefaultTrainProperties.yml file. For more information about train properties, see here.
Why not boats?!?!
Incompatibilities
If you have another plugin that performs similar Minecart replacement techniques, it is likely that TrainCarts will not function or function poorly. For the 'chunk persistence' part of this plugin, other plugins that unload chunks without firing events result in this feature failing. Minebackup is known for having this problem.
Metrics
This plugin sends server count statistics to MCStats.org. You can (globally) opt out in the PluginMetrics/config.yml file.







-
View User Profile
-
Send Message
Posted Nov 16, 2012Crafter signs still not working
https://dl.dropbox.com/u/46749435/2012-11-16_11.35.57.png
That should work right?
-
View User Profile
-
Send Message
Posted Nov 15, 2012@leagris That must be a textual bug. Nobody should be everybody :) When a train has no owners set...it's ownerless and everyone can use it. That is also why you can see it listed as a train you own - you own all non-owned carts automatically. Hope that clears it up.
-
View User Profile
-
Send Message
Posted Nov 15, 2012@leagris
Here is an illustration of /train list having a train belong to me but not when doing /train info
And wow for the fix
-
View User Profile
-
Send Message
Posted Nov 15, 2012New version is up, don't forget to get it! It contains a ton of bugfixes and additions, so don't miss it!
http:dev.bukkit.org/server-mods/traincarts/files/54-v1-72-1/
@leagris Really have to thank you for reporting this issue! It was a really nasty problem that was caused in multiple locations. Thanks to you, it is now fixed :) I can now place trains, set tags a-z for all carts, restart or rejoin the server, and everything is still there. Train Properties also still work. I also had to fix some problems with cart properties ending up all over the place, also in the wrong train. This caused problems when doing /train commands that operated on all carts of the train. All of this is fixed in the above version. (I went official to start with 1.4.4 for the next version)
-
View User Profile
-
Send Message
Posted Nov 15, 2012@bergerkiller
Noticed this a few minutes ago.
a train tagged private and owned by "nobody" was listed in the trains I owns with /train list but when doing a /train info it was still marked owned by "nobody" but public. The train traveled more and some time later it was no longer listed as owned by me.
So it look like not all properties are randomly altered. Some trains got reset all default but their name. For sure, at server start, all existing minecart entities are reset to defaults and previously linked carts are now individual rogue with default and sometimes without motion either.
-
View User Profile
-
Send Message
Posted Nov 15, 2012@leagris Unfortunately I can't store minecarts elsewhere as it is now, there is a lot of entity related info stored. Position, velocity, items, health and other stuff is only part of that. I already replace all minecarts with my own minecart version, so that's not to blame here.
-
View User Profile
-
Send Message
Posted Nov 15, 2012@bergerkiller
Yet another work-around would be to cleanup all carts (matched and not-matched but close entities as an uoption) and respawn entities for each TC handled minecarts without a matched entity.
Afterall, a minecart entity which could not match a Train Carts known minecart has no reasons to live, so get ride of it alltogather.
If Train Cart has a cart to work with, but it can not find the corresponding entity, then it spawns a new one and it is safe because, there are no more rogue minecart entities in the way, as these where got ridden-of before.
-
View User Profile
-
Send Message
Posted Nov 15, 2012@Etsija Exactly, it is just a way to fix things up. The command is only needed if you, for example, insert a switcher sign between two other switcher signs, and a recalculation is required.
@leagris In TrainCarts I use a database-like system. I map chunk coordinates to groups that need this chunk to be loaded. When chunks load, they obtain this list and check whether all chunks of the group are loaded now. If they are, the group is restored by obtaining the minecart entities. (this is where the ... carts missing comes into play) and a group is created with the properties of that train.
The only ways this system can fail is if the minecart group is restored too early (I added several checks against this), and the minecarts aren't loaded yet. Another possibility is that, while restoring, the set properties get lost for some reason.
I will do several test runs by setting tags on the train and then checking whether these tags are still there. Thanks for the info!
-
View User Profile
-
Send Message
Posted Nov 15, 2012@bergerkiller
Ill try this new build but first here are my detailed observations of the issue and idea for fixes:
After a server restart or sometimes randomly, trains and carts loose their properties on the go as they get reset to default properties for no reason.
This is what cause stuck trains to pile-up after a server restart as they loose loadchunk and no-collide and becomes public trains instead of owned trains.
I discovered this while setting properties just after train spawn.
[+train] | spawn 1:0 1.2 | mmmmm
[+train] | property | setowner | nobody
[+train] | property | loadchunks | true
[+train] | property | collide | false
I was riding in a train, spamming /train info to get a grasp of what it was doing. Then suddenly, I saw the train getting back the default properties in the middle of the ride.
This lost train properties occurs randomly when while riding. It occurs every time after a server restart for trains that where up during the shut-down.
My guess is, this is a common issue I already frighted with in various minecart plugins. Server has its own entities database and manage minecarts velocity there with chunk data. Most of the time, server thread handled minecart velocity is lost after a restart (craftbukkit).
Minecart plugins have to workaround handling their own minecarts database, mapping it to the server handled entity database. While a chunk load, it brings its own entities to live, and the minecart plugin has to figure-out which of the chunk loaded cart entities belong to him. This is a very hackish task, as entity IDS may have changed in-between.
In the time the chunk loaded and the server thread computed new minecarts locations, due to its internally handled velocity, the minecart plugin will try to match chunk loaded minecart entities based on its own database recorded location. But it can not, because the carts have moved. This is a wider problem during server start-up because of increased delay between chunk load and plug-in enable. Train Carts seems to gracefully register chunk loaded minecarts without a match on known trains, but these get the default properties and inherit server known velocity (which is 0 at a station).
This could explains why, I get random loss of train properties. A velocity of 1.2 blocks per tick is unnatural and have no match-able server handled velocity. As the cart approach an unloaded chunk boundary, it's server side handled location can get out of sync with the plugin handled location. The plugin fails to match the server side entity with its known train and then register a new train with defaults.
This could explains why, I get defaulted trains after a server reload for the very similar reason (plugin load after handled chunkload and minecart velocity).
A good workaround I could think of for the server start entity out of sync problem, would be for traincarts to despawn/remove all its handled trains and carts on unload, force a chunk save for every related chunks to ensure no remaining cart entity remains in a chunks at next start-up.
This would means saving any storage and powered cart inventory and burning state. Then it should re-spawn known trains with states and content at plugin load.
For the random property loss due to loss of sync at chunkloads. I guess it could have a better algorithm for identifying related minecart entities instead of registering new ones with defaults.
Yet another work-around would be to cleanup all carts (matched and not-matched but close entities as an uoption) and respawn entities for each TC handled minecarts without a matched entity.
Afterall, a minecart entity which could not match a Train Carts known minecart has no reasons to live, so get ride of it alltogather.
If Train Cart has a cart to work with, but it can not find the corresponding entity, then it spawns a new one and it is safe because, there are no more rogue minecart entities in the way, as these where got ridden-of before.
-
View User Profile
-
Send Message
Posted Nov 15, 2012@bergerkiller
Ah, this is what I suspected. So really, the optimal way is to AVOID "/train reroute" unless absolutely necessary (i.e. unless the path finding really fails)? I think I can see now where I went wrong. Thanks for the info - I'll ride the routes and see what kind of destinations.dat it gives me.
-
View User Profile
-
Send Message
Posted Nov 15, 2012@Etsija /train reroute removes all path finding nodes. All of them. It forces a re-calculation when a minecart with destination travels past a switcher sign. This is why small lag is observed if your train map is really huge.
-
View User Profile
-
Send Message
Posted Nov 14, 2012@bergerkiller
Thanks, /train saveall works great. Just one question though: you mentioned something about not all the nodes being stored to destinations.dat? Was it so that it stores only the ones which have been "used" by train destinations? I'm asking since in the earlier destinations.dat versions, my "test network" (which is completely isolated from the actual metro railwork in our server) was included in destinations.dat, but now isn't. So should I give a test drive on it and use /train saveall just after that or what?
EDIT: What's more, after "/train reroute", immediately followed by "/train saveall", destinations.dat is empty again. Something I clearly don't understand in the logic of those commands.
-
View User Profile
-
Send Message
Posted Nov 14, 2012@Etsija I reuploaded test 7, it now contains a /train saveall command:
https:dl.dropbox.com/u/3681706/TrainCarts%20v1.72.1%20TEST7.zip
@leagris Your problem is a bit obscure because I can't seem to reproduce it on the above latest version. I made 6 rows of spawn/destroy pairs, spawn signs spawning every second. I made this run for 2 hours, but no memory problems and no high amount of trains. Nothing weird seen in the group data after saving, either.
I suspect that something else happened: Restoring a train caused countless of minecart entities to be spawned. For that purpose I added a minecart count read-out to the /train list command. Can you use that version? Once you get the same tick lag issue, use /train list to see how many minecarts are on the server. If this is a really high value, then I can at least try and look for reasons why this happens. (no issues to be seen at first sight)
-
View User Profile
-
Send Message
Posted Nov 14, 2012@Etsija I will take a look at the destinations saving and add a /train saveall command that will save all information to disk. This includes stuff like detector regions, spawn signs, train properties and group data.
@leagris Even with 43 trains it shouldn't lag. I've done benchmarks where I had 200 trains of 5 carts running around.... Something else must be up I guess. When it happens again, can you check how much memory the server is using up? And also, after you clear the train again. Try using one of the plugins that can show memory usage, it is more accurate than the amount shown in task manager/process info.
-
View User Profile
-
Send Message
Posted Nov 14, 2012Ah shucks. I restarted our server, and now once again, destinations.dat is empty. I don't understand the logic of the file - and it is making it very hard to me to work on my code for printing out the route finding map...:)
Please, please could you implement a command to dump the relevant pathfinding data "online" to destinations.dat. If that's not too much trouble. Thank you.
-
View User Profile
-
Send Message
Posted Nov 13, 2012Well, after 11hours uptime, all players left the server because TPS was down to 2.4TPS :(
43 trains (there are supposed to be max 18)
/train removeall and TPS grown again
Therr is still something leaky with train data instances/workers.
-
View User Profile
-
Send Message
Posted Nov 13, 2012So bergerkiller, I'm well on my way creating a version of your TCDestinationsConverter, which will output to DOT format. I decided to choose that since it is dead easy to plot a graph of the railway system as it is seen by TrainCarts with any DOT engine, like GraphViz for example.
For that purpose, I would really need the destinations.dat problem fixed. If you have changed something in your code so that destinations.dat is not saved anymore, could you please implement a command to specifically dump the nodes and edges to destinations.dat? I think that would be really useful to me, since I could then take "snapshots" of the routing situation and debug the problems (we are currently having) with route finding.
-
View User Profile
-
Send Message
Posted Nov 13, 2012@bergerkiller
Thank you for the fix, now train count is all accurate.
Performance
One remaining issue I still have is this recurrent TPS drop.
We have a permanent moving train count between 16-18 with 5 carts each in 3 distinct metro lines. Each line was dumbed-down to a both-ways "spawn train → travel → station → travel → station → travel → station → travel → kill train". The 6 permanent train spawners are clocked at 1 minute interval.
So, every minutes, there are:
I switched to this spawn then kill train setup, due to issues with stuck trains/carts at server restarts and sometimes op colliding wreaking trains in the tunnels by accident. With this setup, in case of a mishap, an op can safely do a
/train removealland all the metro lines will auto-re-populates.These are optimizations I could do to improve efficiency and avoid these TPS drops:
I have several issues with this fallback to a point-to-point "spawn → go → kill" method:
-
View User Profile
-
Send Message
Posted Nov 13, 2012No, it doesn't seem to be generating anything to destinations.dat. The file is totally empty.
-
View User Profile
-
Send Message
Posted Nov 12, 2012@Etsija It didn't generate new nodes? Note that it no longer creates switcher nodes when the train activating it has no destination set; it's to reduce tick lag.