diff --git a/Spigot-Server-Patches/Make-sure-to-remove-correct-TE-during-TE-tick.patch b/Spigot-Server-Patches/Make-sure-to-remove-correct-TE-during-TE-tick.patch new file mode 100644 index 0000000000..6988095841 --- /dev/null +++ b/Spigot-Server-Patches/Make-sure-to-remove-correct-TE-during-TE-tick.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Mon, 29 Mar 2021 09:07:25 +0200 +Subject: [PATCH] Make sure to remove correct TE during TE tick + +This looks like it can cause premature TE removal. + +diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/World.java ++++ b/src/main/java/net/minecraft/world/level/World.java +@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { + //this.tileEntityList.remove(tileentity); // Paper - remove unused list + // Paper - prevent double chunk lookups + Chunk chunk; if ((chunk = this.getChunkIfLoaded(tileentity.getPosition())) != null) { // inlined contents of this.isLoaded(BlockPosition). Reuse the returned chunk instead of looking it up again +- chunk.removeTileEntity(tileentity.getPosition()); ++ chunk.removeTileEntity(tileentity.getPosition(), tileentity); // Paper - remove correct TE + } + // Paper end + } +diff --git a/src/main/java/net/minecraft/world/level/chunk/Chunk.java b/src/main/java/net/minecraft/world/level/chunk/Chunk.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/Chunk.java ++++ b/src/main/java/net/minecraft/world/level/chunk/Chunk.java +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + + @Override + public void removeTileEntity(BlockPosition blockposition) { ++ // Paper start - remove correct TE ++ removeTileEntity(blockposition, null); ++ } ++ public void removeTileEntity(BlockPosition blockposition, TileEntity match) { ++ // Paper end + if (this.loaded || this.world.s_()) { +- TileEntity tileentity = (TileEntity) this.tileEntities.remove(blockposition); ++ // Paper start ++ TileEntity tileentity = (TileEntity) this.tileEntities.get(blockposition); + +- if (tileentity != null) { ++ if (tileentity != null && (match == null || match == tileentity)) { ++ this.tileEntities.remove(tileentity); ++ // Paper end + tileentity.al_(); + } + }