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

    bergerkiller

    [​IMG]

    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. :)

    Description:
    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.

    Media:

    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.

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

    Commenting

    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.

    Changelog

    Show your appreciation for my plugins by donating
    [​IMG]
     
  2. Offline

    CommanderGizmo

    bergerkiller

    It looks like all crafting signs now fail using the test bulid. Here's the debug data.

    [EDIT]
    Also, when performing an in place upgrade using the reload command and upgrade folder, all trains were not found. Trying to break the trains in the world after loading generates this error. I can break the train again and again and it just keeps giving me a cart and leaving the broken one there. I also hear continuous looping train sounds but nothing is moving. Switching back to 1.72.0 yields these carts as phantoms.
     
  3. Offline

    bergerkiller

    CommanderGizmo
    The crafting bug is fixed now:

    http://dev.bukkit.org/server-mods/bkcommonlib/files/13-v1-34/

    It's awaiting approval still. The error you were having is good, because if I didn't include that error, even weirder things could start happening. It has to do with a minecart being in a zombie state (it thinks it is unloaded and waits for the group it is in to restore the minecart). I will look at the in and outs of that error to see why it happens. My guess is that you tried to damage a minecart in zombie state and I forgot to add an isUnloaded check to prevent issues.

    You should never hot-swap plugins by reloading. Not only will saving be impossible (it can't find the classes of the minecarts that are in the world), it will also cause the heap space to reach the limit, crashing the server. The thing you had is most likely related to this; there was a zombie member in the world and the plugin was unable to restore it.

    CommanderGizmo
    I updated the download: (same link)

    https://dl.dropbox.com/u/3681706/TrainCarts v1.72.1 TEST1.zip

    It now also includes some extra logic to make sure it replaces MinecartMember instances on the world that are glitched. (it compares class name)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 14, 2016
  4. Offline

    CommanderGizmo

    Thanks for the rapid fixes!
     
  5. Offline

    Helmi74

    Hi,

    first of all i'd like to thank you for that great plugin. it's totally awesome.

    One question: Is it possible to use variables in e.g. destination names when setting properties? For example using the $obj.var that you can set with Variable Triggers or something like that would be great. I'd like to switch destinations that way.
     
  6. Offline

    Qi Xiang

    Could you like maybe include some kind of chunk anchor (in the future) where maybe a sign would keep a chunk loaded because my trains always stop because a certain chunk is not loaded

    EDIT: oh, and thanks for the extremely fast update!
     
  7. Offline

    bergerkiller

    Qi Xiang
    You can set trains to keep chunks loaded, so no need for the keepchunksloaded sign. Such a plugin is easily made, though, you can add a plugin request for it on these forums. (also state that the author should use the native getTileEntities function and not loop through all 16x16x16 blocks in the chunk to find the sign...)

    Helmi74
    Hmm yeah such a thing is missing right now, I think such a thing should become part of SignLink. A sign responding to redstone that can change a variable would be pretty useful, plus you would be able to use these variables in other signs as you stated.
     
  8. Offline

    Qi Xiang

    How do I set the trains to keep chunks loaded? oh btw. thanks for the quick reply :)
    EDIT: Nevermind, I figured it out :D
     
  9. Offline

    leagris

    Waiter sign bug

    Hello,

    Waiter sign in Version 1.72.0 does not work as expected.

    Using:
    CraftBukkit version git-Bukkit-1.4.2-R0.1-6-g4a656a3-b2453jnks (MC: 1.4.2) (Implementing API version 1.4.2-R0.2-SNAPSHOT)
    Train Carts v1.72.0
    Train Carts Blocks v1.05
    BKCommonLib v1.33
    SignLink v1.27

    Reproduce:
    1. Build a Q shaped track (a loop with a Y shaped end)
    2. Put a Waiter sign before the track switch leading the the dead-end tow way track.
    3. Have a first train enter or over the dead-end track part.
    4. Have a second train apoproaching the waiter sign.
    While the second train reach the waiter sign, it stops (good as there is a train occupying the forward tracks section).

    As the first train leave the dead-end to re-enter the loop (then freeing the track section), the second train does not move-on.

    If the first train is removed/destroyed, then the second train move-on.

    Expected behaviour:
    The second train should move-on as soon as the first train leave the occupied section.

    Probable causes:
    • The first train going backward fooling the waiter
    • Path finding can't distinguish between occupied VS free portion of a Y shaped tracks.
     
  10. Offline

    Helmi74

    Thanks to Lexlaiden i just found out that Variable Triggers Plugin can change Text on sign - i'm just trying if this works for this case.

    bergerkiller I'm not totally clear how "tag" signs are intended to work - i couldn't find them in the docs - are they undocumented yet?

    I've got this situation here: http://monosnap.com/image/6OHh0JrfbxSbY6lYxvrFrLahf

    One tag sign is under each of the red squares. Basically that worked for 2 or 3 tests and it doesn't work now. The only thing i thought couldn't work is if the train approaches such a switch from a direction faced to the back of the sign so i placed the signs each in a direction where this shouldn't happen but it looks like switching doesn't work well either. It looks like TrainCarts dynamically changes the outlook of the rail parts and that also changes if and how the switches work? That's kind of confusing to me and i couldn't find anything in the docs how i can avoid that.

    Maybe i'm just to unexperienced with MC itself :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 14, 2016
  11. Offline

    bergerkiller

  12. Offline

    Helmi74

    bergerkiller ok so i guess what i showed should basically not be a problem? It still is with the newest version. It looks like trains are completely going wild and random in the switchers. Is there anything i can help you with finding a possible bug?

    Edit: looks like it was my fault - for some reason the update didn't work and i was still running 1.7.0 - it seems to work now with 1.7.1
     
  13. Offline

    leagris

    1.7.1 waiter still does not work before a Y join reverse forward

    Disposition:
    Code:
    Legend: R=Rail, S=RailSwitch, I=In, O=Out
     
            I O
            ↓ ↑
    Waiter  R R
            R R
    Switch  SRR
            R
    2way ↓↑ R
            R
            R
    DeadEnd —
    Once a cart reach the Waiter, it either randomly:
    • Ignore Waiter then collide a parked cart inside the 2way,
    • Detect a cart in the 2way, wait, then get stuck after the 2waay is left free.
     
  14. Offline

    Helmi74

    bergerkiller i'm still confused about the switchers - especially the automatic ones called "tag". I wonder in what situations are they expected to work and in which not. Is there any special constellation of rails at the switching block if there's a tag sign under it to make it work in any case? i got some loops at each end of a track - the track basically works most of the time but the switcher in the loop seems to be confused about what it has to switch and when.

    So are there cases where "tag" doesn't work or are there specialities to avoid for switchers generally? I've experimented a lot but i can't seem to find a system what works and what doesn't and i even don't know if these are bugs in the plugin or in my brain :)

    Thanks for helping out!
    Frank
     
  15. Offline

    bergerkiller

    leagris
    Sorry for the big delay, I really had to fix up the physics in TrainCarts. It was hindering a lot of other things. To get to the point, I built your track, but it appears to work fine. Here is a screenshot so you can verify it is the correct set-up:
    [​IMG]

    The signs underneath are:
    I could push one cart to the 'dead end' and the next cart would wait for that cart to be gone. I could move the dead-end cart away and once it passed the switcher part the waiting cart started moving almost instantly. It could be you used a switcher sign, but if you did, I really need to know what you had on that sign, or what purpose it has. If the switcher switches the tracks in a U-shape, then obviously the cart is going to move, as it no longer has to wait for the dead-end track then. It could be I just fixed it or something, though. So here is a new test version:

    https://dl.dropbox.com/u/3681706/TrainCarts v1.72.1 TEST4.zip

    Helmi74
    The tag sign is the exact same sign as the switcher. It is just an alias for the switcher sign because, a long long time ago (...great, now I have that song in my head), the tag sign existed merely to switch based on tags. Eventually that turned into a switcher sign because of the many statements that could be parsed.

    You should always use the switcher sign, as the tag sign is more or less deprecated. That is why it isn't stated on the WIKI.
     
  16. Offline

    N0Way1

    bergerkiller

    Hi there! First of all, sorry me for the mistakes in my message if you ll find any.
    I have singed up here just to say thank you for your plugin. It is really awesome! My friends and I use it on our server and despite of some bugs
    it works great. I, as it has been already written in this topic by others members, have some troubles with switcher and waiter signs. Hope they will be fixed soon (have not tryed test versions yet, guess those troubles already irrelevant)

    I was also huge surprised of your fast support. All of your answers are extremly helpful and detailed. Good job

    Good luck and best wishes from Russia ;)
     
  17. Offline

    bergerkiller

    N0Way1
    Thanks! Don't forget to report all issues you can possibly find. I finished off fixing up all the problems around vertical rails, but every new issue gone is a step in the right direction. Though it could be many of the bugs you encountered were issues in 1.72.0 which was a hastily-compiled 1.4 version...1.72.1 will fix a lot of bugs that are in that version.

    New test version is up. Test5 changelog compared to test4:
    • Fixed train and cart properties staying behind after train/cart removal
    • Fixed train and cart properties being un-editable when the train unloads
    • Fixed keepChunksLoaded not keeping chunks loaded properly
    • Added unload read-out when doing /train or /cart info and it is unloaded
    • Fixed an NPE when an unloaded minecart is killed or created
    • /train list now also counts unloaded trains
    • Added diagonal support for all signs
    • Added diagonal station launching support (and powering)
    https://dl.dropbox.com/u/3681706/TrainCarts v1.72.1 TEST5.zip

    I really need some testing on this one, especially those that use the keepChunksLoaded feature. I did some extensive tests on them, but nothing beats having 20 players running around on the server. To properly test it, just edit the train and let the train (which keeps chunks loaded) loose. If it takes too long for this train to reach a destination:
    1. Use /train info. Is it unloaded?
    2. Use /train info again. Did the position change?
    If the position changed, then it is still moving towards you, if not, then something could be wrong, or the train is waiting near a station somewhere. The unloaded state should be accurate enough, but you never know.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 14, 2016
  18. Offline

    CommanderGizmo

    Thanks. Will test.

    [EDIT]
    Not sure why, but my switcher signs still seem to be ignored. I broke some and put them back up, but still no go.

    At three way intersection:
    [​IMG]

    The train just rolls back and forth through the switcher signs going straight across. What gives?
     
  19. Offline

    dVoCex

    Thank's bergerkiller, diagonal stations works like charm!
     
  20. Offline

    An0nym8us

    I am using this plugin on my server :). Very useful ;).
     
  21. Offline

    bergerkiller

    CommanderGizmo
    Thanks for reporting, I rebuilt your circuit and indeed, it is not working. I think it is using the directions relative to the minecart instead of relative to the sign. Will fix it in a bit.
     
  22. Offline

    Astrae

    bergerkiller

    Just wanted to say this is an awesome plugin, and I've been adding a huge traincart system to my projects. One of my problems, though, is that sometimes I like to share tracks between multiple cart lines (like real subway systems), but I keep getting collisions at my stations or in the tunnels when many trains manage to sync up and come in at the same time. I've also been running into problems where one train stopped on the tracks will gradually crash the server as more and more trains keep piling up behind it. My current solution is to add a ton of waiter signs at every intersection, and some kill switches to destroy all trains if a station gets backed up, but what I'd really like is a more elegant fixed-block control system. You can see how they work here: http://en.wikipedia.org/wiki/Railway_signalling#History_of_block_signalling. My thought is it would work like this:

    [Train]
    waiter <TTL>
    start:section2
    end:section1

    So the waiter signs (when lines 3 and 4 are added) would become semaphore signs. Line 3 (or "s/start") would indicate that this signs starts the block section by this name. Line 4 (or"e/end") would mark the end of the section. Signs would not scan the track between them (to prevent huge scan calculations), but would internally track weather the section was occupied or not with a lock. The lock would save what time it was created, its start and end signs, and what train it is currently associated with. Trains would also need a pointer to the locks that they currently hold so that they can release them when they are deleted.

    The system would work like this:
    • Locks are created when the first waiter sign names them, and are destroyed completely when they have no signs associated with them
    • If the section is not occupied, an incoming train would obtain the section's lock.
    • If another train approaches a waiter sign and the lock it gives is already in use, the incoming train would be stopped at the sign until the lock releases.
    • The train that currently holds the lock would release the lock only when it moves over the waiter sign that ends that secion.
    • Trains can hold multiple locks at the same time, but each lock is independent of the train it is associated with. If the train is deleted, all locks associated with it are released and can be given out again.
    • Locks are only valid when there is at least one start end end sign associated with the section name; so if a train hits a waiter sign with a "start" that has no matching "end", nothing will happen.

    <TTL> is an optional "Time to Live". This is for large systems where there is the potential for gridlocking and stopped trains is very likely. If this is set, the lock given by this sign will be honored only until this time expires.

    For example:
    • train1 obtains the lock for "section2" as it travels along its path.
      • TTL for that lock is 120 seconds.
    • Along the way, train1 is stopped accidentally by a player on the tracks.
    • An approaching train (train2) is stopped at the beginning of "section2" because train1 has the lock
      • train1 has nowheld the lock for 60 seconds
    • Periodically, train2 checks to see how much longer the lock is valid for.
    • Once train1 has held the lock for 120 seconds, it sees that train1 is empty, deletes the train, then takes the lock for itself.
      • If train1 were occupied, it would continue to honor the lock until the passenger gets out. This could be overridden with a plugin setting

    To prevent permanent locking on servers that do not have "KeepChunksLoaded" enabled, TTL for locks associated with trains in unloaded chunks is always set to 0.

    2-way semaphores (where a train could enter from either side) would have the same section start and end:
    [Train]
    waiter <TTL>
    start:section2
    end:section2

    While I admit this would take a bit of logic to get in to place, it looks like all the mechanical aspects are already there. This would help me immensely since I could control the number of trains currently in my system (since the number of block sections would be finite, I could only have as many trains moving as I have sections), and prevent lockups and collisions when I'm not online.
     
  23. Offline

    bergerkiller

    Astrae
    Hmmm maybe you can try something with the detector signs?
    http://www.minecraftwiki.net/wiki/Bukkit/TrainCarts/Signs/Detector

    You can use those to power a blocker sign when the track section the detector detects is occupied:
    http://www.minecraftwiki.net/wiki/Bukkit/TrainCarts/Signs/Blocker

    This way you can build a section system like you described. Also note that the waiter sign allows the detected length ahead the sign, which you can increment as well:

    Will wait the train until the next 200 tracks are free of any trains.
     
  24. Offline

    Astrae

    bergerkiller

    The trouble with sensors is that they don't work well over long distances and curved track. As for the wait signs- I was under the impression that they scanned the track ahead of them, and I wasn't sure how efficient that would be at scale (I would be looking at putting in 50-70 signs across my system). I think they're perfect for short queues at a station, but I wasn't sure how well it would work once I have 10-20 trains scanning 100-200 pieces of track each at a time. I did something along those lines a looong time ago with minecart mania and my whole server got mad at me for hogging all the server's resources.
     
  25. Offline

    Helmi74

    Indeed having such a section system would be great - I'm running into the same problems than Astrae and for the moment i'm going to avoid including automated trains into the train network but having them run on separate rails for now as i'm unsure how to avoid crashes on a safe way without having to have two people only look after crashed trains all the time :)

    Apart from that i'm starting to love TrainCarts even more every day. You're really doing a great job here, bergerkiller.

    One thing i noticed: When destroying signs that mark a destination i get "you did not select a train to edit" or a similar message and an empty sign instantly gets created again without giving me chance to edit it. I have to delete the whole block where it sits on. Is this intentional and i'm doing something wrong or is it a bug?
     
  26. Offline

    bergerkiller

    Astrae
    I think waiter signs are less efficient, as they have to re-scan the entire path ahead every couple of times. For very long distances, it will probably cause server performance issues, which is why I recommend using the detector sign.

    The detector sign uses the same tracking logic as the waiter sign to find out the detected area, so there shouldn't be a difference...

    Helmi74
    The empty sign is actually not empty - it still has the old text. CraftBukkit simply fails at cancelling sign breaks properly. I do think it is a bug, however. It shouldn't do an onClick if you intend to destroy the sign.
     
  27. Offline

    Helmi74

    Most of the time i try to destroy the sign to create a new one so what i want is to completely remove one and this doesn't work. The only thing i was wondering that this only seems to happen with destination signs and no other train signs. Also wondering about that message i get that seems to come from trains. But if it's a CraftBukkit bug... well i can live with it - it's just a bit annoying :)

    One more question regarding item groups in the config. I found out they're working with IDs. Is it somehow possible to use amounts with groups? 5*fuel doesn't seem to work on a sign where 5*coal works fine. Is there a way to make that work? Is it possible to use fixed amounts in the config?

    I'm working on a automated storage and production system with some pals and grouping is a big issue there.
     
  28. Offline

    bergerkiller

    Helmi74
    Mhh yes grouping like that isn't exactly working right. I can look into that for you though; then I have to somehow multiply the amounts from that group.
     
  29. Offline

    Helmi74

    bergerkiller thanks thats great. (Again) One more question: Is it possible to selectively do chest in or chest out by name or tag of the train? I'm trying to selectively unload chests based on a selection of the player. I can remotely control the content of a sign already using variable triggers. Also spawning a train from remote isn't a big problem but the train would pass several chests with chest out commands - i would only chest out the things the player selected.
     
  30. Offline

    CommanderGizmo

    bergerkiller

    My server has been experiencing intermittent issues where the primary thread locks, severe lag occurs within traincarts (carts move one frame at a time in slow motion while the rest of the game is only slightly choppy), and people are getting kicked from the server with connection errors after a few minutes. Running the /Trains destroyall command three times seems to fix it. It takes three times (no more, no less) to work, and destroys more trains on each run; after this things smooth back out. These issues appear to be getting worse. I am running CB 1.4.2-R0.2, TC 1.7.2-Test5, BK 1.34.

    I do not see why Trains would be the cause, but I have just gotten this error in my log. There is nothing else in the log within a few minutes of this occurrence, and only one person was logged in at the time. Once this occurred all the connection issues went away and things are running smooth again. Of course, we have no trains.

    Any ideas what is going on?
     
  31. Offline

    bergerkiller

    CommanderGizmo
    I suspect this is a problem in BKCommonLib, the parse tree species is part of the transfer sign logic/crafter sign. All of that logic is in BKCommonLib. I suspect it is calling itself...

    EDIT

    See if this resolves that problem. It may not fix all issues though, as some appear to be in TrainCarts as well:

    http://dev.bukkit.org/server-mods/bkcommonlib/files/15-v1-36/

    EDIT2

    New test version which completely fixes all those ghost trains. Do use the above BKCOmmonLib!

    https://dl.dropbox.com/u/3681706/TrainCarts v1.72.1 TEST7.zip
     

Share This Page