2021-06-14 08:41:01 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 21 Jul 2018 08:25:40 -0400
|
|
|
|
Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
2024-01-23 14:34:17 +01:00
|
|
|
index 422ef83670f7c4a2e5b0da48dc0906ad96b8ece0..e4936a70d3a686e5cba0ea9d878f6e09fbee713d 100644
|
2021-06-14 08:41:01 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
2023-12-25 23:51:56 +01:00
|
|
|
@@ -878,6 +878,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
2021-06-14 08:41:01 +02:00
|
|
|
} else {
|
|
|
|
ChunkMap.TrackedEntity playerchunkmap_entitytracker = new ChunkMap.TrackedEntity(entity, i, j, entitytypes.trackDeltas());
|
|
|
|
|
|
|
|
+ entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
|
|
|
|
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
|
|
|
|
playerchunkmap_entitytracker.updatePlayers(this.level.players());
|
|
|
|
if (entity instanceof ServerPlayer) {
|
2023-12-25 23:51:56 +01:00
|
|
|
@@ -920,7 +921,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
2021-06-14 08:41:01 +02:00
|
|
|
if (playerchunkmap_entitytracker1 != null) {
|
|
|
|
playerchunkmap_entitytracker1.broadcastRemoved();
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+ entity.tracker = null; // Paper - We're no longer tracked
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void tick() {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2024-01-23 15:43:48 +01:00
|
|
|
index d993f6421e17a24bd6c371298ae78c2bc2f8a7ac..b818ac80bd9d68f6058e4dc6ee447645083dc177 100644
|
2021-06-14 08:41:01 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2024-01-21 17:39:05 +01:00
|
|
|
@@ -1436,6 +1436,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2021-06-14 08:41:01 +02:00
|
|
|
// CraftBukkit start
|
2021-11-23 16:04:41 +01:00
|
|
|
private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
|
2021-06-14 08:41:01 +02:00
|
|
|
org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper start - extra debug info
|
2021-06-14 08:41:01 +02:00
|
|
|
+ if (entity.valid) {
|
2024-01-21 17:39:05 +01:00
|
|
|
+ MinecraftServer.LOGGER.error("Attempted Double World add on {}", entity, new Throwable());
|
2021-06-14 08:41:01 +02:00
|
|
|
+ return true;
|
|
|
|
+ }
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper end - extra debug info
|
2021-06-14 08:41:01 +02:00
|
|
|
if (entity.isRemoved()) {
|
2021-11-23 16:04:41 +01:00
|
|
|
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
|
2021-06-14 08:41:01 +02:00
|
|
|
return false;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-01-23 14:34:17 +01:00
|
|
|
index 47ba1f8fbbe3e5a052028ee1dbff31844bc61f78..72478a84e1dca85bb9694ea9816a1acc09c8ff5f 100644
|
2021-06-14 08:41:01 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-01-21 17:39:05 +01:00
|
|
|
@@ -241,6 +241,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
2021-06-14 08:41:01 +02:00
|
|
|
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
|
|
|
|
private CraftEntity bukkitEntity;
|
|
|
|
|
2021-12-13 05:31:32 +01:00
|
|
|
+ public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper
|
2021-06-14 08:41:01 +02:00
|
|
|
public CraftEntity getBukkitEntity() {
|
|
|
|
if (this.bukkitEntity == null) {
|
|
|
|
this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
2024-01-21 17:39:05 +01:00
|
|
|
index 21a2800db22f287b9c6a8290326fdf3b94ae94b1..2e561ac90a8c91ea13cfc18d09f8e0abbcff9385 100644
|
2021-06-14 08:41:01 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
2024-01-21 17:39:05 +01:00
|
|
|
@@ -34,6 +34,14 @@ public class EntityLookup<T extends EntityAccess> {
|
2021-06-14 08:41:01 +02:00
|
|
|
UUID uUID = entity.getUUID();
|
|
|
|
if (this.byUuid.containsKey(uUID)) {
|
|
|
|
LOGGER.warn("Duplicate entity UUID {}: {}", uUID, entity);
|
|
|
|
+ // Paper start - extra debug info
|
2024-01-21 17:39:05 +01:00
|
|
|
+ if (entity instanceof net.minecraft.world.entity.Entity) {
|
|
|
|
+ final T old = this.byUuid.get(entity.getUUID());
|
|
|
|
+ if (old instanceof net.minecraft.world.entity.Entity oldCast && oldCast.getId() != entity.getId() && oldCast.valid) {
|
|
|
|
+ LOGGER.error("Overwrote an existing entity {} with {}", oldCast, entity);
|
2021-06-14 08:41:01 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper end - extra debug info
|
2021-06-14 08:41:01 +02:00
|
|
|
} else {
|
|
|
|
this.byUuid.put(uUID, entity);
|
|
|
|
this.byId.put(entity.getId(), entity);
|