Entity: avoid double-checking block intersections for moving entities

fixes #1824
This commit is contained in:
Dylan K. Taylor 2023-04-16 17:38:26 +01:00
parent b5dc72b0ee
commit 56fbd45dd5
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -115,6 +115,8 @@ abstract class Entity{
/** @var Block[]|null */
protected $blocksAround;
private bool $checkBlockIntersectionsNextTick = true;
/** @var Location */
protected $location;
/** @var Location */
@ -649,7 +651,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);
@ -1308,6 +1313,7 @@ abstract class Entity{
}
protected function checkBlockIntersections() : void{
$this->checkBlockIntersectionsNextTick = false;
$vectors = [];
foreach($this->getBlocksAroundWithEntityInsideActions() as $block){