Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
5c7081fecc
* Updated Upstream (Bukkit/CraftBukkit) 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 Bukkit Changes: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes:4090d01f
SPIGOT-5047: Correct slot types for 1.14 inventoriese8c08362
SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.d445af3b
SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
74 Zeilen
3.2 KiB
Diff
74 Zeilen
3.2 KiB
Diff
From 3f863b60ea75e77e1d1a9514444d0e3d9b8567ff 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 4409a6ec84..5d1947f826 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -408,6 +408,25 @@ public class Chunk implements IChunkAccess {
|
|
if (k >= this.entitySlices.length) {
|
|
k = this.entitySlices.length - 1;
|
|
}
|
|
+ // Paper - remove from any old list if its in one
|
|
+ List<Entity> nextSlice = this.entitySlices[k]; // the next list to be added to
|
|
+ List<Entity> currentSlice = entity.entitySlice;
|
|
+ if (nextSlice == currentSlice) {
|
|
+ if (World.DEBUG_ENTITIES) MinecraftServer.LOGGER.warn("Entity was already in this chunk!" + entity, new Throwable());
|
|
+ return; // ??? silly plugins
|
|
+ }
|
|
+ if (currentSlice != null && currentSlice.contains(entity)) {
|
|
+ // Still in an old chunk...
|
|
+ if (World.DEBUG_ENTITIES) MinecraftServer.LOGGER.warn("Entity is still in another chunk!" + entity, new Throwable());
|
|
+ Chunk chunk = entity.getCurrentChunk();
|
|
+ if (chunk != null) {
|
|
+ chunk.removeEntity(entity);
|
|
+ } else {
|
|
+ removeEntity(entity);
|
|
+ }
|
|
+ currentSlice.remove(entity); // Just incase the above did not remove from the previous slice
|
|
+ }
|
|
+ // Paper end
|
|
|
|
if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper
|
|
entity.inChunk = true;
|
|
@@ -416,6 +435,7 @@ public class Chunk implements IChunkAccess {
|
|
entity.chunkY = k;
|
|
entity.chunkZ = this.loc.z;
|
|
this.entitySlices[k].add(entity);
|
|
+ entity.entitySlice = this.entitySlices[k]; // Paper
|
|
this.markDirty(); // Paper
|
|
}
|
|
|
|
@@ -439,6 +459,9 @@ public class Chunk implements IChunkAccess {
|
|
}
|
|
// Paper start
|
|
if (entity.currentChunk != null && entity.currentChunk.get() == this) entity.setCurrentChunk(null);
|
|
+ if (entitySlices[i] == entity.entitySlice) {
|
|
+ entity.entitySlice = null;
|
|
+ }
|
|
if (!this.entitySlices[i].remove(entity)) {
|
|
return;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index fe9881fdf2..32162003ab 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -67,6 +67,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
|
|
|