diff --git a/src/main/java/net/citizensnpcs/EventListen.java b/src/main/java/net/citizensnpcs/EventListen.java index acbf004e5..74d73ab96 100644 --- a/src/main/java/net/citizensnpcs/EventListen.java +++ b/src/main/java/net/citizensnpcs/EventListen.java @@ -59,13 +59,17 @@ import com.google.common.collect.ListMultimap; public class EventListen implements Listener { private final NPCRegistry npcRegistry = CitizensAPI.getNPCRegistry(); - private final ListMultimap toRespawn = ArrayListMultimap.create(); private final Map registries; + private final ListMultimap toRespawn = ArrayListMultimap.create(); EventListen(Map registries) { this.registries = registries; } + private Iterable getAllNPCs() { + return Iterables. concat(npcRegistry, Iterables.concat(registries.values())); + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onChunkLoad(ChunkLoadEvent event) { ChunkCoord coord = toCoord(event.getChunk()); @@ -95,10 +99,6 @@ public class EventListen implements Listener { } } - private Iterable getAllNPCs() { - return Iterables. concat(npcRegistry, Iterables.concat(registries.values())); - } - @EventHandler(ignoreCancelled = true) public void onEntityChangedWorld(EntityTeleportEvent event) { if (event.getFrom() == null || event.getTo() == null) diff --git a/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java b/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java index 85fdee4f5..bdaacfe0f 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java @@ -53,7 +53,6 @@ public class EnderDragonController extends MobEntityController { this.npc = (CitizensNPC) npc; if (npc != null) { NMS.clearGoals(goalSelector, targetSelector); - } } @@ -65,9 +64,16 @@ public class EnderDragonController extends MobEntityController { @Override public void c() { - if (npc != null) + if (npc != null) { npc.update(); - else + if (motX != 0 || motY != 0 || motZ != 0) { + motX *= 0.98; + motY *= 0.98; + motZ *= 0.98; + yaw = getCorrectYaw(locX + motX, locZ + motZ); + setPosition(locX + motX, locY + motY, locZ + motZ); + } + } else super.c(); } @@ -109,6 +115,15 @@ public class EnderDragonController extends MobEntityController { return super.getBukkitEntity(); } + private float getCorrectYaw(double tX, double tZ) { + if (locZ > tZ) + return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))); + if (locZ < tZ) { + return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F; + } + return yaw; + } + @Override public NPC getNPC() { return npc;