DiveCoaster plugin

Discussion in 'Spigot Plugin Development' started by BroodRooster, May 17, 2016.

  1. Hi Developers,

    So I wan't to make a DiveCoaster plugin. As shown under here.
    [​IMG]

    I think its something with VehicleMoveEvent. The only Thing I don't know is how to set the velocity to the 2 carts left and right of him. Here is my code:

    Code (Text):
    public class Main extends JavaPlugin {

        public void onEnable() {
           
        }
       
        @EventHandler
        public void onMoveEvent(VehicleMoveEvent e) {
            if (e.getVehicle().getCustomName().equalsIgnoreCase("DiveCoaster")) {
                if (e.getVehicle().getVelocity() != null) {
                    Vector vec = e.getVehicle().getVelocity();
                   
                }
            }
        }
    }
     
    Greats,
    BroodRooster
     
  2. Code (Text):
    public class Main extends JavaPlugin implements Listener {

        public void onEnable() {
           
        }
       
        @EventHandler
        public void onMoveEvent(VehicleMoveEvent e) {
            Entity cart = e.getVehicle();
           
            if (cart.getCustomName().equalsIgnoreCase("DiveCoaster")) {
                Vector vec = cart.getVelocity();
               
                if (cart.getCustomName().equalsIgnoreCase("DiveCoaster2")) {
                    cart.setVelocity(vec);
                }
            }
        }
       
        public boolean onCommand (CommandSender sender, Command cmd, String CommandLable, String[] args) {
            if (cmd.getName().equalsIgnoreCase("DiveCoaster")) {
                Player p = (Player) sender;
                Location loc = p.getLocation();
               
                p.getWorld().spawnEntity(loc, EntityType.MINECART).setCustomName("DiveCoaster");;
            }
            if (cmd.getName().equalsIgnoreCase("DiveCoaster2")) {
                Player p = (Player) sender;
                Location loc = p.getLocation();
               
                p.getWorld().spawnEntity(loc, EntityType.MINECART).setCustomName("DiveCoaster2");;
            }
            return true;
        }
    }
    So now I updated the code. But it still doens't work. Can somebody help me out here?

    Greats,
    BroodRooster
     
  3. Don't forget to register your event listener and make your class implement Listener
     
  4. You could move the main one and make the side ones keep teleporting to the side of the main one?
     
  5. Also you're setting the same velocity that you're getting? o.o
     
  6. No. He is checking for a name, storing the velocity of the cart with that name. After that, he checks the same cart for an other name and sets the velocity based on the one he got previously...
    My eyes hurt when i was reading that...
     
  7. So how would I give the other one that velocity?
     
  8. Are you trying to make the passenger set the velocity? eg the cart goes in the passengers direction?

    if so do entity.setVelocity(player.getLocation().getDirection());

    idk exact code xD not on computer
     
  9. I'm trying to let the two carts have the same Velocity. So the are moving with the same speed.
     
  10. Listen: This is a forum about supporting plugin development. Your question has nothing to do with the spigot API, you are simply asking for spoonfeed. We wont spoonfeed you. I will gladly help out if you have questions regarding the API or how to implement a certain task.
     
    • Like Like x 1
  11. Bacause its a Alfa version of it. So keep your mouth close, and try it by yourself, Haha i'm so evil MOEHAHAHAHHAHAHAHHA
     
  12. No don't go and say it's so beautifull if it don't work. By the way, I've already made one ;).
     
  13. Okay post a preview in here than
     
  14. I feel if you make them the same velocity there's other factors that might make it mess up and not stick together...
     
  15. I will post it around 21:00
     
  16. Where's preview?
     
    • Agree Agree x 1