Increasing Boat Speed (NMS)?

Discussion in 'Spigot Plugin Help' started by Qwahchees, Apr 15, 2017.

  1. Hi Spigot,

    I've been trying to increase boat speeds for a while with no avail. I've tried to use reflection on methods that set the boat speed, modify the field for the double where boat speed is held and none of it has worked so far.

    I've also tried to setVelocity(); but it causes the boat to stutter and slow down.

    Does anyone have any idea?
    Thanks in advance,
    Justin
     
  2. I don't poke around with NMS much but you can try simulating the boat and setting it's postilion with the simulated path. That would require no reflection thus no SecurityManager but probably resource expensive.
     
  3. A boat is an entity afaik, you can set its speed attribute. (might not even need nms)
     
  4. Maybe I got too complicated then, the genericAttribute?

    I'd be afraid of the resource intensiveness, but good insight, thanks!
     
  5. Yes try the speed generic attributes, if that doesnt work I can help you do nms.
     
  6. Thank you, unfortunately I don't think there's a genericattributes for boats (to my awareness). I've just tried to work with it, and EntityBoat or Entity from NMS doesn't get a getGenericAttributes method.

    Using EntityBoat and setting maxSpeed doesn't do anything. This is my current code:

    Code (Text):

        public static Entity spawnEntity(Player p) {
            Bukkit.getLogger().info("[PROJECT_ENGINE]" + name + " tried to spawn.");
            Location loc = p.getLocation();
            Entity ent = Bukkit.getWorld(Settings.NAME_WORLD).spawnEntity(loc, type);

            addData(ent);
            setNMS(ent);
            ent.setPassenger(p);

            return ent;
        }

        public static void despawnEntity() {
            for (LivingEntity ent : Bukkit.getWorld(Settings.NAME_WORLD).getLivingEntities()) {
                if (name.equals(ent.getName()) || name.equals(ent.getCustomName())) {
                    ent.remove();
                }
            }
        }

        public static void setNMS(Entity ent) {
            net.minecraft.server.v1_11_R1.EntityBoat nmsEntity = ((CraftBoat) ent).getHandle();
            nmsEntity.maxSpeed = 1.0D;
            nmsEntity.setSize(5.0f, 5.0f);
            //nmsEntity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.1D);
            //nmsEntity.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(damage);
        }