Merge remote-tracking branch 'origin/minor-next' into major-next

This commit is contained in:
Dylan K. Taylor
2023-04-20 00:18:19 +01:00
6 changed files with 51 additions and 30 deletions

View File

@ -118,6 +118,7 @@ abstract class Entity{
protected Vector3 $motion;
protected Vector3 $lastMotion;
protected bool $forceMovementUpdate = false;
private bool $checkBlockIntersectionsNextTick = true;
public AxisAlignedBB $boundingBox;
public bool $onGround = false;
@ -620,7 +621,10 @@ abstract class Entity{
$hasUpdate = false;
$this->checkBlockIntersections();
if($this->checkBlockIntersectionsNextTick){
$this->checkBlockIntersections();
}
$this->checkBlockIntersectionsNextTick = true;
if($this->location->y <= World::Y_MIN - 16 && $this->isAlive()){
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_VOID, 10);
@ -1279,6 +1283,7 @@ abstract class Entity{
}
protected function checkBlockIntersections() : void{
$this->checkBlockIntersectionsNextTick = false;
$vectors = [];
foreach($this->getBlocksAroundWithEntityInsideActions() as $block){
@ -1290,10 +1295,12 @@ abstract class Entity{
}
}
$vector = Vector3::sum(...$vectors);
if($vector->lengthSquared() > 0){
$d = 0.014;
$this->motion = $this->motion->addVector($vector->normalize()->multiply($d));
if(count($vectors) > 0){
$vector = Vector3::sum(...$vectors);
if($vector->lengthSquared() > 0){
$d = 0.014;
$this->motion = $this->motion->addVector($vector->normalize()->multiply($d));
}
}
}