From ae96a02e49ca098cc48de3ba8097576b7cd92228 Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 25 Apr 2019 14:41:45 +0800 Subject: [PATCH] Fix backwards compat issue with 1.13.2 --- main/src/main/resources/plugin.yml | 2 +- .../v1_13_R2/util/PlayerlistTrackerEntry.java | 61 +++++++++---------- .../nms/v1_14_R1/util/NMSImpl.java | 2 +- .../nms/v1_14_R1/util/PlayerNavigation.java | 2 +- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/main/src/main/resources/plugin.yml b/main/src/main/resources/plugin.yml index 292c5975d..013d1ae7e 100644 --- a/main/src/main/resources/plugin.yml +++ b/main/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ softdepend: [Vault] version: ${project.version} (build ${BUILD_NUMBER}) main: net.citizensnpcs.Citizens website: http://www.citizensnpcs.co -api-version: "1.14" +api-version: "1.13" commands: traitc: aliases: [trc] diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java index fd54a308c..17a3f4b2a 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java @@ -27,9 +27,8 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry { return; Entity tracker = getTracker(this); if (entityplayer != tracker && c(entityplayer)) { - if (!this.trackedPlayers.contains(entityplayer) - && ((entityplayer.getWorldServer().getPlayerChunkMap().a(entityplayer, getChunkX(tracker), getChunkZ(tracker))) - || (tracker.attachedToPlayer))) { + if (!this.trackedPlayers.contains(entityplayer) && ((entityplayer.getWorldServer().getPlayerChunkMap() + .a(entityplayer, getChunkX(tracker), getChunkZ(tracker))) || (tracker.attachedToPlayer))) { if ((tracker instanceof SkinnableEntity)) { SkinnableEntity skinnable = (SkinnableEntity) tracker; @@ -44,6 +43,32 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry { super.updatePlayer(entityplayer); } + private static int getChunkX(Entity tracker) { + try { + return tracker.chunkX; + } catch (NoSuchFieldError ex) { + try { + return CHUNK_X.getInt(tracker); + } catch (Exception ex2) { + ex2.printStackTrace(); + return 0; + } + } + } + + private static int getChunkZ(Entity tracker) { + try { + return tracker.chunkZ; + } catch (NoSuchFieldError ex) { + try { + return CHUNK_Z.getInt(tracker); + } catch (Exception ex2) { + ex2.printStackTrace(); + return 0; + } + } + } + private static int getE(EntityTrackerEntry entry) { try { return (Integer) E.get(entry); @@ -99,36 +124,6 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry { return false; } - private static int getChunkX(Entity tracker) { - try { - return tracker.chunkX; - } - catch (NoSuchFieldError ex) { - try { - return CHUNK_X.getInt(tracker); - } - catch (Exception ex2) { - ex2.printStackTrace(); - return 0; - } - } - } - - private static int getChunkZ(Entity tracker) { - try { - return tracker.chunkZ; - } - catch (NoSuchFieldError ex) { - try { - return CHUNK_Z.getInt(tracker); - } - catch (Exception ex2) { - ex2.printStackTrace(); - return 0; - } - } - } - private static Field CHUNK_X = NMS.getField(Entity.class, "ae", false); private static Field CHUNK_Z = NMS.getField(Entity.class, "ag", false); private static Field E = NMS.getField(EntityTrackerEntry.class, "e"); diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java index e8c520768..872d857db 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java @@ -1004,7 +1004,7 @@ public class NMSImpl implements NMSBridge { @Override public void setSitting(Ocelot ocelot, boolean sitting) { - /* TODO */ + // sitting removed } @Override diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerNavigation.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerNavigation.java index 06fb655a5..7c1e2329d 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerNavigation.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerNavigation.java @@ -61,7 +61,7 @@ public class PlayerNavigation extends NavigationAbstract { this.p = entityinsentient.getAttributeInstance(GenericAttributes.FOLLOW_RANGE); this.o = new PlayerPathfinderNormal(); this.o.a(true); - this.r = new PlayerPathfinder(this.o, 100); // TODO: what is this parameter normally? + this.r = new PlayerPathfinder(this.o, 768); this.setRange(24); // this.b.C().a(this); }