1.16.5 Increase a Phantom's flying speed

Discussion in 'Spigot Plugin Development' started by Lavitra, Jul 14, 2021.

  1. How would I go about increasing the flying speed of a Phantom? I have tried getting the MOVEMENT_SPEED attribute and setting its base value as double of what it was before but it does not seem to increase.
    Any help would be appreciated.
     
  2. Hey, thanks for the reply.

    So I tried getting the attribute GENERIC_FLYING_SPEED and setting it to an absurd amount like 1000, just to see if it worked,

    Code (Text):

    phantom.getAttribute(Attribute.GENERIC_FLYING_SPEED).setBaseValue(1000);
     
    but this returns a NULL value whenever I call it. The stack trace is below-

    Code (Text):

    java.lang.NullPointerException: null
            at me.interrest.bosses.BossSummon.lambda$onCommand$2(BossSummon.java:244) ~[?:?]
            at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.16.4.jar:git-Spigot-5fc0fb4-7029c0a]
            at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400) ~[spigot-1.16.4.jar:git-Spigot-5fc0fb4-7029c0a]
            at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1060) ~[spigot-1.16.4.jar:git-Spigot-5fc0fb4-7029c0a]
            at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:355) ~[spigot-1.16.4.jar:git-Spigot-5fc0fb4-7029c0a]
            at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1008) ~[spigot-1.16.4.jar:git-Spigot-5fc0fb4-7029c0a]
            at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:847) ~[spigot-1.16.4.jar:git-Spigot-5fc0fb4-7029c0a]
            at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.4.jar:git-Spigot-5fc0fb4-7029c0a]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_281]
     
    Any reason why it would return null?
     
  3. Send BossSummon.java:244 code
     
  4. Code (Text):

    phantom.getAttribute(Attribute.GENERIC_FLYING_SPEED).setBaseValue(1000);
     
    This is the code at line 244. Getting the attribute generic flying speed of the phantom is returning a null value
     
    #5 Lavitra, Jul 15, 2021
    Last edited: Jul 15, 2021
  5. How are you getting the phantom object?
     
  6. So, I am spawning the phantom at the player location and then trying to get its generic flying speed attribute.

    Code (Text):

    Location loc = player.getLocation();
    Phantom phantom = (Phantom) loc.getWorld().spawnEntity(loc, EntityType.PHANTOM);
    phantom.setSize(25);
    phantom.getAttribute(Attribute.GENERIC_FLYING_SPEED).getBaseValue()
     
    The getting attribute line is generating the null error.
     
  7. I guess Mojang used movement speed for Phantoms instead of flying speed (dafuq?...), so try using "GENERIC_MOVEMENT_SPEED" instead.
     
  8. This is what I used, and instead of returning a null value it literally did nothing.