111 if($tickDiff <= 0 and !$this->justCreated){
114 $this->lastUpdate = $currentTick;
120 $movingObjectPosition = null;
122 if(!$this->isCollided){
126 $moveVector =
new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ);
128 $list = $this->
getLevel()->getCollidingEntities($this->boundingBox->addCoord($this->motionX, $this->motionY, $this->motionZ)->expand(1, 1, 1), $this);
130 $nearDistance = PHP_INT_MAX;
133 foreach($list as $entity){
135 ($entity === $this->shootingEntity and $this->ticksLived < 5)
140 $axisalignedbb = $entity->boundingBox->grow(0.3, 0.3, 0.3);
141 $ob = $axisalignedbb->calculateIntercept($this, $moveVector);
149 if($distance < $nearDistance){
150 $nearDistance = $distance;
151 $nearEntity = $entity;
155 if($nearEntity !== null){
159 if($movingObjectPosition !== null){
160 if($movingObjectPosition->entityHit !== null){
162 $this->server->getPluginManager()->callEvent(
new ProjectileHitEvent($this));
164 $motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2);
167 if($this instanceof Arrow and $this->isCritical()){
171 if($this->shootingEntity === null){
177 if($movingObjectPosition->entityHit->attack($ev->getFinalDamage(), $ev) ===
true){
178 if($this instanceof Arrow and $this->getPotionId() != 0){
180 $movingObjectPosition->entityHit->addEffect($effect->setDuration($effect->getDuration() / 8));
186 $this->hadCollision =
true;
188 if($this->fireTicks > 0){
189 $ev =
new EntityCombustByEntityEvent($this, $movingObjectPosition->entityHit, 5);
190 $this->server->getPluginManager()->callEvent($ev);
191 if(!$ev->isCancelled()){
192 $movingObjectPosition->entityHit->setOnFire($ev->getDuration());
201 $this->
move($this->motionX, $this->motionY, $this->motionZ);
203 if($this->isCollided and !$this->hadCollision){
204 $this->hadCollision =
true;
210 $this->server->getPluginManager()->callEvent(
new ProjectileHitEvent($this));
211 }elseif(!$this->isCollided and $this->hadCollision){
212 $this->hadCollision =
false;
215 if(!$this->onGround or
abs($this->motionX) > 0.00001 or
abs($this->motionY) > 0.00001 or
abs($this->motionZ) > 0.00001){
216 $f = sqrt(($this->motionX ** 2) + ($this->motionZ ** 2));
217 $this->yaw = (atan2($this->motionX, $this->motionZ) * 180 / M_PI);
218 $this->pitch = (atan2($this->motionY, $f) * 180 / M_PI);