mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
Update Math dependency, obliterate some nasty code from Block
This commit is contained in:
parent
4c848bb4c1
commit
101de7adda
8
composer.lock
generated
8
composer.lock
generated
@ -187,12 +187,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pmmp/Math.git",
|
"url": "https://github.com/pmmp/Math.git",
|
||||||
"reference": "115700a493fc38fe8886739c20c4303eeb1cd182"
|
"reference": "93a430a089da009b44b710cca0c4fd4c2f06e702"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/115700a493fc38fe8886739c20c4303eeb1cd182",
|
"url": "https://api.github.com/repos/pmmp/Math/zipball/93a430a089da009b44b710cca0c4fd4c2f06e702",
|
||||||
"reference": "115700a493fc38fe8886739c20c4303eeb1cd182",
|
"reference": "93a430a089da009b44b710cca0c4fd4c2f06e702",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -218,7 +218,7 @@
|
|||||||
"source": "https://github.com/pmmp/Math/tree/master",
|
"source": "https://github.com/pmmp/Math/tree/master",
|
||||||
"issues": "https://github.com/pmmp/Math/issues"
|
"issues": "https://github.com/pmmp/Math/issues"
|
||||||
},
|
},
|
||||||
"time": "2018-09-23T17:50:23+00:00"
|
"time": "2018-11-23T19:38:18+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/nbt",
|
"name": "pocketmine/nbt",
|
||||||
|
@ -76,11 +76,8 @@ class Anvil extends Fallable{
|
|||||||
public function recalculateBoundingBox() : ?AxisAlignedBB{
|
public function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
$inset = 0.125;
|
$inset = 0.125;
|
||||||
|
|
||||||
if(Facing::axis($this->facing) === Facing::AXIS_X){
|
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||||
return new AxisAlignedBB(0, 0, $inset, 1, 1, 1 - $inset);
|
return $bb->squash(Facing::axis(Facing::rotate($this->facing, Facing::AXIS_Y, false)), $inset);
|
||||||
}else{
|
|
||||||
return new AxisAlignedBB($inset, 0, 0, 1 - $inset, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null) : bool{
|
public function onActivate(Item $item, Player $player = null) : bool{
|
||||||
|
@ -74,36 +74,12 @@ class CocoaBlock extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
static $logDistance = 1 / 16;
|
$bb = new AxisAlignedBB(0, (7 - $this->age * 2) / 16, 0, 1, 0.75, 1);
|
||||||
|
|
||||||
$widthInset = (6 - $this->age) / 16;
|
return $bb
|
||||||
$faceDistance = (5 + $this->age * 2) / 16;
|
->squash(Facing::axis(Facing::rotate($this->facing, Facing::AXIS_Y, true)), (6 - $this->age) / 16) //sides
|
||||||
|
->trim(Facing::opposite($this->facing), 1 / 16) //gap between log and pod
|
||||||
$minY = (7 - $this->age * 2) / 16;
|
->trim($this->facing, (11 - $this->age * 2) / 16); //outward face
|
||||||
|
|
||||||
if(Facing::isPositive($this->facing)){
|
|
||||||
$minFacing = $logDistance;
|
|
||||||
$maxFacing = $faceDistance;
|
|
||||||
}else{
|
|
||||||
$minFacing = 1 - $faceDistance;
|
|
||||||
$maxFacing = 1 - $logDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Facing::axis($this->facing) === Facing::AXIS_Z){
|
|
||||||
$minX = $widthInset;
|
|
||||||
$maxX = 1 - $widthInset;
|
|
||||||
|
|
||||||
$minZ = $minFacing;
|
|
||||||
$maxZ = $maxFacing;
|
|
||||||
}else{
|
|
||||||
$minX = $minFacing;
|
|
||||||
$maxX = $maxFacing;
|
|
||||||
|
|
||||||
$minZ = $widthInset;
|
|
||||||
$maxZ = 1 - $widthInset;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new AxisAlignedBB($minX, $minY, $minZ, $maxX, 0.75, $maxZ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
|
@ -91,54 +91,10 @@ abstract class Door extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
$f = 0.1875;
|
|
||||||
$this->updateStateFromOtherHalf();
|
$this->updateStateFromOtherHalf();
|
||||||
|
|
||||||
$bb = new AxisAlignedBB(0, 0, 0, 1, 2, 1);
|
$bb = new AxisAlignedBB(0, 0, 0, 1, 2, 1);
|
||||||
|
return $bb->trim($this->open ? Facing::rotate($this->facing, Facing::AXIS_Y, !$this->hingeRight) : $this->facing, 13 / 16);
|
||||||
if($this->facing === Facing::EAST){
|
|
||||||
if($this->open){
|
|
||||||
if(!$this->hingeRight){
|
|
||||||
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
|
||||||
}
|
|
||||||
}elseif($this->facing === Facing::SOUTH){
|
|
||||||
if($this->open){
|
|
||||||
if(!$this->hingeRight){
|
|
||||||
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
|
||||||
}
|
|
||||||
}elseif($this->facing === Facing::WEST){
|
|
||||||
if($this->open){
|
|
||||||
if(!$this->hingeRight){
|
|
||||||
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
|
||||||
}
|
|
||||||
}elseif($this->facing === Facing::NORTH){
|
|
||||||
if($this->open){
|
|
||||||
if(!$this->hingeRight){
|
|
||||||
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -81,40 +81,15 @@ class EndRod extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
$m = Facing::axis($this->facing);
|
$myAxis = Facing::axis($this->facing);
|
||||||
$width = 0.375;
|
|
||||||
|
|
||||||
switch($m){
|
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||||
case Facing::AXIS_Y:
|
foreach([Facing::AXIS_Y, Facing::AXIS_Z, Facing::AXIS_X] as $axis){
|
||||||
return new AxisAlignedBB(
|
if($axis === $myAxis){
|
||||||
$width,
|
continue;
|
||||||
0,
|
|
||||||
$width,
|
|
||||||
1 - $width,
|
|
||||||
1,
|
|
||||||
1 - $width
|
|
||||||
);
|
|
||||||
case Facing::AXIS_Z:
|
|
||||||
return new AxisAlignedBB(
|
|
||||||
$width,
|
|
||||||
$width,
|
|
||||||
0,
|
|
||||||
1 - $width,
|
|
||||||
1 - $width,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
case Facing::AXIS_X:
|
|
||||||
return new AxisAlignedBB(
|
|
||||||
0,
|
|
||||||
$width,
|
|
||||||
$width,
|
|
||||||
1,
|
|
||||||
1 - $width,
|
|
||||||
1 - $width
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
$bb->squash($axis, 6 / 16);
|
||||||
return null;
|
}
|
||||||
|
return $bb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,25 +64,8 @@ class FenceGate extends Transparent{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Facing::axis($this->facing) === Facing::AXIS_Z){
|
$bb = new AxisAlignedBB(0, 0, 0, 1, 1.5, 1);
|
||||||
return new AxisAlignedBB(
|
return $bb->squash(Facing::axis($this->facing), 6 / 16);
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0.375,
|
|
||||||
1,
|
|
||||||
1.5,
|
|
||||||
0.625
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
return new AxisAlignedBB(
|
|
||||||
0.375,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0.625,
|
|
||||||
1.5,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
|
@ -79,29 +79,8 @@ class Ladder extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
$f = 0.1875;
|
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||||
|
return $bb->trim($this->facing, 13 / 16);
|
||||||
$minX = $minZ = 0;
|
|
||||||
$maxX = $maxZ = 1;
|
|
||||||
|
|
||||||
if($this->facing === Facing::NORTH){
|
|
||||||
$minZ = 1 - $f;
|
|
||||||
}elseif($this->facing === Facing::SOUTH){
|
|
||||||
$maxZ = $f;
|
|
||||||
}elseif($this->facing === Facing::WEST){
|
|
||||||
$minX = 1 - $f;
|
|
||||||
}elseif($this->facing === Facing::EAST){
|
|
||||||
$maxX = $f;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
|
||||||
$minX,
|
|
||||||
0,
|
|
||||||
$minZ,
|
|
||||||
$maxX,
|
|
||||||
1,
|
|
||||||
$maxZ
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,17 +59,17 @@ abstract class Stair extends Transparent{
|
|||||||
$minY = $this->upsideDown ? 0 : 0.5;
|
$minY = $this->upsideDown ? 0 : 0.5;
|
||||||
|
|
||||||
$topStep = new AxisAlignedBB(0, $minY, 0, 1, $minY + 0.5, 1);
|
$topStep = new AxisAlignedBB(0, $minY, 0, 1, $minY + 0.5, 1);
|
||||||
self::setBoundsForFacing($topStep, $this->facing);
|
$topStep->trim(Facing::opposite($this->facing), 0.5);
|
||||||
|
|
||||||
/** @var Stair $corner */
|
/** @var Stair $corner */
|
||||||
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
|
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
|
||||||
self::setBoundsForFacing($topStep, $backFacing);
|
$topStep->trim(Facing::opposite($backFacing), 0.5);
|
||||||
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
|
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
|
||||||
//add an extra cube
|
//add an extra cube
|
||||||
$extraCube = new AxisAlignedBB(0, $minY, 0, 1, $minY + 0.5, 1);
|
$extraCube = new AxisAlignedBB(0, $minY, 0, 1, $minY + 0.5, 1);
|
||||||
self::setBoundsForFacing($extraCube, Facing::opposite($this->facing));
|
$bbs[] = $extraCube
|
||||||
self::setBoundsForFacing($extraCube, $frontFacing);
|
->trim($this->facing, 0.5)
|
||||||
$bbs[] = $extraCube;
|
->trim(Facing::opposite($frontFacing), 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
$bbs[] = $topStep;
|
$bbs[] = $topStep;
|
||||||
@ -88,25 +88,6 @@ abstract class Stair extends Transparent{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function setBoundsForFacing(AxisAlignedBB $bb, int $facing) : void{
|
|
||||||
switch($facing){
|
|
||||||
case Facing::EAST:
|
|
||||||
$bb->minX = 0.5;
|
|
||||||
break;
|
|
||||||
case Facing::WEST:
|
|
||||||
$bb->maxX = 0.5;
|
|
||||||
break;
|
|
||||||
case Facing::SOUTH:
|
|
||||||
$bb->minZ = 0.5;
|
|
||||||
break;
|
|
||||||
case Facing::NORTH:
|
|
||||||
$bb->maxZ = 0.5;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new \InvalidArgumentException("Facing must be horizontal");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
$this->facing = Bearing::toFacing($player->getDirection());
|
$this->facing = Bearing::toFacing($player->getDirection());
|
||||||
|
@ -73,27 +73,8 @@ class Trapdoor extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
$f = 0.1875;
|
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||||
|
return $bb->trim($this->open ? $this->facing : ($this->top ? Facing::DOWN : Facing::UP), 13 / 16);
|
||||||
if($this->top){
|
|
||||||
$bb = new AxisAlignedBB(0, 1 - $f, 0, 1, 1, 1);
|
|
||||||
}else{
|
|
||||||
$bb = new AxisAlignedBB(0, 0, 0, 1, $f, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->open){
|
|
||||||
if($this->facing === Facing::NORTH){
|
|
||||||
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
|
||||||
}elseif($this->facing === Facing::SOUTH){
|
|
||||||
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
|
||||||
}elseif($this->facing === Facing::WEST){
|
|
||||||
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
|
||||||
}elseif($this->facing === Facing::EAST){
|
|
||||||
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user