341 lines
18 KiB
Diff
341 lines
18 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <wangxyper@163.com>
|
|
Date: Sun, 12 Jan 2025 10:27:31 +0800
|
|
Subject: [PATCH] Add tpsbar with chunkhot membar and regionbar
|
|
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java
|
|
index bd3ce123652af11974be4cbf8d2e96f1b2ee0a68..5f26fd89704aa3fd9c37a1d68a7c4c65ce1e7a5d 100644
|
|
--- a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java
|
|
+++ b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java
|
|
@@ -131,6 +131,7 @@ public abstract class BaseChunkSystemHooks implements ca.spottedleaf.moonrise.co
|
|
|
|
@Override
|
|
public void onChunkNotTicking(final LevelChunk chunk, final ChunkHolder holder) {
|
|
+ chunk.getChunkHot().clear(); // KioCG
|
|
chunk.getLevel().getCurrentWorldData().removeTickingChunk(chunk); // Folia - region threading
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index ecf185fce582a542c65a9544388b84835643978b..12062e37c0e832f27ba52844739d0e8d5519a30a 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1663,7 +1663,46 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// Folia end - region threading
|
|
//this.tickCount++; // Folia - region threading
|
|
//this.tickRateManager.tick(); // Folia - region threading
|
|
+ // KioCG start - ChunkHot
|
|
+ final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.level.chunk.LevelChunk> chunks = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>();
|
|
+ if (region != null){
|
|
+ for (net.minecraft.world.level.chunk.LevelChunk chunk : region.world.getCurrentWorldData().getTickingChunks()) {
|
|
+ /* wait for rewrite - temporarily crash fix
|
|
+ for (net.minecraft.server.level.ServerChunkCache.ChunkAndHolder chunkAndHolder : region.world.getCurrentWorldData().getTickingChunks()){
|
|
+ final net.minecraft.world.level.chunk.LevelChunk chunk = chunkAndHolder.chunk();
|
|
+ */
|
|
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(region.world, chunk.locX, chunk.locZ)){
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ chunks.add(chunk);
|
|
+ }
|
|
+ }
|
|
+ if (region != null && io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() % 20 == 0){
|
|
+ final java.util.Iterator<net.minecraft.world.level.chunk.LevelChunk> chunkIterator = chunks.unsafeIterator();
|
|
+ while (chunkIterator.hasNext()){
|
|
+ final net.minecraft.world.level.chunk.LevelChunk targetChunk = chunkIterator.next();
|
|
+
|
|
+ targetChunk.getChunkHot().nextTick();
|
|
+ targetChunk.getChunkHot().start();
|
|
+ }
|
|
+ }
|
|
+ //KioCG end
|
|
this.tickChildren(hasTimeLeft, region); // Folia - region threading
|
|
+ // KioCG start - ChunkHot
|
|
+ if (region != null && io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() % 20 == 0){
|
|
+ final java.util.Iterator<net.minecraft.world.level.chunk.LevelChunk> chunkIterator = chunks.unsafeIterator();
|
|
+ while (chunkIterator.hasNext()){
|
|
+ final net.minecraft.world.level.chunk.LevelChunk targetChunk = chunkIterator.next();
|
|
+
|
|
+ if (!targetChunk.getChunkHot().isStarted()){
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ targetChunk.getChunkHot().stop();
|
|
+ }
|
|
+ }
|
|
+ //KioCG end
|
|
if (false && nanos - this.lastServerStatus >= STATUS_EXPIRE_TIME_NANOS) { // Folia - region threading
|
|
this.lastServerStatus = nanos;
|
|
this.status = this.buildServerStatus();
|
|
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index e76599e92e4bf4f5b5d7176f4a0a2a854d10818a..20df6b46c420b25b598accb57b921055fb0c988b 100644
|
|
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -724,6 +724,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
|
|
@Override
|
|
public void stopServer() {
|
|
+ me.earthme.luminol.functions.GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar
|
|
+ me.earthme.luminol.functions.GlobalServerMemoryBar.cancelBarUpdateTask(); //Luminol - Memory bar
|
|
+ me.earthme.luminol.functions.GlobalServerRegionBar.cancelBarUpdateTask(); //Luminol - Region bar
|
|
super.stopServer();
|
|
//Util.shutdownExecutors(); // Paper - Improved watchdog support; moved into super
|
|
SkullBlockEntity.clear();
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 94fb1c99baefbdde91dc5fcf103683c7ffda6baf..b4fdbdba579fa7c7de4928c259b5ff16b0e83aeb 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1342,6 +1342,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
final int timerId = isActive ? entity.getType().tickTimerId : entity.getType().inactiveTickTimerId;
|
|
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler();
|
|
profiler.startTimer(timerId);
|
|
+ LevelChunk levelChunk = entity.shouldTickHot() ? this.getChunkIfLoaded(entity.moonrise$getSectionX(),entity.moonrise$getSectionZ()) : null; // KioCG
|
|
+ if (levelChunk != null) levelChunk.getChunkHot().startTicking(); try { // KioCG
|
|
try {
|
|
// Folia end - profiler
|
|
if (isActive) { // Paper - EAR 2
|
|
@@ -1359,6 +1361,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
} else {entity.inactiveTick();} // Paper - EAR 2
|
|
profilerFiller.pop();
|
|
} finally { profiler.stopTimer(timerId); } // Folia - profiler
|
|
+ } finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG
|
|
|
|
for (Entity entity1 : entity.getPassengers()) {
|
|
this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2
|
|
@@ -1378,6 +1381,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
final int timerId = isActive ? passengerEntity.getType().tickTimerId : passengerEntity.getType().inactiveTickTimerId;
|
|
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler();
|
|
profiler.startTimer(timerId);
|
|
+ LevelChunk levelChunk = !(passengerEntity instanceof Player) ? this.getChunkIfLoaded(passengerEntity.blockPosition()) : null; // KioCG
|
|
+ if (levelChunk != null) levelChunk.getChunkHot().startTicking(); try { // KioCG
|
|
try {
|
|
// Folia end - profiler
|
|
passengerEntity.setOldPosAndRot();
|
|
@@ -1412,6 +1417,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
this.tickPassenger(passengerEntity, entity, isActive); // Paper - EAR 2
|
|
}
|
|
} finally { profiler.stopTimer(timerId); } // Folia - profiler
|
|
+ } finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG
|
|
}
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
|
index 111f2f05d0ad3f290dab97f231caf8516821e030..047279cce3ff3a9eedd54db370b8fa6754d85ee4 100644
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -420,7 +420,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
|
|
public @Nullable String clientBrandName = null; // Paper - Brand support
|
|
public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
|
|
-
|
|
+ public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
|
+ public volatile boolean isMemBarVisible = false; //Luminol - Memory bar
|
|
+ public volatile boolean isRegionBarVisible = false; //Luminol - Region bar
|
|
// Paper start - rewrite chunk system
|
|
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
|
private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder();
|
|
@@ -957,8 +959,35 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
this.trackEnteredOrExitedLavaOnVehicle();
|
|
this.updatePlayerAttributes();
|
|
this.advancements.flushDirty(this, true);
|
|
+
|
|
+ // KioCG start - ChunkHot
|
|
+ if (this.tickCount % 20 == 0){
|
|
+ this.nearbyChunkHot = this.refreshNearbyChunkHot();
|
|
+ }
|
|
+ // KioCG end
|
|
}
|
|
|
|
+ // KioCG start - ChunkHot
|
|
+ private volatile long nearbyChunkHot = 0;
|
|
+
|
|
+ public long getNearbyChunkHot() { return this.nearbyChunkHot; }
|
|
+
|
|
+ private long refreshNearbyChunkHot() {
|
|
+ long total = 0L;
|
|
+ int searchRadius = ((ServerLevel) this.level()).moonrise$getViewDistanceHolder().getViewDistances().tickViewDistance();
|
|
+ for (int i = this.moonrise$getSectionX() - searchRadius; i <= this.moonrise$getSectionX() + searchRadius; ++i) {
|
|
+ for (int j = this.moonrise$getSectionZ() - searchRadius; j <= this.moonrise$getSectionZ() + searchRadius; ++j) {
|
|
+ net.minecraft.world.level.chunk.LevelChunk targetChunk = this.level().getChunkIfLoaded(i, j);
|
|
+ if (targetChunk != null) {
|
|
+ total += targetChunk.getChunkHot().getAverage();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return total;
|
|
+ }
|
|
+ // KioCG end
|
|
+
|
|
+
|
|
private void updatePlayerAttributes() {
|
|
AttributeInstance attribute = this.getAttribute(Attributes.BLOCK_INTERACTION_RANGE);
|
|
if (attribute != null) {
|
|
diff --git a/net/minecraft/world/entity/AreaEffectCloud.java b/net/minecraft/world/entity/AreaEffectCloud.java
|
|
index bfd904e468bbf2cc1a5b3353d3a69ad5087c81ae..116933975ac975bb5a801be81e1c0e9bd641f162 100644
|
|
--- a/net/minecraft/world/entity/AreaEffectCloud.java
|
|
+++ b/net/minecraft/world/entity/AreaEffectCloud.java
|
|
@@ -436,4 +436,11 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
|
|
return super.applyImplicitComponent(component, value);
|
|
}
|
|
}
|
|
+
|
|
+ // KioCG start
|
|
+ @Override
|
|
+ public boolean shouldTickHot() {
|
|
+ return false;
|
|
+ }
|
|
+ // KioCG end
|
|
}
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index e9ea86d77395975afbe189993ee0dbbd066c3536..0228471a16805042f13158b86379a77371600489 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -6000,5 +6000,4 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return false;
|
|
return this.outOfCamera;
|
|
}
|
|
-
|
|
}
|
|
diff --git a/net/minecraft/world/entity/LightningBolt.java b/net/minecraft/world/entity/LightningBolt.java
|
|
index c1c63c77598786d86b4aa4475cc4d36e60955085..27dd86d1d94959cbe8376ee714e3306732151105 100644
|
|
--- a/net/minecraft/world/entity/LightningBolt.java
|
|
+++ b/net/minecraft/world/entity/LightningBolt.java
|
|
@@ -287,4 +287,11 @@ public class LightningBolt extends Entity {
|
|
public final boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) {
|
|
return false;
|
|
}
|
|
+
|
|
+ // KioCG start
|
|
+ @Override
|
|
+ public boolean shouldTickHot() {
|
|
+ return false;
|
|
+ }
|
|
+ // KioCG end
|
|
}
|
|
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
|
index a96318e5684d61b2bee998531695b0fe12e9deac..34738e880e6ef30730fc72d7b0fb89c53783be17 100644
|
|
--- a/net/minecraft/world/entity/Mob.java
|
|
+++ b/net/minecraft/world/entity/Mob.java
|
|
@@ -1592,4 +1592,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
this.getNavigation().updatePathfinderMaxVisitedNodes();
|
|
}
|
|
}
|
|
+
|
|
+ // KioCG start
|
|
+ @Override
|
|
+ public boolean shouldTickHot() {
|
|
+ return super.shouldTickHot() && (!this.removeWhenFarAway(0.0) || this.isPersistenceRequired() || this.requiresCustomPersistence());
|
|
+ }
|
|
+ // KioCG end
|
|
}
|
|
diff --git a/net/minecraft/world/entity/animal/horse/TraderLlama.java b/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
|
index 38a5554d6e28ab73c225625531c94592a46d50a8..149fe0c4c2df7cd6925308f6bca5772050594cf3 100644
|
|
--- a/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
|
+++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
|
@@ -156,4 +156,11 @@ public class TraderLlama extends Llama {
|
|
super.start();
|
|
}
|
|
}
|
|
+
|
|
+ // KioCG start
|
|
+ @Override
|
|
+ public boolean shouldTickHot() {
|
|
+ return super.shouldTickHot() && !this.canDespawn();
|
|
+ }
|
|
+ // KioCG end
|
|
}
|
|
diff --git a/net/minecraft/world/entity/npc/WanderingTrader.java b/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
index 70cc20483905d3877e2ffb51afb4902bd59f0cd0..fff3965d892e20a3ad9c84fad2c2df2ffe931fe2 100644
|
|
--- a/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
+++ b/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
@@ -277,4 +277,11 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
|
|
return !pos.closerToCenterThan(this.trader.position(), distance);
|
|
}
|
|
}
|
|
+
|
|
+ // KioCG start
|
|
+ @Override
|
|
+ public boolean shouldTickHot() {
|
|
+ return false;
|
|
+ }
|
|
+ // KioCG end
|
|
}
|
|
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
|
index 5af32286092222f09ad2b54dd2fa6bd9ad3a8f40..0d774fd4be1cdcf03e76db8b17309bbf01bafc55 100644
|
|
--- a/net/minecraft/world/entity/player/Player.java
|
|
+++ b/net/minecraft/world/entity/player/Player.java
|
|
@@ -1521,6 +1521,13 @@ public abstract class Player extends LivingEntity {
|
|
return true;
|
|
}
|
|
|
|
+ // KioCG start
|
|
+ @Override
|
|
+ public boolean shouldTickHot() {
|
|
+ return false;
|
|
+ }
|
|
+ // KioCG end
|
|
+
|
|
public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos bedPos) {
|
|
// CraftBukkit start
|
|
return this.startSleepInBed(bedPos, false);
|
|
diff --git a/net/minecraft/world/entity/projectile/Projectile.java b/net/minecraft/world/entity/projectile/Projectile.java
|
|
index 487e550d6d1f44597cfe14c4aaeb3713e3d916b7..7308dab3248b3319cee6fd0dabfe8e4b7c2628cf 100644
|
|
--- a/net/minecraft/world/entity/projectile/Projectile.java
|
|
+++ b/net/minecraft/world/entity/projectile/Projectile.java
|
|
@@ -527,4 +527,11 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
|
public interface ProjectileFactory<T extends Projectile> {
|
|
T create(ServerLevel level, LivingEntity owner, ItemStack spawnedFrom);
|
|
}
|
|
+
|
|
+ // KioCG start
|
|
+ @Override
|
|
+ public boolean shouldTickHot() {
|
|
+ return false;
|
|
+ }
|
|
+ // KioCG end
|
|
}
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index 23ccd2bc86e643eb3e79195d20c1182d3ad7ead6..569c13814e99f884048742226c2871fabf1e9790 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -104,6 +104,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
// Paper start - rewrite chunk system
|
|
private boolean postProcessingDone;
|
|
private ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkAndHolder;
|
|
+ private final com.kiocg.ChunkHot chunkHot = new com.kiocg.ChunkHot(); public com.kiocg.ChunkHot getChunkHot() { return this.chunkHot; } // KioCG
|
|
|
|
@Override
|
|
public final boolean moonrise$isPostProcessingDone() {
|
|
@@ -930,6 +931,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
try {
|
|
ProfilerFiller profilerFiller = Profiler.get();
|
|
profilerFiller.push(this::getType);
|
|
+ LevelChunk.this.chunkHot.startTicking(); // KioCG
|
|
profiler.startTimer(timerId); try { // Folia - profiler
|
|
BlockState blockState = LevelChunk.this.getBlockState(blockPos);
|
|
if (this.blockEntity.getType().isValid(blockState)) {
|
|
@@ -944,7 +946,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
}
|
|
// Paper end - Remove the Block Entity if it's invalid
|
|
}
|
|
- } finally { profiler.stopTimer(timerId); } // Folia - profiler
|
|
+ } finally { profiler.stopTimer(timerId); LevelChunk.this.chunkHot.stopTickingAndCount(); } // Folia - profiler // KioCG
|
|
|
|
profilerFiller.pop();
|
|
} catch (Throwable var5) {
|
|
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
index 332b33a004ab11150cca0cc2cefc26d0286648f5..714e291b17856aacdac7db992fc18e6ae662f659 100644
|
|
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
@@ -57,7 +57,10 @@ public interface NeighborUpdater {
|
|
return;
|
|
}
|
|
// CraftBukkit end
|
|
+ net.minecraft.world.level.chunk.LevelChunk levelChunk = level.getChunkIfLoaded(pos); // KioCG
|
|
+ if (levelChunk != null) levelChunk.getChunkHot().startTicking(); try { // KioCG
|
|
state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston);
|
|
+ } finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG
|
|
// Spigot start
|
|
} catch (StackOverflowError ex) {
|
|
level.lastPhysicsProblem = pos.immutable();
|