Entity collisions, bounding boxes for entites and blocks

This commit is contained in:
GameHerobrine 2022-10-18 21:40:03 +03:00
parent 9154c0fc3d
commit 1448fd21b9
19 changed files with 265 additions and 118 deletions

View file

@ -180,7 +180,7 @@ class AxisAlignedBB{
return $z;
}
public function intersectsWith(AxisAlignedBB $bb){
if($bb->maxX > $this->minX and $bb->minX < $this->maxX){
if($bb->maxY > $this->minY and $bb->minY < $this->maxY){
@ -190,7 +190,17 @@ class AxisAlignedBB{
return false;
}
public function isXYZInside($x, $y, $z){
if($x <= $this->minX or $x >= $this->maxX){
return false;
}
if($y <= $this->minY or $y >= $this->maxY){
return false;
}
return $z > $this->minZ and $z < $this->maxZ;
}
public function isVectorInside(Vector3 $vector){
if($vector->x <= $this->minX or $vector->x >= $this->maxX){
return false;
@ -294,4 +304,9 @@ class AxisAlignedBB{
return MovingObjectPosition::fromBlock(0, 0, 0, $f, $vector);
}
public function __toString(){
return "min: {$this->minX}, {$this->minY}, {$this->minZ}, max: {$this->maxX}, {$this->maxY}, {$this->maxZ}";
}
}