mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 03:25:13 +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 {
|
public class EventListen implements Listener {
|
||||||
private final NPCRegistry npcRegistry = CitizensAPI.getNPCRegistry();
|
private final NPCRegistry npcRegistry = CitizensAPI.getNPCRegistry();
|
||||||
private final ListMultimap<ChunkCoord, NPC> toRespawn = ArrayListMultimap.create();
|
|
||||||
private final Map<String, NPCRegistry> registries;
|
private final Map<String, NPCRegistry> registries;
|
||||||
|
private final ListMultimap<ChunkCoord, NPC> toRespawn = ArrayListMultimap.create();
|
||||||
|
|
||||||
EventListen(Map<String, NPCRegistry> registries) {
|
EventListen(Map<String, NPCRegistry> registries) {
|
||||||
this.registries = registries;
|
this.registries = registries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Iterable<NPC> getAllNPCs() {
|
||||||
|
return Iterables.<NPC> concat(npcRegistry, Iterables.concat(registries.values()));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onChunkLoad(ChunkLoadEvent event) {
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
ChunkCoord coord = toCoord(event.getChunk());
|
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)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onEntityChangedWorld(EntityTeleportEvent event) {
|
public void onEntityChangedWorld(EntityTeleportEvent event) {
|
||||||
if (event.getFrom() == null || event.getTo() == null)
|
if (event.getFrom() == null || event.getTo() == null)
|
||||||
|
@ -53,7 +53,6 @@ public class EnderDragonController extends MobEntityController {
|
|||||||
this.npc = (CitizensNPC) npc;
|
this.npc = (CitizensNPC) npc;
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMS.clearGoals(goalSelector, targetSelector);
|
NMS.clearGoals(goalSelector, targetSelector);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,9 +64,16 @@ public class EnderDragonController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void c() {
|
public void c() {
|
||||||
if (npc != null)
|
if (npc != null) {
|
||||||
npc.update();
|
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();
|
super.c();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +115,15 @@ public class EnderDragonController extends MobEntityController {
|
|||||||
return super.getBukkitEntity();
|
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
|
@Override
|
||||||
public NPC getNPC() {
|
public NPC getNPC() {
|
||||||
return npc;
|
return npc;
|
||||||
|
Loading…
Reference in New Issue
Block a user