mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-27 19:47:51 +01:00
Fix compatibility with ProtocolLib
This commit is contained in:
parent
599d5dd35d
commit
f9308391ba
@ -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());
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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) {
|
||||||
|
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user