More out of MineCart's!

Discussion in 'Archived: Plugin Requests' started by Marius A. Winsjansen, Jul 30, 2011.

  1. Hello,

    I wonder if its possible to make mod that make's it possible to "stack" minecarts in a row, like a train, so different players can ride togheter in 1 "train"?

    Would be awsome, all tho its probly not that usful tho!
  2. Offline


    I REALLY want this. Minecarts suck currently. Storage minecarts can't move without powered pushing them, but the collisions are awful and they bounce off each other or get stuck inside each other. Make it to where if a minecart links to a minecart if it collides with it. Hell, if people don't want it to do this on collision, make a "linkable" variable, and people can set certain minecarts to be linkable.

    Marius, this is EXTREMELY useful.
  3. Its brilliant to see others that are interested in this like me!

    Yeah, i like what you say and i aggree! It should be more focus on the MineCarts in the game! On the most of the servers out there, peoples nerly use them.. why? its not good, ass you said!

    Its only 2-3 mods out there for the Carts, and they really do nothing much!

    It would be awsome to add some more function to some carts, (like the normal one) so they can go by them self! So, if a normal one is first in line, it drags the others!

    And i love your idea btw, when a cart hits another, it links! would be SO greate!

    All develobers out there, go to work!:)

    It would also be awsome to have a possibility to push a button and then get a minecart!
    Lets say, i am on a rollorcoaster, and i am at the start, and whant a minecart at the start instead of taking out of a chest and MOSTLY instead of making a HUGE redstone creation to get a auto minecarft give type off thingi!

    I actualy dont have anny idea on how to get that to work, but maby by having a chest under a rail and pressing a button and a minecart goes out of the chest and to the rail! Something like that, i dont know!
    I am just saying my ideas out loud:)

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


  5. Offline


    I'm extremely bored and this seems a nice plug-in indeed. I'll see if I can "bind" two minecarts together.
    (handling velocity updates combined with obvious force distribution among the carts)


    Well this is the first time I end up using no events at all. An "EntityCollideWithEntityEvent" is missing, so I end up looping through all entities in a repeating task.


    I did it! I managed to make two minecarts move over a track completely connected :D

    Corners work too? Didn't expect it to be this easy :O
  6. Lovly, nice too see you liked my idea and worked on it!! :D

    Can you make more carts toghere, and different types also?

    Let me know when you are finnish whit a test version :D
  7. Offline


    I'm already designing a similar plugin called CartModifier, I'll see if I can get the trains feature.

    EDIT: Didn't notice bergerkiller was already working on it. Shit. ;(
  8. Yeah, it would be awsome!

    Also, if it can be used togheter whit the MineCart Mania, it would be create! Since that plugin got almoast everything exept the possibility to ride toghetere!!!:)
  9. Offline


    Works. 100%. Works !!!!

    I just made 20 carts bound together in a single train, no commands, no events, all in a runned task!
    Only thing to fix: 180-turned carts move the opposite


    Hills work too. Only thing now is 180 degrees
  10. damn, i am so excited to see this! :D i CANT w8 :D:D

    do you think it takes much more time? :D

    it would be SO awsome if you logged on to my server and showed me and we could test it out and talk more there when you have a test ready for instaling :D
  11. Offline


    Lemme make a video for ya :D
  12. Awsome! :D

    I am updating the web browser on and on and on to see when your done :D
  13. Offline


    Berge can I collab on you with this one, I can make an epic video :p
  14. If you are going to make the video on a SMP server PLZZZ let me join :D
  15. Offline


    How do you not make a video of a Bukkit plugin on a serveR?
  16. What do you mean?
    He is going to make a video on how to use it!

    oh, i read wrong! and i write wrong on the last comment, i meant if he is going to do it on a offical and open server for, not dedicated!:) sorry!

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


    Yes, and he is making the plugin with bukkit, so he is using an online server, can you join, maybe, depending on whether he can be bothered to port forward
  18. Offline


    yup I am.

    Note: it's a bit laggy/buggy since Im hosting a server, running the game, running Fraps and eclipse all at the same time on a dual core 2.0 ghz cpu. But it will demonstrate that what is currently achieved. Ignore weird cart teleportations, doesn't happen w/o recording.

    And running on a local server, so no port forwarding sorry. :)

    I'll give some idea of how this works, since it's pretty easy.
    What happens:
    Every 0.5 seconds it is checked if two carts are close enough to form a pair or join a group.
    Every tick it is for every group calculated what the forward speed is. The average.
    Every cart is then pushed with the same force.
    What I haven't added yet is "keeping distance a certain value". I will add that later on.
  19. Offline


    (full stop)

    So, you wana collaborate?

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

    i typed wrong, and as i said, i meant if he had a server that peopls could join, or if i only had a dedicated server that only he had permission to play on! Like it seems he have!
  21. Offline


    @Tster Sure, if you can make a nice video of it go ahead. But let me fix a few minor bugs first. At the moment the velocity of every cart is equal. I have to add a variation to it to remain the same distance between carts.
  22. Offline


    Ok, atm I will develop, and when we are further through the promo vid can be a train station(I whip ass with redstone)
  23. Offline


  24. Offline


    Oh my god, legend

    How does it store the minecarts linked, a hashmap?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
  25. SO awsome! can you add other carts to the train to? That would be so awsome!
  26. Offline


    xD Thanks.

    Time for some source I guess. It is pretty basic. See this class I made:
        public static double getForwardForce(Entity e) {
            Vector v = e.getVelocity();
            Vector rval = new Vector();
            // Convert rotation to radians
            double ryaw = -e.getLocation().getYaw() / 180f * Math.PI;
            //double rpitch = e.getLocation().getPitch() / 180f * Math.PI;
            double force = Math.sin(ryaw) * v.getZ() - Math.cos(ryaw) * v.getX();
               return force;
        public static void setForwardForce(Entity e, double force) {
            double ryaw = -e.getLocation().getYaw() / 180f * Math.PI;
            Vector f = new Vector(0, e.getVelocity().getY(), 0);
            f.setX(-Math.cos(ryaw) * force);
            f.setZ(Math.sin(ryaw) * force);
        public class MinecartPair {
            public HashSet<Minecart> mc = new HashSet<Minecart>();
            public void eventForce() {
                double force = 0;
                for (Minecart m : mc) {
                    if (m.)
                    force += getForwardForce(m);
                force /= mc.size();
                for (Minecart m : mc) {
                    setForwardForce(m, force);
    getForwardForce/setForwardForce took me a while to make. They are the key behind everything atm. This is how all carts are stored:
        public static ArrayList<MinecartPair> pairs = new ArrayList<MinecartPair>();
        public static HashMap<Minecart, MinecartPair> addedPairs = new HashMap<Minecart, MinecartPair>();
    No events are used. Everything is done is two scheduled tasks. One calls for every pair eventForce, the other makes pairs:
                        ArrayList<Minecart> mc = minecarts(w);
                        for (Minecart m1 : mc) {
                            for (Minecart m2 : mc) {
                                if (m1 != m2) {
                                    if (m1.getLocation().distance(m2.getLocation()) < 2) {
                                        //validate pair not added yet
                                        MinecartPair p1 = addedPairs.get(m1);
                                        MinecartPair p2 = addedPairs.get(m2);
                                        if (p1 == null && p2 == null) {
                                            MinecartPair p = new MinecartPair();
                                            addedPairs.put(m1, p);
                                            addedPairs.put(m2, p);
                                            getServer().broadcastMessage("PAIR ADDED");
                                        } else if (p1 == null && p2 != null) {
                                            addedPairs.put(m1, p2);
                                            getServer().broadcastMessage("MEMBER ADDED");
                                        } else if (p2 == null && p1 != null) {
                                            addedPairs.put(m2, p1);
                                            getServer().broadcastMessage("MEMBER ADDED");
                                        } else if (p1 != null && p2 != null && p1 != p2) {
                                            for (Minecart m : {
                                                addedPairs.put(m, p1);
                                            getServer().broadcastMessage("GROUPS COMBINED");
  27. Offline


    What event is it called under?
  28. Offline


  29. Offline


    onEnable. It is a scheduled task running 24/7. :)
    Everything is in one class too.
    @cholo yep. It takes the average of all velocities. Since all carts have the same weight (atm, will add storage carts too) you can do this. For example, one group of 2 carts collide with a standing-still cart, then 2/3 of the speed remains.

    Now the tough part: get every pair and remain a distance.
  30. bergerkiller, your my god!!!

Share This Page