Solved Riding EntityEnderDragon / Sending outpackets to a player

Discussion in 'Plugin Development' started by EvilWitchdoctor, Dec 29, 2014.

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

    EvilWitchdoctor

    Please prepare for a rather long-blown question. ;)

    Recently a friend of mine asked for help with a plugin allowing players to ride enderdragons, I worked out how to have the player control the enderdragon by the direction they turn their view, but am having problems getting the player to ride the dragon correctly.
    After playing around with fake entities and a good deal of mobtypes, as well reviewing this thread:
    http://bukkit.org/threads/tutorial-1-7-5-wasd-entity-riding.163019/
    I tried setting the player riding a "frozen" witherskull and then set the witherskull riding the dragon (thanks to @ChipDev's tutorial here http://bukkit.org/threads/floating-entities-frozen-entities-floating-items.313439/)
    This works nearly perfectly-- the player ends up riding about 8 blocks above the back of the enderdragon, and the witherskull doesn't really look nice. This will also work with enderpearls, but the seating height will still be off.
    Here is my current strategy:
    I set the player riding an enderpearl, which I spawn at 2.5 blocks above the dragon's getLoation()
    Every couple ticks, I set the enderpearl's velocity equal to the enderdragon's velocity
    If the enderpearl ever strays move then 1.5 blocks from where it ought to be, it gets teleported back (this occurs every 3-15 seconds, and is not very noticable).
    The scheduler only runs when there is a player riding an enderdragon, and has not caused any noticeable performance decrease.
    The problem is that whenever the connection between client and server falters even briefly, the client assumes that the enderpearl will continue following it's trajectory, and will occasionally show the player "glitching forward" off the enderdragon until the game updates the dragon.
    And finally..
    What I am looking for:
    Does anyone know any other approaches? Any fixes for what I am currently doing? All help is appreciated.
    I have tested/checked my code for errors, and this seems more like a conceptual question, but if needed I can post it below.

    Please Note: Before anyone new to this topic suggests it- No, you cannot use, dragon.setPassenger(player), It simply does not work correctly. Also, I'm not looking for links to this plugin: http://dev.bukkit.org/bukkit-plugins/ridethadragon/. It was made for 1.4.5 and does not work past 1.6, it is also rather server-intensive and does not do a great job with player-dragon control.
     
    ChipDev likes this.
  2. Offline

    TheCodingCat

    Why make it so complicated @EvilWitchdoctor just use the PlayerMoveEvent and make the enderdragons velocity the the Event#getTo()'s direction
     
    ChipDev likes this.
  3. Offline

    ChipDev

    http://dev.bukkit.org/bukkit-plugins/enderdragonsplus/
    Decompiling it and checking how they did it. It is 1.7.9, Ill get back to you later
    As I said before about the wither skulls, They are not the best as they occasionally pop up :(
     
    EvilWitchdoctor likes this.
  4. Offline

    EvilWitchdoctor

    @TheCodingCat awesome, I'll try that. I'll also use player.setFlying(true); to prevent them from having a 1-way trip ;)

    @ChipDev Excellent! I didn't see this plugin, not sure how I missed it :rolleyes:
    I'll go see what I can dig up with this, thanks again to you both
     
  5. Offline

    EvilWitchdoctor

    Sorry, I know it's been a few days. I think I found what I'm looking for, but I will need to decompile a deal of NMS to have this work in 1.8 and up. Fortunately that is something I know how to do. :)
     
Thread Status:
Not open for further replies.

Share This Page