Fixed projectiles collding with spectator players

closes #1857
This commit is contained in:
Dylan K. Taylor 2018-01-17 10:57:04 +00:00
parent 9c65a2b890
commit 6f6e3aaa21
3 changed files with 9 additions and 1 deletions

View File

@ -515,6 +515,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return false;
}
public function canBeCollidedWith() : bool{
return !$this->isSpectator();
}
public function resetFallDistance(){
parent::resetFallDistance();
if($this->inAirTicks !== 0){

View File

@ -1067,6 +1067,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
return !$this->justCreated and $entity !== $this;
}
public function canBeCollidedWith() : bool{
return true;
}
protected function updateMovement(){
$diffPosition = ($this->x - $this->lastX) ** 2 + ($this->y - $this->lastY) ** 2 + ($this->z - $this->lastZ) ** 2;
$diffRotation = ($this->yaw - $this->lastYaw) ** 2 + ($this->pitch - $this->lastPitch) ** 2;

View File

@ -1964,7 +1964,7 @@ class Level implements ChunkManager, Metadatable{
for($z = $minZ; $z <= $maxZ; ++$z){
foreach($this->getChunkEntities($x, $z) as $ent){
/** @var Entity|null $entity */
if(($entity === null or ($ent !== $entity and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
if($ent->canBeCollidedWith() and ($entity === null or ($ent !== $entity and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
$nearby[] = $ent;
}
}