1.16.x Boat API

Discussion in 'Spigot Plugin Development' started by CarsonDDD, Nov 22, 2020 at 4:39 AM.

  1. https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Boat.html

    Currently, most of the functions/methods of the boat vehicle are deprecated. I was wonder if any knows if it plans on getting reintroduced into the API any time soon?

    The reason I'm asking this question is I'm trying to write a plugin that increases boat speed. This snippet in theory works, but you cannot change the max speed (so the velocity overflows back down?)
    Does anyone have an idea of a workaround to this problem?

    Code (Java):
        float speed = 666;
        @EventHandler
        public void setBoatSpeed(PlayerMoveEvent e) {
         
            Player player = e.getPlayer();
         
            if(player.getVehicle() != null && player.getVehicle() instanceof Boat) {
                Boat boat = (Boat) player.getVehicle();
                Vector newVelocity = boat.getVelocity();
             
                newVelocity.multiply(speed);
             
                boat.setVelocity(newVelocity);
            }
        }
     
    #1 CarsonDDD, Nov 22, 2020 at 4:39 AM
    Last edited: Nov 22, 2020 at 4:45 AM
  2. I was going to suggest to just test and see if the setMaxSpeed (or whatever method you may need) from the Boat AI worked in your version, while it says unlikely doesn't hurt to try right? It does seem these methods have been deprecated since 1.9 so them getting a rework doesn't seem likely if anytime soon.
     
  3. Sadly they do not work
     
  4. Ah that's a shame, not sure if there's any work around for your method if velocity doesn't work ;-;
     
  5. You multiply the existing vector with 666, this will fail for every entity, not just boats because they're deprecated. Try something much much smaller. (Also in the back of my head I'm not sure if boats have an actual velocity when a player stirs them. You might have to set the players velocity instead)