mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Entity collisions, bounding boxes for entites and blocks
This commit is contained in:
parent
9154c0fc3d
commit
1448fd21b9
19 changed files with 265 additions and 118 deletions
|
|
@ -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}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -170,7 +170,11 @@ class Vector3{
|
|||
$this->x * $v->y - $this->y * $v->x
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static function fromArray($arr){
|
||||
return new Vector3($arr[0], $arr[1], $arr[2]);
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
return "Vector3(x=" . $this->x . ",y=" . $this->y . ",z=" . $this->z . ")";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue