mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
code style fix
This commit is contained in:
parent
fc5c5625cb
commit
5e8e9330e2
361 changed files with 4766 additions and 4650 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
class AxisAlignedBB{
|
||||
public $minX;
|
||||
public $minY;
|
||||
|
|
@ -6,7 +7,7 @@ class AxisAlignedBB{
|
|||
public $maxX;
|
||||
public $maxY;
|
||||
public $maxZ;
|
||||
|
||||
|
||||
public function __construct($minX, $minY, $minZ, $maxX, $maxY, $maxZ){
|
||||
$this->minX = $minX;
|
||||
$this->minY = $minY;
|
||||
|
|
@ -30,7 +31,7 @@ class AxisAlignedBB{
|
|||
public function addMinMax($minX, $minY, $minZ, $maxX, $maxY, $maxZ){
|
||||
return new AxisAlignedBB($this->minX + $minX, $this->minY + $minY, $this->minZ + $minZ, $this->maxX + $maxX, $this->maxY + $maxY, $this->maxZ + $maxZ);
|
||||
}
|
||||
|
||||
|
||||
public function addCoord($x, $y, $z){
|
||||
$minX = $this->minX;
|
||||
$minY = $this->minY;
|
||||
|
|
@ -169,7 +170,7 @@ class AxisAlignedBB{
|
|||
|
||||
return $z;
|
||||
}
|
||||
|
||||
|
||||
public function intersectsWith(AxisAlignedBB $bb){
|
||||
return $bb->maxX >= $this->minX && $bb->minX <= $this->maxX && $bb->maxZ >= $this->minZ && $bb->minZ <= $this->maxZ && $bb->maxY >= $this->minY && $bb->minY <= $this->maxY;
|
||||
}
|
||||
|
|
@ -180,7 +181,7 @@ class AxisAlignedBB{
|
|||
if($y < $this->minY or $y > $this->maxY){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return $z > $this->minZ and $z < $this->maxZ;
|
||||
}
|
||||
public function isXYZInside($x, $y, $z){
|
||||
|
|
@ -190,7 +191,7 @@ class AxisAlignedBB{
|
|||
if($y < $this->minY or $y > $this->maxY){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return $z > $this->minZ and $z < $this->maxZ;
|
||||
}
|
||||
public function isVectorInside(Vector3 $vector){
|
||||
|
|
@ -219,10 +220,8 @@ class AxisAlignedBB{
|
|||
public function isVectorInXY(Vector3 $vector){
|
||||
return $vector->x >= $this->minX and $vector->x <= $this->maxX and $vector->y >= $this->minY and $vector->y <= $this->maxY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos1
|
||||
* @param Vector3 $pos2
|
||||
* @return NULL|MovingObjectPosition
|
||||
*/
|
||||
public function calculateIntercept(Vector3 $pos1, Vector3 $pos2){
|
||||
|
|
@ -301,9 +300,9 @@ class AxisAlignedBB{
|
|||
|
||||
return MovingObjectPosition::fromBlock(0, 0, 0, $f, $vector);
|
||||
}
|
||||
|
||||
|
||||
public function __toString(){
|
||||
return "AABB min: {$this->minX}, {$this->minY}, {$this->minZ}, max: {$this->maxX}, {$this->maxY}, {$this->maxZ}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -148,7 +148,6 @@ class Matrix implements ArrayAccess{
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
//Computation of the determinant of 2x2 and 3x3 matrices
|
||||
|
||||
public function isSquare(){
|
||||
|
|
|
|||
|
|
@ -2,27 +2,27 @@
|
|||
|
||||
class Vector3{
|
||||
public $x, $y, $z;
|
||||
|
||||
|
||||
public function __construct($x = 0, $y = 0, $z = 0){
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
|
||||
|
||||
public function setXYZ($x, $y, $z){
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
|
||||
|
||||
public function copy(){
|
||||
return new Vector3($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
|
||||
public function toArray(){
|
||||
return ["x" => $this->x, "y" => $this->y, "z" => $this->z];
|
||||
}
|
||||
|
||||
|
||||
public function getFloorX(){
|
||||
return (int) $this->x;
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ class Vector3{
|
|||
}
|
||||
|
||||
public function getSide($side, $step = 1){
|
||||
return match ((int)$side) {
|
||||
return match ((int) $side) {
|
||||
0 => new Vector3($this->x, $this->y - $step, $this->z),
|
||||
1 => new Vector3($this->x, $this->y + $step, $this->z),
|
||||
2 => new Vector3($this->x, $this->y, $this->z - $step),
|
||||
|
|
@ -127,7 +127,7 @@ class Vector3{
|
|||
if($x instanceof Vector3){
|
||||
return $this->distanceSquared($x->x, $x->y, $x->z);
|
||||
}else{
|
||||
return ($this->x - $x)*($this->x - $x) + ($this->y - $y)*($this->y - $y) + ($this->z - $z)*($this->z - $z);
|
||||
return ($this->x - $x) * ($this->x - $x) + ($this->y - $y) * ($this->y - $y) + ($this->z - $z) * ($this->z - $z);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,21 +170,19 @@ 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 . ")";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new vector with x value equal to the second parameter, along the line between this vector and the
|
||||
* passed in vector, or null if not possible.
|
||||
*
|
||||
* @param Vector3 $v
|
||||
* @param float $x
|
||||
*
|
||||
* @return Vector3
|
||||
|
|
@ -193,13 +191,13 @@ class Vector3{
|
|||
$xDiff = $v->x - $this->x;
|
||||
$yDiff = $v->y - $this->y;
|
||||
$zDiff = $v->z - $this->z;
|
||||
|
||||
|
||||
if(($xDiff * $xDiff) < 0.0000001){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$f = ($x - $this->x) / $xDiff;
|
||||
|
||||
|
||||
if($f < 0 or $f > 1){
|
||||
return null;
|
||||
}else{
|
||||
|
|
@ -209,12 +207,11 @@ class Vector3{
|
|||
public function getIntermediateWithXValue(Vector3 $v, $y){
|
||||
return $this->clipX($v, $y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new vector with y value equal to the second parameter, along the line between this vector and the
|
||||
* passed in vector, or null if not possible.
|
||||
*
|
||||
* @param Vector3 $v
|
||||
* @param float $y
|
||||
*
|
||||
* @return Vector3
|
||||
|
|
@ -223,20 +220,20 @@ class Vector3{
|
|||
$xDiff = $v->x - $this->x;
|
||||
$yDiff = $v->y - $this->y;
|
||||
$zDiff = $v->z - $this->z;
|
||||
|
||||
|
||||
if(($yDiff * $yDiff) < 0.0000001){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$f = ($y - $this->y) / $yDiff;
|
||||
|
||||
|
||||
if($f < 0 or $f > 1){
|
||||
return null;
|
||||
}else{
|
||||
return new Vector3($this->x + $xDiff * $f, $this->y + $yDiff * $f, $this->z + $zDiff * $f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getIntermediateWithYValue(Vector3 $v, $y){
|
||||
return $this->clipY($v, $y);
|
||||
}
|
||||
|
|
@ -244,7 +241,6 @@ class Vector3{
|
|||
* Returns a new vector with z value equal to the second parameter, along the line between this vector and the
|
||||
* passed in vector, or null if not possible.
|
||||
*
|
||||
* @param Vector3 $v
|
||||
* @param float $z
|
||||
*
|
||||
* @return Vector3
|
||||
|
|
@ -253,20 +249,20 @@ class Vector3{
|
|||
$xDiff = $v->x - $this->x;
|
||||
$yDiff = $v->y - $this->y;
|
||||
$zDiff = $v->z - $this->z;
|
||||
|
||||
|
||||
if(($zDiff * $zDiff) < 0.0000001){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$f = ($z - $this->z) / $zDiff;
|
||||
|
||||
|
||||
if($f < 0 or $f > 1){
|
||||
return null;
|
||||
}else{
|
||||
return new Vector3($this->x + $xDiff * $f, $this->y + $yDiff * $f, $this->z + $zDiff * $f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getIntermediateWithZValue(Vector3 $v, $y){
|
||||
return $this->clipZ($v, $y);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue