fix: reject lock request for non-PSH block

This commit is contained in:
xtex 2023-07-24 11:28:22 +08:00
parent 1841e71ff8
commit 68b8c73896
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

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