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)
public void onEntityDamage(EntityDamageEvent event) {
NPC npc = npcRegistry.getNPC(event.getEntity());
if (npc == null) {
if (event instanceof EntityDamageByEntityEvent) {
npc = npcRegistry.getNPC(((EntityDamageByEntityEvent) event).getDamager());

View File

@ -273,6 +273,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
super.m();
if (npc == null)
return;
boolean navigating = npc.getNavigator().isNavigating();
updatePackets(navigating);
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
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null)
if (npc != null) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
}
@Override

View File

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