Implement Trident (#4547)

Co-authored-by: Dylan T. <dktapps@pmmp.io>
This commit is contained in:
IvanCraft623
2025-09-18 12:00:55 -06:00
committed by GitHub
parent fbf09d990e
commit 6d2d23a210
12 changed files with 429 additions and 5 deletions

View File

@@ -227,12 +227,15 @@ abstract class Projectile extends Entity{
$specificHitFunc = fn() => $this->onHitBlock($objectHit, $rayTraceResult);
}
$motionBeforeOnHit = clone $this->motion;
$ev->call();
$this->onHit($ev);
$specificHitFunc();
$this->isCollided = $this->onGround = true;
$this->motion = Vector3::zero();
if($motionBeforeOnHit->equals($this->motion)){
$this->motion = Vector3::zero();
}
}else{
$this->isCollided = $this->onGround = false;
$this->blockHit = null;
@@ -295,7 +298,9 @@ abstract class Projectile extends Entity{
}
}
$this->flagForDespawn();
if($this->despawnsOnEntityHit()){
$this->flagForDespawn();
}
}
/**
@@ -305,4 +310,11 @@ abstract class Projectile extends Entity{
$this->blockHit = $blockHit->getPosition()->asVector3();
$blockHit->onProjectileHit($this, $hitResult);
}
/**
* @deprecated This will be dropped in favor of deciding whether to despawn within `onHitEntity()` method.
*/
protected function despawnsOnEntityHit() : bool{
return true;
}
}