From 968a3ee539d3379c84fdc1f219e86e94d2dcd659 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 16 Dec 2022 13:31:51 -0800 Subject: [PATCH] Don't call lock check event if the block entity doesn't exist (#8687) --- patches/server/Add-BlockLockCheckEvent.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/server/Add-BlockLockCheckEvent.patch b/patches/server/Add-BlockLockCheckEvent.patch index bd11dcd6be..9f4d5cc29d 100644 --- a/patches/server/Add-BlockLockCheckEvent.patch +++ b/patches/server/Add-BlockLockCheckEvent.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return canUnlock(player, lock, containerName, null); + } + public static boolean canUnlock(Player player, LockCode lock, Component containerName, @Nullable BlockEntity blockEntity) { -+ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer && blockEntity != null && blockEntity.getLevel() != null) { ++ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer && blockEntity != null && blockEntity.getLevel() != null && blockEntity.getLevel().getBlockEntity(blockEntity.getBlockPos()) == blockEntity) { + final org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos()); + net.kyori.adventure.text.Component lockedMessage = net.kyori.adventure.text.Component.translatable("container.isLocked", io.papermc.paper.adventure.PaperAdventure.asAdventure(containerName)); + net.kyori.adventure.sound.Sound lockedSound = net.kyori.adventure.sound.Sound.sound(org.bukkit.Sound.BLOCK_CHEST_LOCKED, net.kyori.adventure.sound.Sound.Source.BLOCK, 1.0F, 1.0F);