Merge 'stable' into 'minor-next'

Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/18326199588
This commit is contained in:
pmmp-admin-bot[bot]
2025-10-07 21:06:02 +00:00

View File

@@ -33,6 +33,7 @@ use pocketmine\world\sound\TridentThrowSound;
use function min; use function min;
class Trident extends Tool implements Releasable{ class Trident extends Tool implements Releasable{
private const DAMAGE_ON_THROW = 1;
public function getMaxDurability() : int{ public function getMaxDurability() : int{
return 251; return 251;
@@ -48,7 +49,12 @@ class Trident extends Tool implements Releasable{
$item = $this->pop(); $item = $this->pop();
if($player->hasFiniteResources()){ 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( $entity = new TridentEntity(Location::fromObject(
$player->getEyePos(), $player->getEyePos(),
@@ -77,7 +83,7 @@ class Trident extends Tool implements Releasable{
} }
public function canStartUsingItem(Player $player) : bool{ 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{ public function onAttackEntity(Entity $victim, array &$returnedItems) : bool{