feat: slow down PSH mutex checks

This commit is contained in:
xtex 2023-07-26 16:46:50 +08:00
parent fa16d2172f
commit 30187548bb
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -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)
}
}
}
}