aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0129-Entity-Tracking-Improvements.patch
diff options
context:
space:
mode:
Diffstat (limited to 'Spigot-Server-Patches/0129-Entity-Tracking-Improvements.patch')
-rw-r--r--Spigot-Server-Patches/0129-Entity-Tracking-Improvements.patch103
1 files changed, 103 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0129-Entity-Tracking-Improvements.patch b/Spigot-Server-Patches/0129-Entity-Tracking-Improvements.patch
new file mode 100644
index 0000000000..349a9c13ad
--- /dev/null
+++ b/Spigot-Server-Patches/0129-Entity-Tracking-Improvements.patch
@@ -0,0 +1,103 @@
+From d0d65d40d665bd4857968bce815a16b73fb71992 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Mon, 17 Jun 2013 01:24:00 -0400
+Subject: [PATCH] Entity Tracking Improvements
+
+If any part of a Vehicle/Passenger relationship is visible to a player,
+send all passenger/vehicles to the player in the chain.
+
+diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
+index 0f4a1b66b..96b1e9a78 100644
+--- a/src/main/java/net/minecraft/server/Entity.java
++++ b/src/main/java/net/minecraft/server/Entity.java
+@@ -53,6 +53,7 @@ public abstract class Entity implements ICommandListener {
+
+ protected CraftEntity bukkitEntity;
+
++ EntityTrackerEntry tracker; // Paper
+ public CraftEntity getBukkitEntity() {
+ if (bukkitEntity == null) {
+ bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
+diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+index fbda70a39..c28b4bd44 100644
+--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
++++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+@@ -49,6 +49,7 @@ public class EntityTrackerEntry {
+ // Paper end
+
+ public EntityTrackerEntry(Entity entity, int i, int j, int k, boolean flag) {
++ entity.tracker = this; // Paper
+ this.tracker = entity;
+ this.e = i;
+ this.f = j;
+@@ -446,17 +447,59 @@ public class EntityTrackerEntry {
+
+ this.tracker.b(entityplayer);
+ entityplayer.d(this.tracker);
++ updatePassengers(entityplayer); // Paper
+ }
+ } else if (this.trackedPlayers.contains(entityplayer)) {
+ this.trackedPlayers.remove(entityplayer);
+ this.tracker.c(entityplayer);
+ entityplayer.c(this.tracker);
++ updatePassengers(entityplayer); // Paper
+ }
+
+ }
+ }
+
+ public boolean c(EntityPlayer entityplayer) {
++ // Paper start
++ if (tracker.isPassenger()) {
++ return isTrackedBy(tracker.getVehicle(), entityplayer);
++ } else if (hasPassengerInRange(tracker, entityplayer)) {
++ return true;
++ }
++
++ return isInRangeOfPlayer(entityplayer);
++ }
++ private static boolean hasPassengerInRange(Entity entity, EntityPlayer entityplayer) {
++ if (!entity.isVehicle()) {
++ return false;
++ }
++ for (Entity passenger : entity.passengers) {
++ if (passenger.tracker != null && passenger.tracker.isInRangeOfPlayer(entityplayer)) {
++ return true;
++ }
++ if (passenger.isVehicle()) {
++ if (hasPassengerInRange(passenger, entityplayer)) {
++ return true;
++ }
++ }
++ }
++ return false;
++ }
++ private static boolean isTrackedBy(Entity entity, EntityPlayer entityplayer) {
++ return entity == entityplayer || entity.tracker != null && entity.tracker.trackedPlayers.contains(entityplayer);
++ }
++ private void updatePassengers(EntityPlayer player) {
++ if (tracker.isVehicle()) {
++ tracker.passengers.forEach((e) -> {
++ if (e.tracker != null) {
++ e.tracker.updatePlayer(player);
++ }
++ });
++ player.playerConnection.sendPacket(new PacketPlayOutMount(this.tracker));
++ }
++ }
++ private boolean isInRangeOfPlayer(EntityPlayer entityplayer) {
++ // Paper end
+ double d0 = entityplayer.locX - (double) this.xLoc / 4096.0D;
+ double d1 = entityplayer.locZ - (double) this.zLoc / 4096.0D;
+ int i = Math.min(this.e, this.f);
+@@ -593,6 +636,7 @@ public class EntityTrackerEntry {
+ this.trackedPlayers.remove(entityplayer);
+ this.tracker.c(entityplayer);
+ entityplayer.c(this.tracker);
++ updatePassengers(entityplayer); // Paper
+ }
+
+ }
+--
+2.12.2.windows.2
+