mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
Entity: added getEyePos()
This commit is contained in:
parent
e03f918806
commit
1cd955c216
@ -1171,6 +1171,10 @@ abstract class Entity extends Location{
|
|||||||
return $this->eyeHeight;
|
return $this->eyeHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEyePos() : Vector3{
|
||||||
|
return new Vector3($this->x, $this->y + $this->getEyeHeight(), $this->z);
|
||||||
|
}
|
||||||
|
|
||||||
public function onCollideWithPlayer(Player $player) : void{
|
public function onCollideWithPlayer(Player $player) : void{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ class SplashPotion extends Throwable{
|
|||||||
if(!$this->willLinger()){
|
if(!$this->willLinger()){
|
||||||
foreach($this->world->getNearbyEntities($this->boundingBox->expandedCopy(4.125, 2.125, 4.125), $this) as $entity){
|
foreach($this->world->getNearbyEntities($this->boundingBox->expandedCopy(4.125, 2.125, 4.125), $this) as $entity){
|
||||||
if($entity instanceof Living and $entity->isAlive()){
|
if($entity instanceof Living and $entity->isAlive()){
|
||||||
$distanceSquared = $entity->add(0, $entity->getEyeHeight(), 0)->distanceSquared($this);
|
$distanceSquared = $entity->getEyePos()->distanceSquared($this);
|
||||||
if($distanceSquared > 16){ //4 blocks
|
if($distanceSquared > 16){ //4 blocks
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class Bow extends Tool{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$nbt = EntityFactory::createBaseNBT(
|
$nbt = EntityFactory::createBaseNBT(
|
||||||
$player->add(0, $player->getEyeHeight(), 0),
|
$player->getEyePos(),
|
||||||
$player->getDirectionVector(),
|
$player->getDirectionVector(),
|
||||||
($player->yaw > 180 ? 360 : 0) - $player->yaw,
|
($player->yaw > 180 ? 360 : 0) - $player->yaw,
|
||||||
-$player->pitch
|
-$player->pitch
|
||||||
|
@ -53,7 +53,7 @@ abstract class ProjectileItem extends Item{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseResult{
|
public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseResult{
|
||||||
$nbt = EntityFactory::createBaseNBT($player->add(0, $player->getEyeHeight(), 0), $directionVector, $player->yaw, $player->pitch);
|
$nbt = EntityFactory::createBaseNBT($player->getEyePos(), $directionVector, $player->yaw, $player->pitch);
|
||||||
$this->addExtraTags($nbt);
|
$this->addExtraTags($nbt);
|
||||||
|
|
||||||
$class = $this->getProjectileEntityClass();
|
$class = $this->getProjectileEntityClass();
|
||||||
|
@ -1463,7 +1463,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canInteract(Vector3 $pos, float $maxDistance, float $maxDiff = M_SQRT3 / 2) : bool{
|
public function canInteract(Vector3 $pos, float $maxDistance, float $maxDiff = M_SQRT3 / 2) : bool{
|
||||||
$eyePos = $this->getPosition()->add(0, $this->getEyeHeight(), 0);
|
$eyePos = $this->getEyePos();
|
||||||
if($eyePos->distanceSquared($pos) > $maxDistance ** 2){
|
if($eyePos->distanceSquared($pos) > $maxDistance ** 2){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user