From 30187548bbb09f9029103b17f630ec56522e54af Mon Sep 17 00:00:00 2001 From: xtex Date: Wed, 26 Jul 2023 16:46:50 +0800 Subject: [PATCH] feat: slow down PSH mutex checks --- .../kotlin/quaedam/shell/ProjectionShellMutex.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/src/main/kotlin/quaedam/shell/ProjectionShellMutex.kt b/common/src/main/kotlin/quaedam/shell/ProjectionShellMutex.kt index 2cd214a..af48f68 100644 --- a/common/src/main/kotlin/quaedam/shell/ProjectionShellMutex.kt +++ b/common/src/main/kotlin/quaedam/shell/ProjectionShellMutex.kt @@ -12,12 +12,14 @@ object ProjectionShellMutex { init { TickEvent.SERVER_POST.register { server -> - val mutex = (server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`() - val currentTime = System.currentTimeMillis() - mutex.forEach { (pos, lock) -> - if (currentTime - lock.time > 60 * 1000) { - mutex.remove(pos) - ProjectionShell.channel.sendToPlayer(lock.player, ClientboundPSHLockRevokePacket) + if (server.tickCount and 8 == 0) { + val mutex = (server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`() + val currentTime = System.currentTimeMillis() + mutex.forEach { (pos, lock) -> + if (currentTime - lock.time > 60 * 1000) { + mutex.remove(pos) + ProjectionShell.channel.sendToPlayer(lock.player, ClientboundPSHLockRevokePacket) + } } } }