Inactive [MECH] TrainCarts v1.71.2 - Link minecarts of different types together to form trains [2222]

Discussion in 'Inactive/Unsupported Plugins' started by bergerkiller, Aug 3, 2011.

  1. Offline



    After a request from Marius A. Winsjansen I started to work on linked Minecarts. On the first day I already managed to make multiple carts move with the same speed, but a long list of bugs was to be expected. After fixing lots of bugs, adding lots of (complicated) Minecart handling functions and after hours of testing on my local server, this plugin is finally ready for a stable release! :D

    Also, special thanks go to @Shamebot for helping me out several times. :)

    For a lot of information about TrainCarts see the WIKI page!

    Configuration and permissions

    All configuration nodes can be found in config.yml and contains a description with it. Permissions can be found in PermissionDefaults.yml, combined with a description.


    Early development video (Photobucket)

    Video displaying version 0.6 of this plugin (YouTube)

    Video displaying version 1.0 of this plugin (YouTube)

    Video displaying version 1.1 of this plugin (YouTube)

    Video displaying version 1.2 of this plugin (holy...)

    A tutorial video in German explaining various sign-circuitry of TrainCarts

    PhotoBucket Sign system tutorial videos (also linked in the WIKI pages)
    Train spawner / Stations / Stations2 / Arrival signs / Train teleportation / Track switcher based on tags / Destinations / Blocker
    Video of how the switcher, station and destination signs work together

    Side information:

    It works best on straight lines with not too much elevation changes followed up by sharp corners. As long the cart gap can be adjusted, everything goes fine. It had some collision issues in the past, but I fixed all of that by manipulating the actual Minecraft server native code. I added links in the source where this was appropriate. Sharp 'U'-turns cause individual carts to lose perceptive of their direction. Keep at least one piece of track in between corner sections! Trains are stored on-disk when reloading and stopping the server, so expect trains to be there when you return.

    Important when updating: do one reload to save all trains, then replace traincarts.jar, and then do another reload. This next reload will probably cause a noClassDefFound exception (since the old jar got replaced), this is why a pre-reload is required. Replacing the jar without reloading is a very bad idea: it will cause a lot of runtime exceptions. Best is of course to stop the server and start again, but this is not always possible.

    This plugin is made compatible with Minecart Mania. If you notice a certain feature of Minecart Mania is not compatible with TrainCarts, notify me and I'll fix it. :)

    Known bugs:
    - None.

    - Train-sign message handling using SignLink (low priority)
    - Minecart use permissions (for individual carts?) such as Storage Minecarts


    If you encountered a bug, post exactly what you had done and in what order. Even a slight wobble can help fixing bugs. When posting (long) errors I recommend you to post everything, don't cut it off. I work with native methods, so in my case these lines are important. For comments on the media content see YouTube, it also contains a description with the music name when music is used.

    Bug reporting (extend)

    1. Post the Craftbukkit version you are using (the first info message in the console)
    2. Post the log from where the first plugin gets enabled to the 'done'.
    3. Post possible errors in this log too (don't cut them short)
    4. No error? Still post the log. Also explain how I can reproduce it, you can use screenshots
    5. Before reporting, remove ALL plugins other than TrainCarts and try again. If it works then, find out what plugin is interfering and post that here. I can add support.
    6. ALWAYS use the latest recommended Craftbukkit build with this, or my methods may just fail because of renamed functions.

    Important links:

    Request thread
    TrainCarts on BukkitDev for download and more
    TrainCarts source and more on GitHub
    TrainCartsBlocks add-on source and more on GitHub
    SignLink Bukkit page (required to use Arrival signs)
    MyWorlds Bukkit page (required to use Portal train teleportation)

    notice: try to keep SignLink/MyWorlds up-to-date to prevent compatibility issues.

    Installation for those that don't know how

    1. Download and install the latest craftbukkit version
    2. Download the latest TrainCarts version
    3. ^ Save the archive (zip file) to your computer
    4. ^ Open the archive you just downloaded
    5. In the folder your server sits in, create the plugins folder if it doesn't exist
    6. Open the plugins folder
    7. Move the TrainCarts.jar file found in the archive into the plugins folder
    8. Run your craftbukkit server and look in the console/log for possible errors, and/or if the plugin is enabled.


    Show your appreciation for my plugins by donating
  2. Offline


    bergerkiller So far I have not had any phantom carts appear, even when reloading the config or the server. I think it might really be fixed! I'll keep testing. Random intermittent issues are the worst, eh? Thanks for keeping after it for free when most coders would run away and hide.
  3. Offline


    CommanderGizmo Maintaining it is a lot easier than it was a few months ago. I deobfuscated all minecart related logic, so when Minecraft decided to 'screw me over' again, it won't be as bad. Only the move function, which I override to disable certain collisions, is a constant annoyance right now.

    Thanks for testing it btw, I don't have time to test TrainCarts non-stop and check every single feature after every new version, I have to rely on incoming bug reports to fix problems. (mainly because 40% of the train physics is done inside Minecraft itself...)
  4. Offline


    I'm running the 1.71.5 test build posted above, and so far after riding all my rails to test them a bunch (my rail system has a ton of detector-powered sidings for multi-train stuff so they don't crash), the problem with my detector sections always being "on" and therefore always stopping trains forever that I posted above seems to be gone. I'mma test it a bit more, but so far so good. Thanks! :D

    Well I lied, it's doing it again (Detecting as if something is in that region, when it's not). Is this something I'm doing then? Because it only happens between certain regions, most of them work fine all the time... can the only be so big or not have a certain track path or something? lol
  5. Offline


    So far, so good! I haven't had any more phantom carts, crashed trains, or stuck carts since I updated to 1.71.5!

    One more question for now:
    I have trains running next to my crops, but none of them seem to grow while I'm gone. I have the default properties of all trains set to KeepChunksLoaded=true, and have confirmed so with the /train info. They are moving, but the KeepChunksLoadedOnlyWhileMoving is set to false anyway. Is there anything in bukkit or MC that requires a player to be present to grow the crops, or is it possible the chunks aren't really staying loaded?
  6. Offline


    CommanderGizmo When the train leaves the area, the chunks will unload. Unless you place a minecart underground or something the chunks will not stay loaded. Crops grow using a lot of randomness, so the chunk needs to be loaded for a fairly long time for them to grow.

    SinCalChewy It does use complicated logic to reduce the amount of checks on trains. For example, when the detector is on, it only handles trains leaving that match the detector. When the detector is off, it will only handle new trains that match the detector. There is always a possibility that the detector-off logic is malfunctioning, or that a train disappears from the region without it being removed. I'll have to test that once more to verify, because this same issue has happened before...

    And then it is also possible there is a ghost cart on the rails, keeping the detector on.
  7. Offline


    bergerkiller Yes, the carts run directly under the crops. From what I can tell in the source, it looks like it keeps a 5x5 area of chunks loaded with the cart in the center. Having a cart sitting parked or circling under the crops ought to work, correct? Is it possible the chunks is getting unloaded and reloaded rather than staying loaded? Perhaps that might reset the growth timers.
  8. Offline


    CommanderGizmo CraftBukkit unloads chunks every tick, so as soon as the minecart leaves a chunk, the 5-width chunk block gets unloaded, and another 5-width chunk block loads again. Having a minecart circle between chunks is not a good idea, as chunks would unload a lot then. (it's CraftBukkits' fault for not handling chunk unloads better...)
  9. Offline


    Is there no way to cancel a chunk unload? I normally leave one just sitting. If that is the case the chunks should stay loaded? Does your code load the chunk every tick?
  10. Offline


    TrainCarts does the most efficient methods (others can't do this, because they have to use a slower HashMap all the time, I can store it in the Minecart itself)
    • Every time the minecart moves (postmove) it checks if it crossed a chunk border
    • If it did, it loads all the unloaded chunks within range. This happens every 40 ticks when moving at 0.4 b/tick)
    • If a Chunk Unload event is fired, it checks all the minecarts that occupy this chunk (within 2 chunk range)
    • If there are no minecarts that keep the chunk loaded, the event is allowed
    • In the next handler it despawns all minecarts that occupy that chunk
    I *tried* to implement a chunk unload delay system (chunk persistence) in NoLagg, but ironically, it lags like crazy. In the end it takes more time to look up the chunk in the map to check if it can unload than you gain from possible useless unloads. The same would happen if I keep chunks loaded longer after a minecart leaves chunks.

    If you want to keep a chunk loaded 'all the time', I think you can do this quite easily. All you have to do is have a simple set of chunk coordinates to keep loaded. Try to optimize it all away and perhaps you can get it working. In short: The Minecraft/CraftBukkit devs caused the chunk unload event to be spammed, resulting in causing a lot of lag when you try to keep chunks loaded.
  11. Offline


    Yeah, it seemed to work for awhile with 1.71.5, but then started doing it again. The railway more often works going one way more than the other, was well. Whats kinda weird, is I have lights that come on at the sidings when the rail section is in use, and when it's working they turn off as I leave the rail section for the most part, but then if I ride the rail back that way, they're on for some reason even after seeing them turn off when leaving the section of rail and my train is stopped at the siding because the track is "in use". But once they're stuck on, they stay on most times until I manually flip the lever. Then they will work for a few more minutes, and then stop again most times.

    As for CommanderGizmo asking if wheat will grow, I have set up a few "always grow" wheat farms that grow the wheat all the time. I just made a grid of rails directly under some dirt, and then used a timed spawn sign to spawn a cart every 3 seconds at .1 speed and then at the end of the grid rail a cart destroy, and at least what it seems, they're spawned close enough to keep the area always loaded if you set up the railing right. I have a large wheat farm that I can farm lots of wheat from because it always grows it because of the train system under it. I also do this in the nether with nether wart, with a quite large farm as well.
  12. Offline


    So basically, the thing is on. You let a minecart enter it, it leaves again, and it turns properly off. But for some strange reason, the lever is on sometimes?

    Because that would mean it doesn't toggle the lever now and then. It could be that the lever far away that is in an unloaded chunk, doesn't get toggled. And as you enter near that lever, it is still on, from when the chunk was saved.
  13. Offline


    bergerkiller So, just because I'm curious: Are you saying that the chunk unload is actually cancelled, or simply that the chunk is loaded after it has unloaded?

    Perhaps the crops don't grow because the timers for growth are reset on each loading of the chunk?
  14. Offline


    That is what I'm thinking, because the regions that I never have problems with are closer together, the ones that get stuck on are slightly further, but not super far, apart. Also, if I ride the rail to our second town in the next biome where the lantern/detector is near the station, and then ride it back, it works fine, I would think because it's near the eject and therefore loaded. It seems however, if I ride to the second town in the next biome, and then /home back to the first station, the light/detector is still on, like you said because it was saved like that I would think, and it wasn't turned off when the train came back to town perhaps? Is that something I'm doing wrong, like having them too far apart? Or is that something the plugins doing? Just so I know what I have to do, or wait, for. Lol

    We're on a large biome world, so the rail is pretty long. The regions said they were found and set still when setting the signs down, so I didn't really think twice about it.
  15. Offline


    There are no timers involved when growing. It is simply a matter of chance upon chance upon chance based on the environment the crops are in. (I can know, I rewrote all of that in Spout Vanilla)

    It could be the chunks don't stay loaded long enough to ever hit that chance. It probably takes three times longer for a crop to grow then.

    I never tested the detector for extremely long distances, so it could very well be. I'll do some tests today on my 30-chunks long railway. :)
    Do note that redstone won't update into unloaded chunks. You may have to keep the chunks at these circuits loaded somehow. For sure, I will make sure that levers are updated when a chunk loads. It is a simple matter of adding a chunk-based mapping of the detector signs.
  16. Offline


    Cool, thanks. My first thought was that it was a problem with redstone, but then later found out it was just the levers.
  17. bergerkiller

    Hi, would it be possible to add a feature to list how many TrainCarts are currently on the server.

  18. Offline


    Lexion a train counter or a minecart counter?
  19. I am interested in the number of trains that are active (moving or stationary) not too bothered how many carts make up the trains.

  20. Offline


    /train list now shows the amount of trains on the server, and the amount of trains that are moving.


    Ok all done. It is now up on GitHub. Usage:
    For example:
    It supports all sound and regular effects. I don't think I will add stuff like effect lists with timing and all...if you want to play a complete song, find a plugin (note block playing plugin) I can hook into instead. Don't want to end up managing two complete plugins for this.
  21. Offline


    Detector levers still don't get updated on chunk loading in 1.71.5. :'(

    But other than that, great release so far! Thanks Berger
    Gonna have to mess around with the effect sign. :)
  22. Thanks bergerkiller, it says you are the proud owner of the following carts for anyone using "/train list" even if they have not called any carts, I can ignore that as I just want to see how many trains are on the server.
  23. Offline


    I would really love to see the collect and deposit signs allow you to just pickup or dump to/from the ground. Maybe use 'g' for ground like 'f', 'c', and 'd'. This would open up a whole new set of industrial buildings.
  24. Offline


    Dude you should add a train system so you have to buy your way into the train
  25. Offline


    Actually, there IS a ticket sign, someone requested that once. Though because of it's simplicity not always useful. It basically lets IConomy subtract a set amount from the players' account, and if the player can't pay, he is ejected.
    For example:
    Add gives money, and check simply displays the current bank money value to the user.

    Not a bad idea, and not too hard to implement. All I have to do is develop an inventory based on items on the ground.
  26. Offline


    bergerkiller Could you also add a limiter in the train properties for the maximum distance to pick up and deliver using the ground? Actually, it would be great if there was also a master limiter in the main config file. That way it can't be used to steal items.
  27. Offline


    Hey guys I have a small problem. I'm trying to run a train indefinitely on a loop and when it comes to stations people can hop on and go to the next stop or whatever. For some reason the train tends to just stop when nobody is in it and I have tested the powered rail and it is fine it seems to only happen when it goes out of range of a user as when I run beside the train it is also fine. Sorry if I'm asking a noobish question as I am only new to craftbukkit and this is the first plugin I'v tried. Please get back to me thanks.
  28. Offline


    CommanderGizmo it would use the same distance settings as used for chests and furnaces, a maximum for that is already configurable. (the default too)

    Common issue, set the 'keep chunks loaded' to true on the train:
    While having the train selected. By default it is false, resulting in the train unloading (and stopping) when the chunks the train is in unload.
  29. Offline


    As of the latest version (1.71.5) the carts are putting full stacks of items into furnaces even when an amount is specified:

    deposit f
    8 pork;coal
    An entire stack of pork is placed instead.
  30. Offline


    On it, I noticed an odd error when debugging, too, so I'll fix that as well. (could be the two are related)

    At least I know the 'disable TrainCarts on critical error' system is working fine...


    Fixed both the error and your problem. Now working on a 'grab nearby items' system.

    edit: This will also get a deposit system; which adds to nearby items and spawns additional items.
  31. Offline



    I have also noted that collect signs do not work on furnaces and it seems to place entire stacks of fuel.

Share This Page