mirror of
https://github.com/SparklyPower/SparklyPaper.git
synced 2025-12-23 08:59:19 +00:00
63 lines
3.8 KiB
Diff
63 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Paul Sauve <paul@technove.co>
|
|
Date: Sat, 13 Mar 2021 10:40:22 -0600
|
|
Subject: [PATCH] Reduce entity chunk ticking checks from 3 to 1
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
index 136faf61770011a830cc58259d1dad11830ca808..26379b411d35818bfe59c1b39e2f90417a67c969 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
@@ -1083,11 +1083,12 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
// CraftBukkit end */
|
|
|
|
gameprofilerfiller.enter("checkDespawn");
|
|
+ boolean entityTickingChunk = false; if (!entity.dead) entityTickingChunk = this.getChunkProvider().isInEntityTickingChunk(entity); // Airplane - check once, chunks won't unload ticking entities
|
|
if (!entity.dead) {
|
|
entity.checkDespawn();
|
|
// Tuinity start - optimise notify()
|
|
if (entity.inChunk && entity.valid) {
|
|
- if (this.getChunkProvider().isInEntityTickingChunk(entity)) {
|
|
+ if (entityTickingChunk) { // Airplane - reuse
|
|
this.updateNavigatorsInRegion(entity);
|
|
}
|
|
} else {
|
|
@@ -1113,7 +1114,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
*/
|
|
boolean doMidTick = false; // usually there's a returns in the catch, so treat it like that
|
|
try {
|
|
- this.entityJoinedWorld(entity);
|
|
+ this.entityJoinedWorld(entity, entityTickingChunk); // Airplane - reuse
|
|
doMidTick = true;
|
|
} catch (Throwable throwable) {
|
|
if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
|
@@ -1138,7 +1139,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
this.entitiesById.remove(entity.getId()); // Tuinity
|
|
this.unregisterEntity(entity);
|
|
} else if (entity.inChunk && entity.valid) { // Tuinity start - optimise notify()
|
|
- if (this.getChunkProvider().isInEntityTickingChunk(entity)) {
|
|
+ if (entityTickingChunk) { // Airplane - reuse
|
|
this.updateNavigatorsInRegion(entity);
|
|
}
|
|
} else {
|
|
@@ -1438,7 +1439,9 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
}
|
|
// Tuinity end - log detailed entity tick information
|
|
|
|
- public void entityJoinedWorld(Entity entity) {
|
|
+ // Airplane start - reuse check for in entity ticking chunk
|
|
+ public void entityJoinedWorld(Entity entity) { entityJoinedWorld(entity, this.getChunkProvider().isInEntityTickingChunk(entity)); }
|
|
+ public void entityJoinedWorld(Entity entity, boolean entityTickingChunk) { // Airplane end
|
|
// Tuinity start - log detailed entity tick information
|
|
com.tuinity.tuinity.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
|
|
try {
|
|
@@ -1446,7 +1449,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
currentlyTickingEntity.lazySet(entity);
|
|
}
|
|
// Tuinity end - log detailed entity tick information
|
|
- if (!(entity instanceof EntityHuman) && !this.getChunkProvider().a(entity)) {
|
|
+ if (!(entity instanceof EntityHuman) && !entityTickingChunk) { // Airplane - reuse
|
|
this.chunkCheck(entity);
|
|
} else {
|
|
++TimingHistory.entityTicks; // Paper - timings
|