mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
ea855e2b46
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Developers!: You will need to clean up your work/Minecraft/1.13.2 folder for this Also, restore a patch that was dropped in the last upstream Bukkit Changes: 279eeab3 Fix command description not being set 96e2bb18 Remove debug print from SyntheticEventTest CraftBukkit Changes:d3ed1516
Fix dangerously threaded beacons217a293d
Don't relocate joptsimple to allow --help to work.1be05a21
Prepare for imminent Java 12 releasea49270b2
Mappings Update5259d80c
SPIGOT-4669: Fix PlayerTeleportEvent coordinates for relative teleports Spigot Changes: e6eb36f2 Rebuild patches
79 lines
3.3 KiB
Diff
79 lines
3.3 KiB
Diff
From 96241e585235ed412e893f10f2cc1a9df400f679 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Mon, 23 Jul 2018 22:44:23 -0400
|
|
Subject: [PATCH] Add some Debug to Chunk Entity slices
|
|
|
|
If we detect unexpected state, log and try to recover
|
|
|
|
This should hopefully avoid duplicate entities ever being created
|
|
if the entity was to end up in 2 different chunk slices
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index 42b76b212..7dd59ee03 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -714,8 +714,27 @@ public class Chunk implements IChunkAccess {
|
|
entity.chunkX = this.locX;
|
|
entity.chunkY = k;
|
|
entity.chunkZ = this.locZ;
|
|
- this.entitySlices[k].add(entity);
|
|
+
|
|
// Paper start
|
|
+ List<Entity> entitySlice = this.entitySlices[k];
|
|
+ boolean inThis = entitySlice.contains(entity);
|
|
+ List<Entity> currentSlice = entity.entitySlice;
|
|
+ if (inThis || (currentSlice != null && currentSlice.contains(entity))) {
|
|
+ if (currentSlice == entitySlice || inThis) {
|
|
+ return;
|
|
+ } else {
|
|
+ Chunk chunk = entity.getCurrentChunk();
|
|
+ if (chunk != null) {
|
|
+ chunk.removeEntity(entity);
|
|
+ } else {
|
|
+ removeEntity(entity);
|
|
+ }
|
|
+ currentSlice.remove(entity); // Just incase the above did not remove from this target slice
|
|
+ }
|
|
+ }
|
|
+ entity.entitySlice = entitySlice;
|
|
+ entitySlice.add(entity);
|
|
+
|
|
this.markDirty();
|
|
if (entity instanceof EntityItem) {
|
|
itemCounts[k]++;
|
|
@@ -745,9 +764,10 @@ public class Chunk implements IChunkAccess {
|
|
i = this.entitySlices.length - 1;
|
|
}
|
|
// Paper start
|
|
- if (!this.entitySlices[i].remove(entity)) {
|
|
- return;
|
|
+ if (entity.entitySlice == null || !entity.entitySlice.contains(entity) || entitySlices[i] == entity.entitySlice) {
|
|
+ entity.entitySlice = null;
|
|
}
|
|
+ if (!this.entitySlices[i].remove(entity)) { return; }
|
|
this.markDirty();
|
|
if (entity instanceof EntityItem) {
|
|
itemCounts[i]--;
|
|
@@ -1028,6 +1048,7 @@ public class Chunk implements IChunkAccess {
|
|
}
|
|
// Spigot End
|
|
entity.setCurrentChunk(null); // Paper
|
|
+ entity.entitySlice = null; // Paper
|
|
|
|
// Do not pass along players, as doing so can get them stuck outside of time.
|
|
// (which for example disables inventory icon updates and prevents block breaking)
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index a211cb945..72e43622e 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -62,6 +62,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
}
|
|
}
|
|
};
|
|
+ List<Entity> entitySlice = null;
|
|
// Paper end
|
|
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
|
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
|
--
|
|
2.21.0
|
|
|