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


  3. Offline


    That dosn't help at all...

    I don't need to learn how to set up a server, I already have that.

    But which files shall i copy to /plugins?
  4. Offline


    What are you talking about? Could we know what do you want?
  5. Offline


    I want to install TrainCarts to my server, I am used to only put a .jar file in the server, and thats all. The jar file does the rest...
    But I don't find the .jar file in the folder I get when I download TrainCarts...
  6. Offline


    The file you download IS the jar...this is what you get when you let WinRar open .jar files automatically...jar should be opened by java, not an archiving program.

    Download TrainCarts.jar from GitHub (Direct link)

    Odd part is, this is not the first time someone posts this reply. I will add a second download link where the jar is in an archive, then they can use it at least... :D


    Also an update: Made a 'spawn train' sign to spawn a train (when powered) with a starting velocity on the tracks above the sign. Simple format:

    For example, this spawns a train with 2 powered minecarts, followed up by 3 storage minecarts and 8 minecarts, moving forwards:
    This way you can max. spawn 30 carts at once. Obviously you could add two signs and make the two trains link mid-way. :)
  7. Offline


    Nice idea, I also planed to add a spawntrain to my RedstonePlugin, but you'r faster :)
  8. Offline


    Best is I discovered a bug while making this. In v1.22 the initial 'custom yaw' is not set, thus when linking it moves the opposite direction. I fixed that as well. Also, a video just for developers' sake. :)
  9. Offline


    I don't think I have did this right, nothing works. :O
  10. Offline


    You need the latest Craftbukkit version. An older version doesn't have the world.getUID for some reason, causing an error on boot. (a friend had this too)

    And always look through the console/log to see if TrainCarts is enabled, has errors, etc.
  11. Offline


    It doesn't looks like it is installed at all... :S

    It is possible to get a link to a download which not is to a zip file?
    I think that is the problem...
  12. Offline


    Added a full installation guide at the bottom of the main post. Also, already added a link to download the archive (.rar) with the plugin in it.
  13. Offline


    I don't host the server by myself, the host is Phoenixerve, so the server is not on my computer.
  14. Offline


    Yeaah then I have no idea where you have to place the file, never used a server hosting service. Maybe you can access your (server) files somewhere on the site?
  15. Offline


    I have sent you an message, we can continue there.
  16. Offline


    Alright, alright. Small goals to start with =P

    Step 1: I'm working on implementing a listener class for Minecart Mania. I can't get the trains to respect the Minecart Mania control blocks currently, and a listener class would be a relatively simple way to fix this.

    Step 2: Work on custom logic and extend the Train Carts class -.-
  17. Offline


    @Astrae What 'train events' do you need? I guess one that handles collisions, one that handles the 'group updating' part. I do have to follow some tutorials then, first time I implemented a listener into something. :)

    On a sidenote: You can obtain the MinecartMember from the regular Minecart entity returned. My plugin contains features for this as well, such as MinecartMember.get(Minecart m)

    Also, do you need any specific functions for Minecart Mania? Reversing a train? Stopping a train? Slowly stopping a train? Eject all passengers? I can easily add those from there.

    Ok guys I think I got something you will like for realz. :)

    Powering the left sign, not powering the right sign moves trains to the left.
    Powering the right sign, not powering the left sign moves trains to the right.
    Powering both the left and right sign centers the train in the middle (brake)
    Not powering left and right disabled this, nothing happens.

    I could go and make it very difficult with force signs, but this seems the easiest for the user. :)

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


    Would be nice :D

    Edit: I wrote my post befor i saw the new one xD I think it is also a great idea
  19. Offline


    ok in the meantime added the following events:
    - GroupUpdateEvent
    Is raised 1-4 times per update. It comes with an 'UpdateStage'.
    FIRST is before the 'pre update calculations', if you need to know the velocity before
    BEFORE_GROUP is before the group update and after the velocity update
    AFTER_GROUP is after the group and before the final position updates
    LAST is after the position updates and acts as a monitored event
    All events are cancellable, the last one ignores this.
    - ForceUpdateEvent
    Is called right before the new force is applied to all the carts. It has a force property.

    All the above events also return the Group with it. Only need to add a sort of 'direction' BlockFace property to the members; it is pretty much impossible to get the direction a train is traveling. :)
  20. Offline


    It would be amazing if you could put coal into a storage cart, and have it automatically fuel a power cart. :D

    Of course I have no idea how complicated that would be to do...
    Just an idea.
  21. Offline


    That is actually pretty easy, and also a good suggestion. :)
    Only have to locate the part of coding getting executed when the powered cart runs out of coal...

    Also, the 'settarget' script works. I can now click a minecart of a train and click on a block to go to it, and it accelerates accordingly. Really nice, works with both acceleration and deaccelerion.

        public void setTarget(Location target, double targetVelocity) {
   = new VelocityTarget(target, targetVelocity, this.getBukkitEntity());
    @GreatAdam I added it, configurable of course. It will now get coal from the Storage minecarts neighbouring the powered Minecart and continue tuffing around. :)

    Default will be off, it would not be nice to lose your just-mined coal. :)

        public boolean onCoalUsed() {
            if (TrainCarts.useCoalFromStorageCart) {
                for (MinecartMember mm : this.getNeightbours()) {
                    //Is it a storage minecart?
                    if (mm.type == 1) {
                        //has coal?
                        for (int i = 0; i < mm.getSize(); i++) {
                            if (mm.getItem(i) != null && mm.getItem(i).id == Material.COAL.getId()) {
                                 return true;
            return false;
    Ok updated to v1.23, see changelog. A few noticable changes are the signs, which are still a bit in testing phase.
    (Also, see main post)

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


    Actually, Minecart Mania has a very nice set of events it throws to make it simple to be compatible with the mod. I was playing around last night and I was able to catch all of the events, but I couldn't quite parse them (just need a night alone with the source code). By simply listening for the different Minecart Mania events and reacting appropriately, you would instantly be compatible with it. There are just a few events that you would need to listen for like MinecarLaunchedEvent and MinecartCaughtEvent. The full list is in the MM source code.

    Here's a snippet of what I got working:

    pm.registerEvent(Event.Type.CUSTOM_EVENT, MMListener, Priority.Normal, this);
    A new listener class (MMListener):
    public class TrainModMMListener extends CustomEventListener implements Listener{
        public void onCustomEvent(Event event){
            //All custom events flow through here; pick out only the MM events
                MinecartManiaEvent MMevent = (MinecartManiaEvent)event;
               //Launched event
               //note: this doesn't seem to parse the events correctly... need to find another method
                    Util.log(Level.DEBUG, "Launch event caught successfully!");
                    MinecartGroup train = MinecartGroup.get(((MinecartMotionStartEvent) MMevent).getMinecart().minecart);
                    if (train != null) {
                        //set the speed based on the MM world maximum... need to find this somewhere
                        for(MinecartMember member : train.getMembers()){
                //Caught event
                else if(MMevent.getEventName().equalsIgnoreCase("MinecartCaughtEvent")){
                    Util.log(Level.DEBUG, "Catch event caught successfully!");
                    MinecartGroup train = MinecartGroup.get(((MinecartMotionStopEvent) MMevent).getMinecart().minecart);
                    if (train != null) {
  23. Offline


    Mad love it only dis like the sign spam thing when they pass over the station sign But mad :S an also may i suggest you should add delay signs with they will wait for a certain amount of time then go like minecart mania Mad thanks alot for this epic plugin keep up your work :D
  24. Offline


    @Astrae ok I could look into that I guess. The listener does not 'sub-divide' the events? Like:
    public void onMinecartLaunch(MinecartLaunchEvent event) {
    Because I did that in my listener.

    Also, which Minecart Mania plugin do I need to reference to handle these events?

    @King_KYl3 You can make those using the station sign. Simply power both sides, and remove power from one side to launch the cart again. And it's still in testing phase, so could be some messages were still there... xd
                    Util.broadcast("NORTH: " + north + " | SOUTH: " + south);
    Yup... my bad xd


    Ok I got everything set up, including a message when Minecart Mania was detected. The brake/station block works now. EDIT2: You can also change the direction of trains by clicking on them, now.

    Ok updated to v1.24. Minecart Mania support is added (for the things I found that were not working) and improved some minor functions here and there.

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


    Mad but can you add the obsidion block with minecart mania its a delay block and you place a sign underneath it and with "hold for {time]'' only on first line and it will hold the minecarts for the many seconds XD
  26. Offline


    @King_KYl3 simply waits the amount for every cart... :D
    I'll see if I can make it ignore the carts after the first in the onCaught event.

    Although...that could also be useful... :p
  27. Offline


    does this plugin conflict with any other plugins or cause Read Time Out errors? ever since I've installed it my server keeps timing out after an hour, sometimes after 5 min
  28. Offline

    Celtic Minstrel

    @Astrae – This condition:
    will always return false because MinecartManiaEvent.class is of type Class while event is of type Event. For future reference, what you want is this:
    if(event instanceof MinecartManiaEvent)
  29. Offline


    @erdrickk That shouldn't happen, never had it either. Neither have I noticed plugins conflicting with it (I use quite some). All I can think of is Minecarts not getting saved correctly (different type), does the same happen when you force a save? (save-all)

    @Celtic Yes, I know, but it was more of an example to me. If your interested; here is the coding I currently use:
    public class TCCustomListener extends CustomEventListener implements Listener {
        public void onCaught(MinecartCaughtEvent event) {
            MinecartMember mm = MinecartMember.get(event.getMinecart().minecart);
            if (mm != null && mm.getGroup() != null) {
        public void onClicked(MinecartClickedEvent event) {
            MinecartMember mm = MinecartMember.get(event.getMinecart().minecart);
            if (mm != null && mm.getGroup() != null) {
                if (mm.isMoving()) mm.getGroup().stop();
        public void onCustomEvent(Event event){
            if (event instanceof MinecartCaughtEvent) {
                this.onCaught((MinecartCaughtEvent) event);
            } else if (event instanceof MinecartClickedEvent) {
                this.onClicked((MinecartClickedEvent) event);
    Ok added some example/tutorial videos for the signs. No better way of explaining how they work than a video. :)

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


  31. Offline

    Celtic Minstrel

    I realize you would know; I just wasn't sure Astrae knew.

Share This Page