Handle CraftPlayer#setSpectatorTarget better

Use a proper teleport for teleporting to entities in different
worlds.

Validate that the target entity is valid and deny spectate
requests from frozen players.

Also, make sure the entity is spawned to the client before
sending the camera packet. If the entity isn't spawned clientside
when it receives the camera packet, then the client will not
spectate the target entity.
This commit is contained in:
Spottedleaf
2020-05-14 18:05:00 -05:00
committed by Zach Brown
parent 4ae089597b
commit bb4002d82e
13 changed files with 123 additions and 90 deletions

View File

@@ -98,7 +98,7 @@ index c4d433430503e844121f1917c6caf05823af0a34..7df24be46e4471ae0ddad5cded5eef49
protected static final DataWatcherObject<NBTTagCompound> bs = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
protected static final DataWatcherObject<NBTTagCompound> bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index f453ccdb020e911d84658f630a289612e1557db4..bf2ba0548d93280651d89c2039a298c56a83b0bf 100644
index 49fe2d1a0376e5aa8a5ec00d010e6c834633e7b7..64e00275edf38739fe6e2d79dbcb93243e765678 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -2,6 +2,7 @@ package net.minecraft.server;
@@ -116,7 +116,7 @@ index f453ccdb020e911d84658f630a289612e1557db4..bf2ba0548d93280651d89c2039a298c5
- private boolean ci = true;
+ private boolean ci = true; public boolean hasChatColorsEnabled() { return this.ci; } // Paper - OBFHELPER
private long cj = SystemUtils.getMonotonicMillis();
private Entity spectatedEntity; private void setSpectatorTargetField(Entity e) { this.spectatedEntity = e; } // Paper - OBFHELPER
private Entity spectatedEntity;
public boolean worldChangeInvuln;
@@ -1573,6 +1574,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}