Fix compatibility with ProtocolLib

This commit is contained in:
fullwall 2016-03-05 10:01:38 +08:00
parent 599d5dd35d
commit f9308391ba
5 changed files with 12 additions and 11 deletions

View File

@ -187,6 +187,7 @@ public class EventListen implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
NPC npc = npcRegistry.getNPC(event.getEntity()); NPC npc = npcRegistry.getNPC(event.getEntity());
if (npc == null) { if (npc == null) {
if (event instanceof EntityDamageByEntityEvent) { if (event instanceof EntityDamageByEntityEvent) {
npc = npcRegistry.getNPC(((EntityDamageByEntityEvent) event).getDamager()); npc = npcRegistry.getNPC(((EntityDamageByEntityEvent) event).getDamager());

View File

@ -273,6 +273,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
super.m(); super.m();
if (npc == null) if (npc == null)
return; return;
boolean navigating = npc.getNavigator().isNavigating(); boolean navigating = npc.getNavigator().isNavigating();
updatePackets(navigating); updatePackets(navigating);
if (gravity && !navigating && getBukkitEntity() != null if (gravity && !navigating && getBukkitEntity() != null

View File

@ -70,8 +70,9 @@ public class GhastController extends MobEntityController {
// this method is called by both the entities involved - cancelling // this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving. // it will not stop the NPC from moving.
super.collide(entity); super.collide(entity);
if (npc != null) if (npc != null) {
Util.callCollisionEvent(npc, entity.getBukkitEntity()); Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
} }
@Override @Override

View File

@ -28,8 +28,9 @@ public class Util {
} }
public static void callCollisionEvent(NPC npc, Entity entity) { public static void callCollisionEvent(NPC npc, Entity entity) {
if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length > 0) if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length > 0) {
Bukkit.getPluginManager().callEvent(new NPCCollisionEvent(npc, entity)); Bukkit.getPluginManager().callEvent(new NPCCollisionEvent(npc, entity));
}
} }
public static NPCPushEvent callPushEvent(NPC npc, Vector vector) { public static NPCPushEvent callPushEvent(NPC npc, Vector vector) {

View File

@ -12,11 +12,8 @@ import net.minecraft.server.v1_9_R1.EntityPlayer;
import net.minecraft.server.v1_9_R1.EntityTrackerEntry; import net.minecraft.server.v1_9_R1.EntityTrackerEntry;
public class PlayerlistTrackerEntry extends EntityTrackerEntry { public class PlayerlistTrackerEntry extends EntityTrackerEntry {
private final Entity tracker;
public PlayerlistTrackerEntry(Entity entity, int i, int j, int k, boolean flag) { public PlayerlistTrackerEntry(Entity entity, int i, int j, int k, boolean flag) {
super(entity, i, j, k, flag); super(entity, i, j, k, flag);
this.tracker = entity;
} }
public PlayerlistTrackerEntry(EntityTrackerEntry entry) { public PlayerlistTrackerEntry(EntityTrackerEntry entry) {
@ -28,14 +25,14 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry {
// prevent updates to NPC "viewers" // prevent updates to NPC "viewers"
if (entityplayer instanceof EntityHumanNPC) if (entityplayer instanceof EntityHumanNPC)
return; return;
Entity tracker = getTracker(this);
if (entityplayer != this.tracker && c(entityplayer)) { if (entityplayer != tracker && c(entityplayer)) {
if (!this.trackedPlayers.contains(entityplayer) if (!this.trackedPlayers.contains(entityplayer)
&& ((entityplayer.x().getPlayerChunkMap().a(entityplayer, this.tracker.ab, this.tracker.ad)) && ((entityplayer.x().getPlayerChunkMap().a(entityplayer, tracker.ab, tracker.ad))
|| (this.tracker.attachedToPlayer))) { || (tracker.attachedToPlayer))) {
if ((this.tracker instanceof SkinnableEntity)) { if ((tracker instanceof SkinnableEntity)) {
SkinnableEntity skinnable = (SkinnableEntity) this.tracker; SkinnableEntity skinnable = (SkinnableEntity) tracker;
Player player = skinnable.getBukkitEntity(); Player player = skinnable.getBukkitEntity();
if (!entityplayer.getBukkitEntity().canSee(player)) if (!entityplayer.getBukkitEntity().canSee(player))