Hello I'm trying to make a rideable ender dragon. To that, I have a command which spawns one and puts player as passenger, while also addimg them to a hashmap with their name and the dragon entity id. Everything fires correctly, till the last line, where the dragons velocity isnt changed and it doenst move at all. Anyone have any ideas how to make it controllable and turn the head like the player flying in that direction? Code (Java): class DragonRunner extends BukkitRunnable{ public void run(){ if (BetterDragons.flyers.isEmpty())return; for (String pl : BetterDragons.flyers.keySet()){ Player p = Bukkit.getPlayer(pl); System.out.println(pl); if (p == null)continue; Entity dr = null; for (Entity en : p.getNearbyEntities(10, 10, 10)){ System.out.println(en.getEntityId() + ":" + BetterDragons.flyers.get(pl)); if (dr != null)continue; System.out.println("found"); if (en.getEntityId() == BetterDragons.flyers.get(pl))dr = en; } if (dr == null)continue; System.out.println("velocity work"); dr.setVelocity(p.getLocation().getDirection().multiply(2).add(new Vector(0.0D, 0.2D, 0.0D))); } } } EDIT: Solved, made custom entity: Code (Java): public class RideableDragon extends EntityEnderDragon{ public RideableDragon(World world) { super(world); } @Override public void n(){ if (passengers.isEmpty()){ setHealth(0); world.removeEntity(this); return; } Entity en = passengers.get(0); if (en == null){ setHealth(0); } this.yaw = 180+en.yaw; this.pitch = en.pitch; setHeadRotation(en.pitch); Location loc = this.getBukkitEntity().getLocation().add(en.getBukkitEntity().getLocation().getDirection()); if (loc.getBlock().getType().equals(Material.AIR)){ this.setPosition(loc.getX(), loc.getY(), loc.getZ()); } }
I believe you'll need to extend EntityEnderDragon and edit a-couple override methods to allow such behavior.
Hmm... https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/EntityEnderDragon.java Do you know which fields are right? Not really easy reading obfuscated code.
I'm not entirely sure what fields, a quick Google brought up a couple threads though. Try Googling WASD Ender Dragon control, you'll find a couple threads. Also, I wouldn't use that repository as a reference if your server version is greater-than 1.7.10!
Thanks, got it all figured out using MCP Mapping Viewer, and thanks for the heads up about that repository, thought it was updated but guess had that wrong. Anyways, MCP Mapping Viewer and Spigot.jar source gets you a long way
Ok I Think I Have Found Your Solution In A Different Plugin. https://dev.bukkit.org/projects/echopet Just Create a Pet EnderDragon And Do /Pet Ride!
Uh.. This is the "Spigot Plugin Development" forum. That's not an appropriate solution to this question.