Skip to content

Commit

Permalink
EnderPearls now teleport to the correct world
Browse files Browse the repository at this point in the history
  • Loading branch information
dadodasyra committed Sep 10, 2024
1 parent f6e2a1e commit cc34ada
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/entity/projectile/EnderPearl.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
use pocketmine\world\particle\EndermanTeleportParticle;
use pocketmine\world\sound\EndermanTeleportSound;
use pocketmine\world\Position;

class EnderPearl extends Throwable{
public static function getNetworkTypeId() : string{ return EntityIds::ENDER_PEARL; }
Expand All @@ -38,9 +39,10 @@ protected function onHit(ProjectileHitEvent $event) : void{
//TODO: check end gateways (when they are added)
//TODO: spawn endermites at origin

$target = $event->getRayTraceResult()->getHitVector();
$this->getWorld()->addParticle($origin = $owner->getPosition(), new EndermanTeleportParticle());
$this->getWorld()->addSound($origin, new EndermanTeleportSound());
$owner->teleport($target = $event->getRayTraceResult()->getHitVector());
$owner->teleport(Position::fromObject($target, $this->getWorld()));
$this->getWorld()->addSound($target, new EndermanTeleportSound());

$owner->attack(new EntityDamageEvent($owner, EntityDamageEvent::CAUSE_FALL, 5));
Expand Down

0 comments on commit cc34ada

Please sign in to comment.