From 335fcc8ed1ba8ea24c49f85d43d0dc203de6cafd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 7 Oct 2025 17:49:12 +0100 Subject: [PATCH] Trident: do not allow using if damage is too high fixes #6828 --- src/item/Trident.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/item/Trident.php b/src/item/Trident.php index 991f45b1d..7efd68d9f 100644 --- a/src/item/Trident.php +++ b/src/item/Trident.php @@ -33,6 +33,7 @@ use pocketmine\world\sound\TridentThrowSound; use function min; class Trident extends Tool implements Releasable{ + private const DAMAGE_ON_THROW = 1; public function getMaxDurability() : int{ return 251; @@ -48,7 +49,12 @@ class Trident extends Tool implements Releasable{ $item = $this->pop(); if($player->hasFiniteResources()){ - $item->applyDamage(1); + $item->applyDamage(self::DAMAGE_ON_THROW); + } + if($item->isNull()){ + //canStartUsingItem() will normally prevent this, but it's possible the item might've been modified between + //the start action and the release, so it's best to account for this anyway + return ItemUseResult::FAIL; } $entity = new TridentEntity(Location::fromObject( $player->getEyePos(), @@ -77,7 +83,7 @@ class Trident extends Tool implements Releasable{ } public function canStartUsingItem(Player $player) : bool{ - return $this->damage < $this->getMaxDurability(); + return $this->damage < $this->getMaxDurability() - self::DAMAGE_ON_THROW; } public function onAttackEntity(Entity $victim, array &$returnedItems) : bool{