From 68b8c7389650acde79ff810a9934562fa03e79f2 Mon Sep 17 00:00:00 2001 From: xtex Date: Mon, 24 Jul 2023 11:28:22 +0800 Subject: [PATCH] fix: reject lock request for non-PSH block --- .../shell/network/ServerboundPSHLockAcquirePacket.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/quaedam/shell/network/ServerboundPSHLockAcquirePacket.kt b/common/src/main/kotlin/quaedam/shell/network/ServerboundPSHLockAcquirePacket.kt index 39f9147..d394a44 100644 --- a/common/src/main/kotlin/quaedam/shell/network/ServerboundPSHLockAcquirePacket.kt +++ b/common/src/main/kotlin/quaedam/shell/network/ServerboundPSHLockAcquirePacket.kt @@ -6,6 +6,7 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import quaedam.shell.ProjectionShell +import quaedam.shell.ProjectionShellBlock import quaedam.shell.ProjectionShellMutex import java.util.function.Supplier @@ -33,7 +34,12 @@ data class ServerboundPSHLockAcquirePacket(val pos: BlockPos) { if (!ctx.player.level().isClientSide) { ctx.queue { val player = ctx.player as ServerPlayer - val result = ProjectionShellMutex.tryLock(ctx.player.level() as ServerLevel, pos, player) + val level = ctx.player.level() as ServerLevel + if (level.getBlockState(pos).block !is ProjectionShellBlock) { + ProjectionShell.channel.sendToPlayer(player, ClientboundPSHLockResultPacket(pos, false)) + return@queue + } + val result = ProjectionShellMutex.tryLock(level, pos, player) ProjectionShell.channel.sendToPlayer(player, ClientboundPSHLockResultPacket(pos, result)) } }