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.
This commit is contained in:
NoClip 2022-08-15 22:48:37 +07:00 committed by GitHub
parent c5b2488fc1
commit 2f4a9469b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();