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

    I just noticed. This is why I added a configuration in it. Open the configuration in a text editor (preferably notepad++). You'll see this:

    Change cartDistance: 1.42 to cartDistance: 1.7
    This will increase the kept gap, decreasing the collision chance.

    By changing the distance kept between carts you can change how close together the carts are. Currently carts stop instantly on collision (no fix yet), so you'll have to do with increasing the gap to prevent collisions. :)
     
  3. Offline

    Gynthar357

    okay, i changed the config a bit, it works some sort of, but it strongly depends on the length and the ammount of people who are in the train simultaneously. with a long train and many people in it. it sometimes randomly collides on straight tracks. however, with a relatively short train and only one person it goes quite well now.

    i changed the cartDistance to 2.0 now.

    thanks for you tips and good luck developing the plugin!

    Cheers! :)
     
  4. Offline

    epsn

    thanks so much been waiting for this
     
  5. Offline

    V10lator

    Great work!
    But there is still much to be done. I tested it first on a track build only for testing it. The first time the train didn't move at all, Then I played a bit with switches (great for automatic train disconnections, btw) and triggered a few collisions. I found a few bugs while doing that but there were no errors in the log and I'm tired so... I'll report them next time. ;)
    The last but occured when I wanted to test this on a earlier builded track: The minecarts didn't link to a train anymore.

    And a minor bug: "Train Carts version 0.6 is enabled!" but I downloaded 1.0.

    //EDIT: BTW: Don't you want to share sources?
     
  6. Offline

    bergerkiller

    Obviously I forgot to change the version in the plugin.yml...sigh :eek:
    And yes the collisions are a pain. I tried every imaginable way to prevent the train from stopping, but the endless cycle of collisions is hard to stop...if only it was cancellable.

    Note: I am working on 'track check' before linking (will prevent faulty linking for always) and some way to stop the collisions. I'll increase the cart distance once that is finished and upload a 1.1. (with proper version number, lol)

    If you notice any bugs, feel free to report them. The code is quite complicated so bugs are to be expected. :)

    And it's a solo project, so didn't mind setting up Github for it. Will look into that in the future.
     
  7. Offline

    V10lator

    Simply include the sources in the jar... ;) Maybe if you would do that it wouldn't be a solo project anymore (I'm interrested but not sure if I have enough skills. But if not I think I can learn from the code. :))
     
  8. Offline

    bergerkiller

    Ow that is what you mean. :)
    I added a separate source link before, I'll add the source java files in the jar file next time.
     
  9. Offline

    V10lator

    It bwas just an idea. There are more ways to share sources than github. :)
     
  10. Offline

    bergerkiller

    Yup, although I don't really invest time in it. :)
    Update: Linking is fixed: uses a (nifty) adjacent track inspector method to check if two minecarts share the same rail upon linking. It all comes down to this function:
    Now adding a temporary HashSet with 'faulty links' to prevent lots of these (CPU-heavy) calls every 2 ticks.
     
  11. Offline

    bergerkiller

    Ok good news. After some serious native coding I managed to ban all cross-Minecart collisions, make occupied carts go with the same speed as normal carts and prevent lots of bugs this way. Also special thanks go to @Shamebot for helping me out. :)

    It did require me to copy some native code, so I added source links on top of each function. Also, I added marks to show where I did changes.

    Will soon upload v1.1 which solves a lot of bugs.
     
  12. Offline

    riotherio

    Hey man , You're AWESOME!
    But one question : Is it ok to run this plugin with afforess's minecart mania?
     
  13. Offline

    bergerkiller

    Sure, go ahead! I made this plugin especially compatible with other plugins by making the usage as simple as possible. :)

    *added note* change the configuration if you want to increase the maximum speed. This will probably require a change in cart distance (forcers) too, but not sure.

    Btw: video v1.1 incoming, and it pretty damn amazing! It could be a client mod...yet it isn't. :D
     
  14. Offline

    V10lator

    True. This is awesome.
    I'm updating right now and I had a short look in the sources. I think if I read me in I'm able to understand what's going on but I will be sure when I find the time to do so (a bit busy atm). :)

    //EDIT: I inked together 3 carts and started them alone. After a while I had a look what was up because they needed to long for the track. All 3 carts where at the same place (so it looked like one cart) and they where standing on a activated booster rail (not reproducable till now).
    ALso it's a bad idea to jump with this, have a look st this video:

    I don't know if the "hanging in the sky" and don't load chunks bug is related to this or to inception and there are no errors in the log. :( But after some retries I realized that the cart moves out of the tower (large tower with a hole the carts should fall down) and it dont stop at the ground, too. Also if I search the carts on the track after the server reload I find 0-3 (so sometimes 0, than 2, then all 3, ...).
     
  15. Offline

    bergerkiller

    I noticed something like this, too. I believe it has to do with my Collision update, it causes the cart to penetrate through the ground...I'll look at this tomorrow - again. :rolleyes:

    EDIT

    Ok most things (like the jumping) can be fixed by setting removeDerailedCarts to false. Although, if it doesn't link onto a track below it will penetrate the ground till lava level where you will burn. BURN. No idea why collision with the ground is ignored for my 'special' MinecartFixer type. I'll definitely look into that. :)

    EDIT 2

    Really odd. This bug only happens when the cart is occupied...for the entire group. Hope it won't be too hard to fix this bug...

    This class is currently penetrating the ground when occupied

    EDIT 3

    Saw your video, and yeah, that is basically what happens when an entity ignores the ground. Won't happen if the cart is empty, though.
     
  16. Offline

    gamemaster1494

    It seems there is still a collision problem... I had a lot of break tracks and 3-5 carts would keep going as if they were bump powering each other. Also for some reason the plugin stops working.... Anothing thing i have noticed is the trains dissconecting for some reason, and also derailing... I would really love to get this working... Its awesome so far and that is with all the bugs!

    SUGGUESTION: can you make a sign that you place next to powered rails and on = launch/boost train off = stops all cars instantly... Would help with making train stations ^^
     
  17. Offline

    M1sT3rM4n

    Good concept. My players will like being able to trade with a lot of carts :)
     
  18. Offline

    Mew32

    They dont seem to stop very well on non-activated powered rails... Could you fix that?
     
  19. Offline

    bergerkiller

    Thanks for the input. :)
    I have a 'stop' routine in the MinecartGroup which stops the train instantly (I use it to stop the train upon colliding with a head-on block). I can add it so it will (slowly?) stop when one or more carts move ontop of breaks.

    Will look at the collisions. I had disabled passenger-minecart and minecart-minecart collisions, no idea why this disables block-minecart collisions too.

    EDIT

    Derailing is a setting. It means that minecarts are removed from the group (train) when they derail. I will make it a standard 'false' setting for now, you may have to remove the config.yml to use the new settings.

    EDIT 2

    Tracked down the precise location of the Collision bug. It is in the overridden move function. This scales down the whole bug, so I bet it is fixable. :)
    Ow and for some reason you die upon impact, is this vanilla? I had god-mode on.

    Edit 3

    Ok powered rails (GOLDEN_RAILS) are simply too buggy to use it as I use it now. Going to divide given force over all carts when one cart drives over it, or, if they are off, remove force from all carts.

    Ok updated to v1.15. Fixed the collision bugs, powered rail bugs and 'tried' to limit the amount of annoying cart 'wiggles'. I noticed that this has to do with CPU power. The more lags the server has, the weirder they will act. (probably because I did not handle different timescales in my coding)

    Also, a cart jumping video

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

    koron

    After ten seconds the plugin aktiv, complet server crash:

    2011-08-11 23:21:13 [WARNING] Task of 'Train Carts' generated an exception java.lang.IllegalArgumentException: Cannot measure distance between worlds or to null at org.bukkit.Location.distance(Location.java:327) at com.bergerkiller.bukkit.tc.MinecartGroup.updateGroups(MinecartGroup.java:52) at com.bergerkiller.bukkit.tc.TrainCarts$1.run(TrainCarts.java:96) at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:137) at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:438) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361) at net.minecraft.server.ThreadServerApplication.run(SourceFile:422) 2011-08-11 23:21:13 [WARNING] Can't keep up! Did the system time change, or is the server overloaded?
     
  21. Offline

    gamemaster1494

    Very nice. Thanks for the fix. Now however there is a new problem... It seems when the carts are stopped they try to even out the spaces... And for some reason one of the carts just starts going to the front... And goes threw the other cars. When they launch they all screw up and start to separate... It causes major problems due to them decreasing the speed of what they should go at.
     
  22. Offline

    bergerkiller

    Seems that this plugin is never finished... :p
    First one: Must be because I removed world looping in the past, will do that again...
    Second one: When carts go through each other the collection (the train/group) went into reverse, but even then this should not happen. I'll try to reproduce it, but not sure how. Will look at the launch bug too.

    Edit 2

    @gamemaster1494 Got it. It *kinda* glitches horribly when trying to get out of the launch stance, and because of a possible negative force the group is reversed. Thanks for reporting. :)
    I fixed this now, it took some test-around but it worked.

    Also, added a Location.world == Location.world check in the loop (perhaps it was null or some internal net.minecraft error, I will never know)

    The good ol' block zero collision bug returned. Let's see if I can fix this without removing the passenger-minecart collision prevention all together. [Fixed]

    Will now update to v1.16.

    Ok after quite some bug fixing I updated the source and jar file to v1.16. It should allow the full use of launchers. Also the bug mentioned by @koron, although I am not sure if that error was even possible. :)

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

    40540057

    where has this plugin been all of my McLife ... will install asap and get back to you with any bugs / suggestions
     
  24. Offline

    thehutch

    Epic plugin going to test some features for you and make the testing a little bit easier for you. Also I know you have been working hard on this plugin been watching you with errors in the plugin dev forum :) maybe you should take a break.
     
  25. Offline

    bergerkiller

    Hehe I'm fine. I will need to develop the skill to absorb as much information as possible, deal with sharp deadlines and deal with stress in the future anyway. :p

    Note: working on an awesome plugin called "NoLagg". It will prevent all sorts of server lag causes. An overload of dropped items is already fixed: max amount of items per chunk and spawn restrictions. TNT explosion lag 70% decreased...lol :D
     
  26. Offline

    M1sT3rM4n

    Do you have some benchmarks on how much CPU usage this plugin takes? Also can you implement a feature that auto-deletes these trains after a set time?
     
  27. Offline

    bergerkiller

    Well I made the videos you see on a 2.0 ghz dual core CPU with 2.5 gb ram while running a server, fraps, eclipse, Minecraft in lowest quality and some other apps in the background. I honestly have no idea if it lags, should test that at some point. It shouldn't lag too badly, the only CPU intensive operations are:
    - get the group from a Minecart (keys are Minecarts)
    - loop through all entities in the world, fill a new array of minecarts and loop through this generated array twice
    - Calculate the yaw for the carts. (requires one or two getBlock calls for every cart)
    - check if two carts share the same rails (only upon collision) (loops through all attached tracks)

    If someone wishes to test it, please go ahead.

    I will look into a train removal method, perhaps in onChunkUnload. Not sure about a set time, under what circumstances should this time be reset?
     
  28. Offline

    M1sT3rM4n

    I thought it would be a good idea for the plugin to check the entire world (?) after each time cycle defined by the user (say 5 minutes or 1 hour)
     
  29. Offline

    bergerkiller

    But what if the train is occupied? It would cause a serious interruption. Note: if the train is in an unloaded chunk nothing happens. It uses the cart's internal functions with some onVehicleUpdate/collision event handlers to move the train. These functions/events don't fire in unloaded chunks. I'll do some testing with the amount of trains. :)
     
  30. Offline

    randeri221

    awsome!
    thx i needed that so badly :D
     
  31. Offline

    bergerkiller

    Did a benchmark with someone elses computer (3.2 ghz overclocked to 3.6 ghz, 4 cores) and we had 6 trains of 9 carts running. The cpu was around 10%, but it had some serious lag. (probably because of ~60 entities being updated to all players over a 5 mbps network connection). It hardly consumes CPU, but it can become network-heavy because of all the smaller entities requiring updates. (basically the same as if you had 60 individual carts going round)

    No lag when driving a 50-cart single train around, cpu somewhat the same.
     

Share This Page