geforkt von Mirrors/Paper
c97ce029e9
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues. Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong. This is now resolved. Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me. Please as always, backup your worlds and test before updating to 1.16.2! If you update to 1.16.2, there is no going back to an older build than this. --------------------------------- Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com> Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com> Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com> Co-authored-by: stonar96 <minecraft.stonar96@gmail.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Jason <jasonpenilla2@me.com> Co-authored-by: kashike <kashike@vq.lc> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: KennyTV <kennytv@t-online.de> Co-authored-by: commandblockguy <commandblockguy1@gmail.com> Co-authored-by: DigitalRegent <misterwener@gmail.com> Co-authored-by: ishland <ishlandmc@yeah.net>
109 Zeilen
5.5 KiB
Diff
109 Zeilen
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
Date: Wed, 2 Mar 2016 23:13:07 -0600
|
|
Subject: [PATCH] Send absolute position the first time an entity is seen
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
index 65095b7d91fb4549ef67593054c54ca81b77debe..50df43653933e3bdeb3fd514a1c6c3b9ac3b15ab 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
|
import com.mojang.datafixers.util.Pair;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
+import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
@@ -23,7 +24,7 @@ public class EntityTrackerEntry {
|
|
private final Entity tracker;
|
|
private final int d;
|
|
private final boolean e;
|
|
- private final Consumer<Packet<?>> f;
|
|
+ private final Consumer<Packet<?>> f; private Consumer<Packet<?>> getPacketConsumer() { return f; } // Paper - OBFHELPER
|
|
private long xLoc;
|
|
private long yLoc;
|
|
private long zLoc;
|
|
@@ -38,8 +39,23 @@ public class EntityTrackerEntry {
|
|
private boolean r;
|
|
// CraftBukkit start
|
|
private final Set<EntityPlayer> trackedPlayers;
|
|
+ // Paper start
|
|
+ private java.util.Map<EntityPlayer, Boolean> trackedPlayerMap = null;
|
|
+
|
|
+ /**
|
|
+ * Requested in https://github.com/PaperMC/Paper/issues/1537 to allow intercepting packets
|
|
+ */
|
|
+ public void sendPlayerPacket(EntityPlayer player, Packet packet) {
|
|
+ player.playerConnection.sendPacket(packet);
|
|
+ }
|
|
+
|
|
+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, java.util.Map<EntityPlayer, Boolean> trackedPlayers) {
|
|
+ this(worldserver, entity, i, flag, consumer, trackedPlayers.keySet());
|
|
+ trackedPlayerMap = trackedPlayers;
|
|
+ }
|
|
|
|
public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<EntityPlayer> trackedPlayers) {
|
|
+ // Paper end
|
|
this.trackedPlayers = trackedPlayers;
|
|
// CraftBukkit end
|
|
this.m = Vec3D.a;
|
|
@@ -161,7 +177,25 @@ public class EntityTrackerEntry {
|
|
}
|
|
|
|
if (packet1 != null) {
|
|
- this.f.accept(packet1);
|
|
+ // paper start
|
|
+ if (trackedPlayerMap == null || packet1 instanceof PacketPlayOutEntityTeleport) {
|
|
+ this.f.accept((packet1));
|
|
+ } else {
|
|
+ PacketPlayOutEntityTeleport teleportPacket = null;
|
|
+
|
|
+ for (java.util.Map.Entry<EntityPlayer, Boolean> viewer : trackedPlayerMap.entrySet()) {
|
|
+ if (viewer.getValue()) {
|
|
+ viewer.setValue(false);
|
|
+ if (teleportPacket == null) {
|
|
+ teleportPacket = new PacketPlayOutEntityTeleport(this.tracker);
|
|
+ }
|
|
+ sendPlayerPacket(viewer.getKey(), teleportPacket);
|
|
+ } else {
|
|
+ sendPlayerPacket(viewer.getKey(), packet1);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
this.c();
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
index d98b6ef44e1836920956754dfcb6654fec23b673..b40f6b7d45028b5bc58a222e2d54cb8693273325 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
@@ -1249,10 +1249,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
private final Entity tracker;
|
|
private final int trackingDistance;
|
|
private SectionPosition e;
|
|
- public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet();
|
|
+ // Paper start
|
|
+ // Replace trackedPlayers Set with a Map. The value is true until the player receives
|
|
+ // their first update (which is forced to have absolute coordinates), false afterward.
|
|
+ public java.util.Map<EntityPlayer, Boolean> trackedPlayerMap = new java.util.HashMap<>();
|
|
+ public Set<EntityPlayer> trackedPlayers = trackedPlayerMap.keySet();
|
|
|
|
public EntityTracker(Entity entity, int i, int j, boolean flag) {
|
|
- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit
|
|
+ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayerMap); // CraftBukkit // Paper
|
|
this.tracker = entity;
|
|
this.trackingDistance = i;
|
|
this.e = SectionPosition.a(entity);
|
|
@@ -1334,7 +1338,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
|
// CraftBukkit end
|
|
|
|
- if (flag1 && this.trackedPlayers.add(entityplayer)) {
|
|
+ if (flag1 && this.trackedPlayerMap.putIfAbsent(entityplayer, true) == null) { // Paper
|
|
this.trackerEntry.b(entityplayer);
|
|
}
|
|
} else if (this.trackedPlayers.remove(entityplayer)) {
|