Paper/Spigot-Server-Patches/0113-Entity-Tracking-Improvements.patch
Aikar 835bc39b03
Paper 1.13.1 Update
Updated Upstream (Bukkit/CraftBukkit/Spigot)

Bukkit Changes:
2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields
e0fc6572 SPIGOT-4309: Add "forced" display of particles
efeeab2f Add index to README.md for easier navigation
f502bc6f Update to Minecraft 1.13.1

CraftBukkit Changes:
d0bb0a1d Fix some tests randomly failing
997d378d Fix client stall in specific teleportation scenarios
b3dc2366 SPIGOT-4307: Fix hacky API for banners on shields
2a271162 SPIGOT-4301: Fix more invalid enchants
5d0d83bb SPIGOT-4309: Add "forced" display of particles
a6772578 Add additional tests for CraftBlockData
ce1af0c3 Update to Minecraft 1.13.1

Spigot Changes:
2440e189 Rebuild patches
4ecffced Update to Minecraft 1.13.1
2018-08-26 20:51:39 -04:00

104 lines
4.1 KiB
Diff

From 3f75cb9ef3269d4e9c93f8e2dd9ad32598408488 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 d070d68d7c..4d2e978894 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -72,6 +72,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
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 cce2ce9397..4dbc5eca34 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);
@@ -597,6 +640,7 @@ public class EntityTrackerEntry {
this.trackedPlayers.remove(entityplayer);
this.tracker.c(entityplayer);
entityplayer.c(this.tracker);
+ updatePassengers(entityplayer); // Paper
}
}
--
2.18.0