Players now have finite resources in spectator mode

this seems like the logical solution for the block picking issues.
This commit is contained in:
Dylan K. Taylor 2023-05-16 23:02:33 +01:00
parent 5c85a7c306
commit 008a022ec1
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1191,7 +1191,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
* TODO: make this a dynamic ability instead of being hardcoded
*/
public function hasFiniteResources() : bool{
return $this->gamemode->equals(GameMode::SURVIVAL()) || $this->gamemode->equals(GameMode::ADVENTURE());
return !$this->gamemode->equals(GameMode::CREATIVE());
}
public function isFireProof() : bool{
@ -1657,7 +1657,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() || $this->isSpectator())){
if($existingSlot === -1 && $this->hasFiniteResources()){
$ev->cancel();
}
$ev->call();