Custom model & mount

Discussion in 'Spigot Plugin Development' started by DominicBridge, Jun 2, 2017.

  1. Hey guys,

    Looking into a broomstick flying mod, similar to what magic does. However still fairly new to the Spigot API.

    A few of my theories:
    1) Drop an item and have that entity as a passenger to player and activate fly mode
    2) Remodel a horse and somehow add flying?

    Actually having trouble setting a passenger, I have a broom model loaded. Its currently set to a wooden hoe.

    Am I looking at this the wrong way?

    Not necessarily looking for code. More an idea on how to go about it :)

    Thanks in advance!
  2. Idk but maybe velocity would work
    • Agree Agree x 1
  3. you could mount the player then set the velocity of the mount to increase by the direction the player is looking.
    • Agree Agree x 1
  4. Hi :)
    Magic does this with just an armor stand. Used to be an armor stand mounted on a horse, now it's just an armor stand.

    The broomstick item goes on the armor stand's head, player is mounted on armor stand, and velocity is applied to the armor stand each tick to make it fly. I also adjust the pitch and roll of the armor stand head to make the broom stick point up and down and roll side to side, but that's just an extra little touch.

    Code's all here if you're interested:

    That's basically it, I think!
    • Winner Winner x 1
    • Informative Informative x 1
  5. Whoa!

    Thank you very much, didn't realise it was open source.

    I'll take a look now :D
    • Friendly Friendly x 1
  6. You could have your entity and set the Player as Passenger. You could now set the velocity of the entity so the Player would be moved with it.
  7. How would I go about getting the players velocity though?
    I tried simply doing

    but I'm guessing because its mounted its velocity is 0.
  8. There isn't a reliable way of getting the player's velocity, but you don't really need it. You're going to specify the velocity, make it whatever you want to give the desired effect.

    If you're looking to tell what WASD keys the player is holding, that's a different matter entirely. It can be done with NMS calls but there is no API that will make it work.
    • Informative Informative x 1
  9. Thanks for the info,

    I'll look further into how your Magic plugin does it and decipher a way to fit it into my project :)
  10. You dont have to get which key is pressed. Your able to get the Location of the Player - > you take yaw and pitch to get the direction he is looking at. This way youre getting a Vector you could set as the velocity of the player.
  11. Depends on how you want to control speeding up and slowing down, and if you want them to be able to strafe, or maybe ascend/descend directly.

    Yes in general broomsticks and other vehicles can just move forward in the direction you're looking, and that's how most of them work. But that's kind of boring- how can you speed up and slow down? What if you want to move in a direction other than where you're facing?

    My broomsticks originally uses horses for controls- using jump you could charge up and go faster, using shift you could slow down. But then Mojang broke both of those mechanics, tracking horse jumps is wonky now and so is cancelling dismount. (Last I checked, don't care so much anymore).

    I then switched to using pitch, so they slow down when climbing and accelerate while diving. This worked ok and felt kind of realistic but in practice is an annoying way to control speed. It does not rely on WASD controls though.

    I now use WASD controls for intuitive acceleration and deceleration (W and S) and to allow some strafing movements with A/D, and also the jump key for ascending quickly.

    So yes, it's not a requirement to be able to use WASD/Space but it sure gives you a lot more options in terms of controllability.
  12. Hello Nathan,

    Some lovely stuff here, using some snippets and trying to get it working before Tinkering properly.
    However, I can't seem to get it working to a level where I can tweak and test, I'm getting some flying movements, but I'm getting an error on this line
    class_Entity_setYawPitchMethod.invoke(handle, yaw, pitch);

    [02:15:49 INFO]: protected void net.minecraft.server.v1_11_R1.Entity.setYawPitch(float,float)
    [02:15:49 INFO]: protected void net.minecraft.server.v1_11_R1.Entity.setYawPitch(float,float)
    [02:15:49 WARN]: java.lang.IllegalAccessException: Class com.bridgegaming.wizardingworld.tasks.brooms.BroomFlyingTask can not access a member of class net.minecraft.server.v1_11_R1.Entity with modifiers "protected"

    class_Entity_setYawPitchMethod.toString() displays protected void net.minecraft.server.v1_11_R1.Entity.setYawPitch(float,float)

    The only thing I could think of looking at yours is that the highest class extends Cloneable, Would that be the way forward, and could I implement BukkitRunnable and Cloneable?

  13. I'm not sure that setYawPitch thing is necessary anymore... does it work without that?

    If you need to call it, you'll have to use reflection and setAccessible it. Would be nice to avoid that- I can't really remember why I'm calling that or if it's needed, maybe I was trying to avoid teleporting the armor stand.
  14. By the looks, setYawPitchMethod is changing the way the broom is pointing. But I noticed in an earlier post you mentioned using headpose, so gonna look into that.