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

    bergerkiller

    @UnderMotion ow must have missed it. Anyway, trigger signs now set the train name and destination name to a variable:
    Um you can already divert empty train to other tracks using track switcher signs, so that's not a problem. The spawner sign doesn't spawn a new train until the tracks are cleared, so no problem then either. And with the future 'is track occupied' system you could check for any blocking train too. And the 'keep chunks loaded' issue should be fixed by now.

    Still messing around with permission systems and all sorts of testing. For example, I noticed that I could use the 'pickUp' setting to attract entities too: to auto-suck them into the cart. It's great for auto-pickup systems, but annoying for players since they can't exit the cart without getting sucked back in :)

    Adding a ticket system is what I 'wanted' to do too, with some sort of map + image you could enter. But it's pretty hard to set it all up, since there are multiple trains...
    Perhaps a button with a sign underneath, and when the button is pressed it gives you a map. Only with the map in your hand you can then enter the train, and when entered the map disappears.

    Then you need to somehow keep track of the player and boot him out of the train once he reached the destination...

    Hahaa my TrainCarts API is AWESOME :)
    You can even make trains detonate TNT or open a door, while first nicely stopping at a station :D

    Code:
    group.addAction(new BlockActionDetonateTNT(tnt));
    Allrighty it's now possible to have multiple signs operate on the same piece of track! You can now have 3 signs operating on it on max, if you use sloped rails as well it becomes 5. You can basically attach signs to the block the rails sits on, this way activating that sign as well. It's now possible to combine a track switcher with any other type of sign.

    The track switcher, if not powered, toggles attached levers when any of the statements on the sign match true. This redstone current can be looped around to a destroy sign, this way destroying a cart or entire train if it matches a certain condition.

    Detector sign is a good idea. It will also light up when a player places a minecart on the tracks, will combine that with a special 'push and pull' sign, which will be able to push or pull minecarts around. You can then place two pushers on both ends, and whenever a new cart is placed it will automatically push them towards the middle.

    The detector signs will keep a set of blocks, and whenever one of those blocks get a minecart on top, it will detect it. :)

    Alternatively, which is probably better, I will make stations attract carts in the radius.

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

    MacGyver420

    You're going to have to give signs individual property files at this rate, then one sign could be a station, detector, trigger, switcher.... :p
     
  4. Offline

    bergerkiller

    @MacGyver420 I know, but I won't :)
    It's too much of a hassle to check if the block is still a sign, etc.

    Also, it's giving me a headache just now. Why ow why does Bukkit use entity.dead = true and not entity.die()...now it's almost IMPOSSIBLE to detect if the minecart died. :(
     
  5. Offline

    _frozen

    I know this may be too late since I'm seeing you implementing new features (woo! occupied track detector!) but I have a minor problem.

    I had set up an station configuration with tag signs, then realized the design itself was flawed. So I changed around, moving tag signs from here to there and so forth.

    Now, there are "ghost" tag signs where the carts bounce back instead of continuing, even if theres no tag set on the train. I verified that there are no longer tag signs around the block (even to the point of excavating a 4x4x3 hole and putting a track down the middle). Down the track (like 4-5 blocks away) is the new location of tag signs; they don't even reach there. What can I do to remedy this situation? /train reroute didn't work.

    Also: You mentioned that the feature to sort empty trains are already included. How?
     
  6. Offline

    bergerkiller

    @_frozen That looks more like an issue with the destinations feature, do the carts have a destination set? This bouncing back is caused by an 'SignActionEvent', if there is no sign, this is kinda strange...

    And, on a sidenote, tag signs are going into the disposal bin. They are now called switcher signs, since it no longer serves the purpose for 'just' tags.

    EDIT

    Lucky me, it calls die() internally when it starts removing the entity from the list. Finally a versatile cleanup system...

    EDIT

    Ok I guess the detector sign is fully working...
    My only issue with it now, is that it is extremely CPU intensive...not only does it use pathfinding to follow the track, it also searches all near signs for every block and all minecart members that are near...for long distances this can't go good...
     
  7. Offline

    MacGyver420

    It might be part of the same issue im experiencing with random direction changes. It seems to be happening at corners, or incline changes, where no signs have ever existed. The only thing the direction changes have had in common so far is being near stations (3-15 Blocks) Happens with and without tags set and no destination set.
     
  8. Offline

    UnderMotion

    Well imo I think it would be nice to have a destroyer sign that destroys empty trains, can be useful in some occasions :) But I don't really mind not having it anyways (thanks for the tips btw, never knew these :p)
    Well there's the TrainTicket plugin, which was the one I was using, until it starting getting buggy for me. Maybe check that out?
     
  9. what version is after "1.0.0-R1"?
    tell me.
    edit: I think I am using an old version
     
  10. Offline

    _frozen



    Considering Macgyver's suggestion, I realized that the location where the tag is set is very close to the station location -- 10 tiles away. The station sign indicated it was 10 tiles length, so I removed and remade the station sign, and at the same time reduced the station size to 5. NOW, the train bounces back within 5 tiles. Any suggestions?​

    No clue what I can do. Yes, the train has a destination set. Its the next stop anyways as it s the first stop on the line and this problem affects the inbound to the union station at the center, so..​


     
  11. Offline

    bergerkiller

    @UnderMotion that is now possible by combining a [cart] switcher and [cart] destroy sign together, connecting the lever output of the switcher with the destroy sign. I tested it fully, it's even possible to remove carts with a certain tag :)

    Thanks for the link, will look into it for inspiration.

    @MacGyver420 @_frozen Station launching had issues with insta-direction changing, that is already fixed.

    EDIT

    Yup will have to use maps for this, looks best. Any suggestions to what to display on the map, etc?

    @MacGyver420 Client-sided this is probably not possible, unless I can handle inventory click events made by players. Stacking when picking up minecarts is no problem though.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Sep 9, 2018
  12. Offline

    _frozen

    maps? is there a way to override graphics on said maps? If so, perhaps a way to overlay a train ticket looking graphic?
     
  13. Offline

    bergerkiller

    @_frozen yup you can draw on maps..to some extend though. I'll look into it :)
    Will make tickets for train-specific, which are stored with the train properties. (ticketMapIds)

    Also, detector signs are 100% working, the long distance didn't matter luckily. Do note that you need to attach it to a redstone clock to update it based on player placement inside the target area, train entering and leaving is handled. I can't make placement automatic, since that requires me to search a large area whenever a minecart is placed....I simply don't think that is worth it.
     
  14. Offline

    MacGyver420

    It's possible but has a limited palette, Im currently using ScrollingMenuSigns to display a list of destinations on a map, that users can select while riding the cart, and it allows for a background image.
    @bergerkiller
    How specific are you planning to go with tickets? If its just a "board any train with a ticket in hand" system then a generic ticket graphic would work. If your planning to make it so different trains have different tickets, then a train name and price would be nice. If its going to be a destination to destination system, then that info will need to be on there.
     
  15. Offline

    bergerkiller

    @MacGyver420 Well best would be if the tickets had a 'from' and 'to' location, like real tickets, but implementing that is kinda hard without actual station names...

    Therefore, I guess it's best to use 'nth station eject player' systems: you can buy tickets to travel x stations away, or buy a ticket for the day to travel all day.

    Of course, these tickets will only be active within a certain radius, which you can set at the ticket 'booth'.
     
  16. Offline

    MacGyver420

    That does sound like the best way to do it, and you can get away with only displaying train name and duration on the ticket. Also as im cleaning the 40 minecarts out of my inventory im reminded of something simple that didnt make it to our MM successor thread, Minecarts stacking in your inventory.
     
  17. Offline

    MacGyver420

    Yeah stack on pickup was what i was going for.
     
  18. Offline

    UnderMotion

    I would love it if you make a small tutorial on how to do that, because I'm pretty confused :confused:
    I understand the way switcher signs work but I don't know how to make a variable with one so that if trains are empty they would reroute and if they are occupied they'd go about their merry way [sheep]
    Well the way I imagine it is to have a picture of a minecart on it, include the price of the ticket and the from/to location names. :)
     
  19. Offline

    dockter

    Im getting this error:

    2012-01-01 14:35:27 [SEVERE] [TrainCarts] Failed to perform physics on train 'train7':
    2012-01-01 14:35:27 [SEVERE] java.lang.[NullPointerException]
    2012-01-01 14:35:27 [SEVERE] at com.bergerkiller.bukkit.tc.NativeMinecartMember.postUpdate(NativeMinecartMember.java:446)
    2012-01-01 14:35:27 [SEVERE] at com.bergerkiller.bukkit.tc.MinecartMember.postUpdate(MinecartMember.java:72)
    2012-01-01 14:35:27 [SEVERE] at com.bergerkiller.bukkit.tc.MinecartGroup.doPhysics(MinecartGroup.java:751)
    2012-01-01 14:35:27 [SEVERE] at com.bergerkiller.bukkit.tc.MinecartGroup.doPhysics(MinecartGroup.java:676)
    2012-01-01 14:35:27 [SEVERE] at com.bergerkiller.bukkit.tc.MinecartMember.w_(MinecartMember.java:67)
    2012-01-01 14:35:27 [SEVERE] at net.minecraft.server.World.entityJoinedWorld(World.java:1253)
    2012-01-01 14:35:27 [SEVERE] at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:107)
    2012-01-01 14:35:27 [SEVERE] at net.minecraft.server.World.playerJoinedWorld(World.java:1235)
    2012-01-01 14:35:27 [SEVERE] at net.minecraft.server.World.tickEntities(World.java:1142)
    2012-01-01 14:35:27 [SEVERE] at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:518)
    2012-01-01 14:35:27 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
    2012-01-01 14:35:27 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)

    If I do a /train removeall my server locks up within 15 seconds afterwards.
     
  20. Offline

    bergerkiller

    @dockter mmh I'll look into it, must have to do with getGroup() returning null. Can fix that :)

    EDIT

    Got it, easy to fix. Will make sure that it breaks the physics loop if the group changed in the post update function. What happened is that it performed a post update without ever performing a pre update.

    EDIT

    Love it when the physics are a lot smoother and I have no idea how I managed to do that xd
     
  21. Offline

    dockter

    Any idea why the server goes into a hang state when I use /train removeall ?

    No console error, just the main minecraft thread run at 100% and boots everyone logged in, unable to stop server, doesn't respond to commands.
     
  22. Offline

    bergerkiller

    @dockter can only think of having a LOT of minecarts on the server that need removal...
    However, I'll look into it a bit more. Bear in mind that the coding got changed drastically compared to 1.54, I will even have to call it 1.6 when I release the next version...
     
  23. Offline

    dockter

    U have a version of this 1.6 beta available, I can test it out on my dev server.

    BTW, I dont know if a recent spout or CB change helped, but the maxspeed thing is now working after many builds of this function being ignored.

    Something is goofy, when I have the issue and the server hangs, it multiples all the train carts I have on the tracks my by a very large factor number, I just deleted about 300 minecarts from our world, this with the traincarts plugin removed at the moment.

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

    _frozen

    Well, thats realistic-- a zone-based system is exactly what you are suggesting, and a elegant soultion.
     
  25. Offline

    bergerkiller

    Huray, today adding RAIL meta data. I know...but why not ey? It will make it possible to set rail properties at some point, but the main idea is being able to set detector sign regions using it. Every minecart member keeps track of the block underneath, so adding the rail meta data check isn't too hard to add.

    Only have to be careful with RAM usage: having a separate list of meta data for every track can become pretty large...using empty lists by default I hope to minimize this.

    (though, having 3000 blocks, each 12 bytes min, is still 36 kb. But ow well, whatya do :)

    Code:
    public abstract class RailMetaData {
    
        public abstract void readFrom(DataInputStream stream) throws IOException;
        public abstract void writeTo(DataOutputStream stream) throws IOException;
        public abstract void update();
        public abstract void enter(MinecartMember member);
        public abstract void leave(MinecartMember member);
    
    }
    
     
    Don Redhorse likes this.
  26. Offline

    _frozen

    Is there a way for interested parties (i.e. us) to get a hands on dev build or at least the upcoming lists of changes to signs? I m already dreading changing all the tag signs over to switch signs -- unless there's a way to automate the change over?
     
  27. Offline

    bergerkiller

    @_frozen um I'll upload a dev version I guess, let me just disable all the meta data stuff...
    Do note that detector signs will be failing for now, it was working but that method was a 'overkill' for the purpose. (therefore rail meta data)

    EDIT

    All done, see the BETA 1.6 version on GitHub. Note that it was still at development point in that version, so if you get any odd messages in the log or broadcasted, you know why.

    NOTE: Every sign type has a '[cart]' and '[train]' version. Using cart will apply the sign on individual carts, the train will do it on entire trains. (if possible)

    There are now /cart and /train commands. Use /cart to set properties for individual carts, use /train to set it for all owned carts in a train.

    Available sign types:
    Switcher

    Use the 2nd and 3rd line for the evaluation points. If both contain a number, it will switch as a counter, sending x amount to left and x amount to right in a loop. You can also use:
    Any other name will read the tags from the cart(s).

    Station now has a 'stop' sound, you can disable it in the config if you want to. Cart/train properties are saved in new files.
     
  28. Offline

    xcanner

    @bergerkiller did a quick test of the dev version on test server (will test more tomorrow). Did you look at the problem with chunkloading (we could use speedlimit 1.0 with no problems in 1.8.1, now max speed is around 0.6), seems like the same as 1.54 to me.
     
  29. Offline

    robxu9

    @bergerkiller: there seems to be an uphill bug :( http://youtu.be/rFbltsS5emA
    (I just started uploading it, so it might be still processing)
     
  30. Offline

    MechanID

    after quick testing
    1 keepChunksLoaded not working
    2 station launches minecarts and it seems they can move to sunset without powercart or power rails
    3 something weird happens with train when there is missing rail on the way
     
  31. Offline

    bergerkiller

    @MechanID
    1. Why isn't it working? I fully tested it and it loaded all nearby chunks perfectly, and didn't get unloaded.
    2. Positive?
    3. What happens?
    @robxu9 will look at it

    EDIT

    ugh can't seem to replicate that behaviour, possible to join that server in offline mode? (getting the game in 4-5 days)
     

Share This Page