How can i disable 'backscatter', of a minecart?

Discussion in 'Plugin Development' started by frederikbontved, Dec 27, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    frederikbontved

    Hey bukkit-community.
    I'm currently working on a car plugin, where the minecart is a car. But every-time it's collide with a block, the minecart is thrown back.
    If anyone could help me, i'll be really happy.
    Sorry for bad english :-(
     
  2. Offline

    fireblast709

    VehicleBlockCollisionEvent?
     
    Cycryl likes this.
  3. Offline

    frederikbontved

    I use VehicleBlockCollisionEvent, but the event is not cancelable...
     
  4. Offline

    fireblast709

    But you can still influence the Vehicle ;3
     
  5. Offline

    frederikbontved

    Can you please tell me how? I'll be very happy :)!^^
     
  6. Offline

    fireblast709

    like event.getVehicle().setVelocity(new Vector(0,0,0)) should stop the vehicle
     
  7. Offline

    frederikbontved

    It doesn't works :( I've tried many things, but nothing of them works..
     
  8. Offline

    tommycake50

    because a block collision event is fired when you hit a block and you cant cancel that.
    if setting the velocity didnt work idk try setting it like this.
    event.getVehicle().setVelocity(new Vector(-1,-1,-1))
     
  9. Offline

    frederikbontved

    It still does'nt works :(
    My code:
    @EventHandler
    public void onVehicleBlockCollision(VehicleBlockCollisionEvent event) {
    if (event.getVehicle() instanceof Minecart) {
    Bukkit.broadcastMessage("Test..");
    event.getVehicle().setVelocity(new Vector(-1,-1,-1));
    }
    }
    (It doese'nt write the message "Test..")..
     
  10. Offline

    tommycake50

    then its not firing simple as.
    try another event.
    either that or vehicle isn't a super-type of minecart
     
  11. Offline

    fireblast709

    *subtype
    frederikbontved have you registered your listener?
     
  12. Offline

    tommycake50

    nope minecart extendsVehicle therefore vehicle is minecart's supertype :3
     
  13. Offline

    fireblast709

    Code:
    if(event.getVehicle() instanceof Minecart)
    This tests if this Vehicle is an instance of its subtype Minecart
     
  14. Offline

    tommycake50

    i know that.
    maybe i wasnt making sense.
    but does that mean the event isn't getting called?
     
  15. Offline

    fireblast709

    tommycake50 yes its being called. He probably did not register his listener
     
  16. Offline

    frederikbontved

    I've registered my listeners;
    In onEnable() = this.getServer().getPluginManager().registerEvents(this, this);
    And in the top = implements Listener
    I call the events in the main class..
    Sorry for bad english.
     
  17. Offline

    fireblast709

    Well I get the message when I push a minecart, that is on a rail, against a block
     
  18. Offline

    frederikbontved

    But this is Minecarts, there dont are on rails. This minecarts is driving on all other blocks.
    Sorry for bad english!
     
  19. Offline

    fireblast709

    just tested, even without rails it fires the event (just like 5 times)
     
  20. Offline

    frederikbontved

    I dont get any messages :(!
     
  21. Offline

    fireblast709

    Post the code
     
  22. Offline

    tommycake50

  23. Offline

    frederikbontved

  24. Offline

    tommycake50

    btw 0,0,0 is definitely better than -1,-1,-1 dunno why i said that...
    looks fine...
    oh and just a tip but its better to use multiple classes that follow the java code convention.
     
  25. Offline

    frederikbontved

    I'm using one class, because i dont now how to load HashMaps, and other variables in the other classes.
    But could you see, why i dont get the message?
     
  26. Offline

    tommycake50

    no reason why you shouldn't get the message.
     
  27. Offline

    gamerzap

    Your constructor in your other classes can have arguments for those things, or you could make methods in the class which have arguments for your variables to add you variables to that class. (Although you should use the constructor thing)

    Vehicle is a supertype of Minecart so that should work; and VehicleBlockCollisionEvent is a subtype of VehicleCollisionEvent which is a subtype of VehicleEvent which has a method getVehicle() which returns the vehicle it is related to so that should work also. I don't know why it isn't working... do you have anyother plugins?

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

    frederikbontved

    I dont have any other plugins, on the server..
     
  29. Offline

    frederikbontved

  30. Offline

    frederikbontved

    Please, could anyone not help me?
     
Thread Status:
Not open for further replies.

Share This Page