mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
57dd397155
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: b999860d SPIGOT-2304: Add LootGenerateEvent CraftBukkit Changes:77fd87e4
SPIGOT-2304: Implement LootGenerateEventa1a705ee
SPIGOT-5566: Doused campfires & fires should call EntityChangeBlockEvent41712edd
SPIGOT-5707: PersistentDataHolder not Persistent on API dropped Item
74 lines
3.2 KiB
Diff
74 lines
3.2 KiB
Diff
From f93a941f330b4f7cfeab3b724caf43790160a2b5 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 803afed60d..80b5013d95 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -489,6 +489,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;
|
|
@@ -498,6 +517,7 @@ public class Chunk implements IChunkAccess {
|
|
entity.chunkZ = this.loc.z;
|
|
this.entities.add(entity); // Paper - per chunk entity list
|
|
this.entitySlices[k].add(entity);
|
|
+ entity.entitySlice = this.entitySlices[k]; // Paper
|
|
this.markDirty(); // Paper
|
|
}
|
|
|
|
@@ -522,6 +542,10 @@ 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;
|
|
+ entity.inChunk = false;
|
|
+ }
|
|
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 a0379c6a77..838aa7da69 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -71,6 +71,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
}
|
|
}
|
|
};
|
|
+ List<Entity> entitySlice = null;
|
|
// Paper end
|
|
|
|
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
|
|
--
|
|
2.26.2
|
|
|