Fix MC-117075: Block entity unload lag spike
This commit is contained in:
@@ -237,7 +237,7 @@
|
|||||||
|
|
||||||
+ // Paper start - if loaded
|
+ // Paper start - if loaded
|
||||||
@Nullable
|
@Nullable
|
||||||
+ @Override
|
@Override
|
||||||
+ public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) {
|
+ public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) {
|
||||||
+ return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z);
|
+ return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z);
|
||||||
+ }
|
+ }
|
||||||
@@ -290,7 +290,7 @@
|
|||||||
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
|
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@Override
|
+ @Override
|
||||||
public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create);
|
ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create);
|
||||||
@@ -415,14 +415,14 @@
|
|||||||
+
|
+
|
||||||
+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
|
+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
|
||||||
+ this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i);
|
+ this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i);
|
||||||
}
|
+ }
|
||||||
+
|
+
|
||||||
+ if ((i & 1) != 0) {
|
+ if ((i & 1) != 0) {
|
||||||
+ this.blockUpdated(blockposition, iblockdata1.getBlock());
|
+ this.blockUpdated(blockposition, iblockdata1.getBlock());
|
||||||
+ if (!this.isClientSide && iblockdata.hasAnalogOutputSignal()) {
|
+ if (!this.isClientSide && iblockdata.hasAnalogOutputSignal()) {
|
||||||
+ this.updateNeighbourForOutputSignal(blockposition, newBlock.getBlock());
|
+ this.updateNeighbourForOutputSignal(blockposition, newBlock.getBlock());
|
||||||
+ }
|
+ }
|
||||||
+ }
|
}
|
||||||
+
|
+
|
||||||
+ if ((i & 16) == 0 && j > 0) {
|
+ if ((i & 16) == 0 && j > 0) {
|
||||||
+ int k = i & -34;
|
+ int k = i & -34;
|
||||||
@@ -474,7 +474,7 @@
|
|||||||
|
|
||||||
return chunk.getBlockState(pos);
|
return chunk.getBlockState(pos);
|
||||||
}
|
}
|
||||||
@@ -446,14 +719,21 @@
|
@@ -446,32 +719,44 @@
|
||||||
this.pendingBlockEntityTickers.clear();
|
this.pendingBlockEntityTickers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,6 +486,8 @@
|
|||||||
- while (iterator.hasNext()) {
|
- while (iterator.hasNext()) {
|
||||||
- TickingBlockEntity tickingblockentity = (TickingBlockEntity) iterator.next();
|
- TickingBlockEntity tickingblockentity = (TickingBlockEntity) iterator.next();
|
||||||
+ int tilesThisCycle = 0;
|
+ int tilesThisCycle = 0;
|
||||||
|
+ var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
|
||||||
|
+ toRemove.add(null); // Paper - Fix MC-117075
|
||||||
+ for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
+ for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
||||||
+ this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
|
+ this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
|
||||||
+ TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
|
+ TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
|
||||||
@@ -495,12 +497,13 @@
|
|||||||
- iterator.remove();
|
- iterator.remove();
|
||||||
+ // Spigot start
|
+ // Spigot start
|
||||||
+ tilesThisCycle--;
|
+ tilesThisCycle--;
|
||||||
+ this.blockEntityTickers.remove(this.tileTickPosition--);
|
+ toRemove.add(tickingblockentity); // Paper - Fix MC-117075; use removeAll
|
||||||
+ // Spigot end
|
+ // Spigot end
|
||||||
} else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) {
|
} else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) {
|
||||||
tickingblockentity.tick();
|
tickingblockentity.tick();
|
||||||
}
|
}
|
||||||
@@ -461,17 +741,19 @@
|
}
|
||||||
|
+ this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
||||||
|
|
||||||
this.tickingBlockEntities = false;
|
this.tickingBlockEntities = false;
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
@@ -525,7 +528,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,13 +792,29 @@
|
@@ -510,13 +795,29 @@
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity getBlockEntity(BlockPos pos) {
|
public BlockEntity getBlockEntity(BlockPos pos) {
|
||||||
@@ -556,7 +559,7 @@
|
|||||||
this.getChunkAt(blockposition).addAndRegisterBlockEntity(blockEntity);
|
this.getChunkAt(blockposition).addAndRegisterBlockEntity(blockEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -643,7 +941,7 @@
|
@@ -643,7 +944,7 @@
|
||||||
|
|
||||||
for (int k = 0; k < j; ++k) {
|
for (int k = 0; k < j; ++k) {
|
||||||
EnderDragonPart entitycomplexpart = aentitycomplexpart[k];
|
EnderDragonPart entitycomplexpart = aentitycomplexpart[k];
|
||||||
@@ -565,7 +568,7 @@
|
|||||||
|
|
||||||
if (t0 != null && predicate.test(t0)) {
|
if (t0 != null && predicate.test(t0)) {
|
||||||
result.add(t0);
|
result.add(t0);
|
||||||
@@ -912,7 +1210,7 @@
|
@@ -912,7 +1213,7 @@
|
||||||
|
|
||||||
public static enum ExplosionInteraction implements StringRepresentable {
|
public static enum ExplosionInteraction implements StringRepresentable {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user