mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 19:16:34 +01:00
Fix EnderDragon NPC movement
This commit is contained in:
parent
be4a9fba85
commit
1cb9c7b057
@ -59,13 +59,17 @@ import com.google.common.collect.ListMultimap;
|
||||
|
||||
public class EventListen implements Listener {
|
||||
private final NPCRegistry npcRegistry = CitizensAPI.getNPCRegistry();
|
||||
private final ListMultimap<ChunkCoord, NPC> toRespawn = ArrayListMultimap.create();
|
||||
private final Map<String, NPCRegistry> registries;
|
||||
private final ListMultimap<ChunkCoord, NPC> toRespawn = ArrayListMultimap.create();
|
||||
|
||||
EventListen(Map<String, NPCRegistry> registries) {
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
private Iterable<NPC> getAllNPCs() {
|
||||
return Iterables.<NPC> 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<NPC> getAllNPCs() {
|
||||
return Iterables.<NPC> concat(npcRegistry, Iterables.concat(registries.values()));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityChangedWorld(EntityTeleportEvent event) {
|
||||
if (event.getFrom() == null || event.getTo() == null)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user