From 2f4a9469b658efc20fcb8b6aeacab2a3432f49a6 Mon Sep 17 00:00:00 2001 From: NoClip <35138228+AkmalFairuz@users.noreply.github.com> Date: Mon, 15 Aug 2022 22:48:37 +0700 Subject: [PATCH] Player: spectator shouldn't able to pick blocks they don't have (#5111) Jury is out on whether they should be able to pick blocks at all, or be considered to have infinite resources, but this solution has been used in a few other places already anyway, so it can be cleaned up another time. --- src/player/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/player/Player.php b/src/player/Player.php index 86e18a6c6..336ff6f8c 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -1558,7 +1558,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $ev = new PlayerBlockPickEvent($this, $block, $item); $existingSlot = $this->inventory->first($item); - if($existingSlot === -1 && $this->hasFiniteResources()){ + if($existingSlot === -1 && ($this->hasFiniteResources() || $this->isSpectator())){ $ev->cancel(); } $ev->call();