Skip to content

Commit f14ae9d

Browse files
committed
Add options to disable chunk and block entity ticking
1 parent a64ea13 commit f14ae9d

5 files changed

Lines changed: 43 additions & 0 deletions

File tree

paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@
189189
this.ticketStorage.purgeStaleTickets(this.chunkMap);
190190
}
191191

192+
@@ -344,7 +_,7 @@
193+
if (!this.level.isDebug()) {
194+
ProfilerFiller profiler = Profiler.get();
195+
profiler.push("pollingChunks");
196+
- if (this.level.tickRateManager().runsNormally()) {
197+
+ if (this.level.tickRateManager().runsNormally() && this.level.paperConfig().unsupportedSettings.ticking.chunks) { // Paper - option to disable ticking
198+
profiler.push("tickingChunks");
199+
this.tickChunks(profiler, timeDiff);
200+
profiler.pop();
192201
@@ -376,12 +_,20 @@
193202
chunkCount, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap)
194203
);

paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,18 @@
326326
if (isActive) {
327327
this.resetEmptyTime();
328328
}
329+
@@ -437,9 +_,11 @@
330+
}
331+
}
332+
);
333+
+ if (this.paperConfig().unsupportedSettings.ticking.blockEntities) { // Paper - option to disable ticking
334+
profiler.popPush("blockEntities");
335+
this.tickBlockEntities();
336+
profiler.pop();
337+
+ } // Paper - option to disable ticking
338+
}
339+
340+
profiler.push("entityManagement");
329341
@@ -468,7 +_,7 @@
330342
long time = this.levelData.getGameTime() + 1L;
331343
this.serverLevelData.setGameTime(time);

paper-server/patches/sources/net/minecraft/world/level/Level.java.patch

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,14 @@
445445
return chunk.getBlockState(pos);
446446
}
447447
}
448+
@@ -523,6 +_,7 @@
449+
}
450+
451+
public void addBlockEntityTicker(final TickingBlockEntity ticker) {
452+
+ if (!this.paperConfig().unsupportedSettings.ticking.blockEntities) return; // Paper - option to disable ticking
453+
(this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(ticker);
454+
}
455+
448456
@@ -533,31 +_,48 @@
449457
this.pendingBlockEntityTickers.clear();
450458
}

paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@
246246
public boolean isEmpty() {
247247
return false;
248248
}
249+
@@ -703,6 +_,7 @@
250+
}
251+
252+
private <T extends BlockEntity> void updateBlockEntityTicker(final T blockEntity) {
253+
+ if (!this.level.paperConfig().unsupportedSettings.ticking.blockEntities) return; // Paper - option to disable ticking
254+
BlockState state = blockEntity.getBlockState();
255+
BlockEntityTicker<T> ticker = state.getTicker(this.level, (BlockEntityType<T>)blockEntity.getType());
256+
if (ticker == null) {
249257
@@ -752,23 +_,24 @@
250258
if (this.blockEntity.getType().isValid(blockState)) {
251259
this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity);

paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ public class Fixes extends ConfigurationPart {
477477
public class UnsupportedSettings extends ConfigurationPart {
478478
public boolean fixInvulnerableEndCrystalExploit = true;
479479
public boolean disableWorldTickingWhenEmpty = false;
480+
public Ticking ticking;
481+
482+
public class Ticking extends ConfigurationPart {
483+
public boolean chunks = true;
484+
public boolean blockEntities = true;
485+
}
480486
}
481487

482488
public Hopper hopper;

0 commit comments

Comments
 (0)