Paper/Spigot-Server-Patches/0100-Remove-unused-World-Tile-Entity-List.patch
Aikar 9dc4d6448b
Numerous fixes to entity related changes
While it wasn't really "broken" before, if plugins use NMS
(which they really should't be) and mess with entity management
themselves, and get it wrong, they could ultimately corrupt our
state expectations.

I've been unable to reproduce any issues locally, but these changes
are the result of me analyzing the code pretty deeply and seeing
about how to make it more durable to abnormal usage.

Any servers seeing oddities, please run with -Ddebug.entities=true
and send me any logs triggered.
2019-04-05 23:08:45 -04:00

72 lines
3.7 KiB
Diff

From 509bc747e1d9431854cb6956c0fc1d1c95e072ed Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 13 Apr 2016 00:25:28 -0400
Subject: [PATCH] Remove unused World Tile Entity List
Massive hit to performance and it is completely unnecessary.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 5fc2da0d92..04ec2a0399 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -71,7 +71,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
};
// Spigot end
protected final Set<Entity> g = com.google.common.collect.Sets.newHashSet(); // Paper
- public final List<TileEntity> tileEntityList = Lists.newArrayList();
+ //public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
private final List<TileEntity> c = Lists.newArrayList();
private final Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper
@@ -1269,7 +1269,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
timings.tileEntityTick.startTiming(); // Spigot
if (!this.tileEntityListUnload.isEmpty()) {
this.tileEntityListTick.removeAll(this.tileEntityListUnload);
- this.tileEntityList.removeAll(this.tileEntityListUnload);
+ //this.tileEntityList.removeAll(this.tileEntityListUnload); // Paper - remove unused list
this.tileEntityListUnload.clear();
}
@@ -1322,7 +1322,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
if (tileentity.x()) {
tilesThisCycle--;
this.tileEntityListTick.remove(tileTickPosition--);
- this.tileEntityList.remove(tileentity);
+ //this.tileEntityList.remove(tileentity); // Paper - remove unused list
if (this.isLoaded(tileentity.getPosition())) {
this.getChunkAtWorldCoords(tileentity.getPosition()).d(tileentity.getPosition());
}
@@ -1352,7 +1352,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
// CraftBukkit start
// From above, don't screw this up - SPIGOT-1746
- if (!this.tileEntityList.contains(tileentity1)) {
+ if (true) { // Paper - remove unused list
this.a(tileentity1);
}
// CraftBukkit end
@@ -1372,9 +1372,9 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
protected void p_() {}
public boolean a(TileEntity tileentity) {
- boolean flag = this.tileEntityList.add(tileentity);
+ boolean flag = true; // Paper - remove unused list
- if (flag && tileentity instanceof ITickable) {
+ if (flag && tileentity instanceof ITickable && !this.tileEntityListTick.contains(tileentity)) { // Paper
this.tileEntityListTick.add(tileentity);
}
@@ -1855,7 +1855,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
} else {
if (tileentity != null) {
this.c.remove(tileentity);
- this.tileEntityList.remove(tileentity);
+ //this.tileEntityList.remove(tileentity); // Paper - remove unused list
this.tileEntityListTick.remove(tileentity);
}
--
2.21.0