Begin remigrate to Shiroha

uhm
This commit is contained in:
2026-07-14 11:32:51 +08:00
parent 5661499e95
commit 576a9a44c8
60 changed files with 379 additions and 379 deletions
@@ -12,10 +12,10 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
for (final ChunkHolder chunkHolder : from.chunkHoldersToBroadcast) {
into.chunkHoldersToBroadcast.add(chunkHolder);
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ into.portalRateThrottler.mergeWith(from.portalRateThrottler);
+ from.portalRateThrottler.destroy();
+ // Camellia end
+ // Shiroha end
}
@Override
@@ -23,12 +23,12 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
into.chunkHoldersToBroadcast.add(chunkHolder);
}
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ for (var worldData : dataSet) {
+ from.portalRateThrottler.splitInto(worldData.portalRateThrottler);
+ }
+ from.portalRateThrottler.destroy();
+ // Camellia end
+ // Shiroha end
}
};
@@ -36,7 +36,7 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
return this.isHandlingTick;
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ public final moe.monnairealms.camellia.utils.RateThrottler portalRateThrottler = new moe.monnairealms.camellia.utils.RateThrottler();
+ public final net.objecthunter.exp4j.Expression portalRateCapExpression = moe.monnairealms.camellia.config.modules.function.PortalRateLimiterConfig.getExpressionIfConfigured();
+
@@ -64,7 +64,7 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
+
+ return this.portalRateThrottler.isOutOfRate(this.computePortalRateCap());
+ }
+ // Camellia end
+ // Shiroha end
// entities
// this is copy on write to allow packet processing to iterate safely
private final CopyOnWriteArrayList<ServerPlayer> localPlayers = new CopyOnWriteArrayList<>();
@@ -76,9 +76,9 @@ index cdb1647146f526dc80b15a09d3a936b5dbc54ba3..4ce5bdd16b04f76c2e98a5465343a82e
//net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = level.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers // Folia - region threading
profiler.push(() -> level + " " + level.dimension().identifier());
profiler.push("tick");
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ regionizedWorldData.portalRateThrottler.begin();
+ // Camellia end
+ // Shiroha end
try {
foliaProfiler.startTimer(level.tickTimerId); try { // Folia - profiler
@@ -86,9 +86,9 @@ index cdb1647146f526dc80b15a09d3a936b5dbc54ba3..4ce5bdd16b04f76c2e98a5465343a82e
profiler.pop();
profiler.pop();
regionizedWorldData.explosionDensityCache.clear(); // Paper - Optimize explosions // Folia - region threading
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ regionizedWorldData.portalRateThrottler.done();
+ // Camellia end
+ // Shiroha end
}
//this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked // Folia - region threading
@@ -100,15 +100,15 @@ index 0097c55adf5578f425b476b3498db1c701189e4b..1a0e5fbc823c328d16f48f2df4507bf2
// removed from region while ticking
return;
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ var worldData = entity.level().getCurrentWorldData();
+ if (entity.portalProcess != null && worldData.isPortalTeleportationOutOfRate()) {
+ return;
+ }
+ // Camellia end
+ // Shiroha end
if (entity.handlePortal()) {
// portalled
+ worldData.portalRateThrottler.increase(); // Camellia - Add portal rate limiter
+ worldData.portalRateThrottler.increase(); // Shiroha - Add portal rate limiter
return;
}
}
@@ -116,15 +116,15 @@ index 0097c55adf5578f425b476b3498db1c701189e4b..1a0e5fbc823c328d16f48f2df4507bf2
// removed from region while ticking
return;
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ var worldData = entity.level().getCurrentWorldData();
+ if (entity.portalProcess != null && worldData.isPortalTeleportationOutOfRate()) {
+ return;
+ }
+ // Camellia end
+ // Shiroha end
if (entity.handlePortal()) {
// portalled
+ worldData.portalRateThrottler.increase(); // Camellia - Add portal rate limiter
+ worldData.portalRateThrottler.increase(); // Shiroha - Add portal rate limiter
return;
}
// Folia end - region threading