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,6 +12,7 @@ object ProjectionShellMutex {
init { init {
TickEvent.SERVER_POST.register { server -> TickEvent.SERVER_POST.register { server ->
if (server.tickCount and 8 == 0) {
val mutex = (server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`() val mutex = (server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`()
val currentTime = System.currentTimeMillis() val currentTime = System.currentTimeMillis()
mutex.forEach { (pos, lock) -> mutex.forEach { (pos, lock) ->
@ -22,6 +23,7 @@ object ProjectionShellMutex {
} }
} }
} }
}
fun tryLock(level: ServerLevel, pos: BlockPos, player: ServerPlayer): Boolean { fun tryLock(level: ServerLevel, pos: BlockPos, player: ServerPlayer): Boolean {
val mutex = (level.server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`() val mutex = (level.server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`()