Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 19:40:07 +01:00
f835a91d15
Upstream has added the equivalent of our SentientNPC API, with exception to the EnderDragon. We've added Mob to the EnderDragon, and our SentientNPC API should behave the same. Vex#getOwner has been deprecated and a replacement Vex#getSummoner has been added using Mob. However, since 1.13 is not production ready, SentientNPC API is subject for removal in 1.13.1 since 1.13 API is not compatible with 1.12. Please move to the Mob interface ASAP. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: c5ab54d8 Expand GameRule API ab9a606c Improve entity hierarchy by adding Mob interface. CraftBukkit Changes:29e75648
Expand GameRule API50e6858b
Improve entity hierarchy by adding Mob interface.0e1d79b4
Correct error in previous patch
86 Zeilen
3.7 KiB
Diff
86 Zeilen
3.7 KiB
Diff
From f1edc0289d2b308fd8c73f64b58c8946913b6af5 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 67e2158ca1..e510940ab3 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -712,8 +712,33 @@ public class Chunk implements IChunkAccess {
|
|
entity.ae = this.locX;
|
|
entity.af = k;
|
|
entity.ag = this.locZ;
|
|
- this.entitySlices[k].add(entity);
|
|
+
|
|
// Paper start
|
|
+ List<Entity> entitySlice = this.entitySlices[k];
|
|
+ boolean inThis = entitySlice.contains(entity);
|
|
+ if (entity.entitySlice != null || inThis) {
|
|
+ if (entity.entitySlice == entitySlice || inThis) {
|
|
+ LogManager.getLogger().warn(entity + " was already in this chunk section! Report this to https://github.com/PaperMC/Paper/issues/1223");
|
|
+ new Throwable().printStackTrace();
|
|
+ return;
|
|
+ } else {
|
|
+ LogManager.getLogger().warn(entity + " is still in another ChunkSection! Report this to https://github.com/PaperMC/Paper/issues/1223");
|
|
+
|
|
+ Chunk chunk = entity.getCurrentChunk();
|
|
+ if (chunk != null) {
|
|
+ if (chunk != this) {
|
|
+ LogManager.getLogger().warn(entity + " was in another chunk at that! " + chunk.locX + "," + chunk.locZ);
|
|
+ }
|
|
+ chunk.removeEntity(entity);
|
|
+ } else {
|
|
+ removeEntity(entity);
|
|
+ }
|
|
+ new Throwable().printStackTrace();
|
|
+ }
|
|
+ }
|
|
+ entity.entitySlice = entitySlice;
|
|
+ entitySlice.add(entity);
|
|
+
|
|
this.markDirty();
|
|
if (entity instanceof EntityItem) {
|
|
itemCounts[k]++;
|
|
@@ -746,6 +771,12 @@ public class Chunk implements IChunkAccess {
|
|
if (!this.entitySlices[i].remove(entity)) {
|
|
return;
|
|
}
|
|
+ if (entitySlices[i] == entity.entitySlice) {
|
|
+ entity.entitySlice = null;
|
|
+ } else {
|
|
+ LogManager.getLogger().warn(entity + " was removed from a entitySlice we did not expect. Report this to https://github.com/PaperMC/Paper/issues/1223");
|
|
+ new Throwable().printStackTrace();
|
|
+ }
|
|
this.markDirty();
|
|
if (entity instanceof EntityItem) {
|
|
itemCounts[i]--;
|
|
@@ -979,6 +1010,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 4315804ddb..785c31089e 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -64,6 +64,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
}
|
|
}
|
|
};
|
|
+ Object entitySlice = null;
|
|
// Paper end
|
|
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
|
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
|
--
|
|
2.18.0
|
|
|