mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
Block: Make recalculation of BB non-dependent on block position
This now computes BBs relative to 0,0,0 and then offsets them as appropriate. This requires less boilerplate code and also furthers the goal of separating block types from instances.
This commit is contained in:
parent
56b04fa0bb
commit
99a0c2a188
@ -76,23 +76,9 @@ class Anvil extends Fallable{
|
|||||||
$inset = 0.125;
|
$inset = 0.125;
|
||||||
|
|
||||||
if($this->meta & 0x01){ //east/west
|
if($this->meta & 0x01){ //east/west
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0, 0, $inset, 1, 1, 1 - $inset);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z + $inset,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1 - $inset
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB($inset, 0, 0, 1 - $inset, 1, 1);
|
||||||
$this->x + $inset,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1 - $inset,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,7 @@ class Bed extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0, 0, 0, 1, 0.5625, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 0.5625,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHeadPart() : bool{
|
public function isHeadPart() : bool{
|
||||||
|
@ -657,6 +657,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
public function getCollisionBoxes() : array{
|
public function getCollisionBoxes() : array{
|
||||||
if($this->collisionBoxes === null){
|
if($this->collisionBoxes === null){
|
||||||
$this->collisionBoxes = $this->recalculateCollisionBoxes();
|
$this->collisionBoxes = $this->recalculateCollisionBoxes();
|
||||||
|
foreach($this->collisionBoxes as $bb){
|
||||||
|
$bb->offset($this->x, $this->y, $this->z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->collisionBoxes;
|
return $this->collisionBoxes;
|
||||||
@ -679,6 +682,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
public function getBoundingBox() : ?AxisAlignedBB{
|
public function getBoundingBox() : ?AxisAlignedBB{
|
||||||
if($this->boundingBox === null){
|
if($this->boundingBox === null){
|
||||||
$this->boundingBox = $this->recalculateBoundingBox();
|
$this->boundingBox = $this->recalculateBoundingBox();
|
||||||
|
if($this->boundingBox !== null){
|
||||||
|
$this->boundingBox->offset($this->x, $this->y, $this->z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $this->boundingBox;
|
return $this->boundingBox;
|
||||||
}
|
}
|
||||||
@ -687,14 +693,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
* @return AxisAlignedBB|null
|
* @return AxisAlignedBB|null
|
||||||
*/
|
*/
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,15 +54,8 @@ class Cactus extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
static $shrinkSize = 0.0625;
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB($shrinkSize, $shrinkSize, $shrinkSize, 1 - $shrinkSize, 1 - $shrinkSize, 1 - $shrinkSize);
|
||||||
$this->x + 0.0625,
|
|
||||||
$this->y + 0.0625,
|
|
||||||
$this->z + 0.0625,
|
|
||||||
$this->x + 0.9375,
|
|
||||||
$this->y + 0.9375,
|
|
||||||
$this->z + 0.9375
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityCollide(Entity $entity) : void{
|
public function onEntityCollide(Entity $entity) : void{
|
||||||
|
@ -48,16 +48,15 @@ class Cake extends Transparent implements FoodSource{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
|
||||||
$f = $this->getDamage() * 0.125; //1 slice width
|
$f = $this->getDamage() * 0.125; //1 slice width
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + 0.0625 + $f,
|
0.0625 + $f,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + 0.0625,
|
0.0625,
|
||||||
$this->x + 1 - 0.0625,
|
1 - 0.0625,
|
||||||
$this->y + 0.5,
|
0.5,
|
||||||
$this->z + 1 - 0.0625
|
1 - 0.0625
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +50,7 @@ class Carpet extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
return new AxisAlignedBB(0, 0, 0, 1, 0.0625, 1);
|
||||||
return new AxisAlignedBB(
|
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 0.0625,
|
|
||||||
$this->z + 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{
|
||||||
|
@ -52,14 +52,7 @@ class Chest extends Transparent{
|
|||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
//these are slightly bigger than in PC
|
//these are slightly bigger than in PC
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0.025, 0, 0.025, 0.975, 0.95, 0.975);
|
||||||
$this->x + 0.025,
|
|
||||||
$this->y,
|
|
||||||
$this->z + 0.025,
|
|
||||||
$this->x + 0.975,
|
|
||||||
$this->y + 0.95,
|
|
||||||
$this->z + 0.975
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
||||||
|
@ -78,12 +78,12 @@ class CobblestoneWall extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + ($west ? 0 : $inset),
|
($west ? 0 : $inset),
|
||||||
$this->y,
|
0,
|
||||||
$this->z + ($north ? 0 : $inset),
|
($north ? 0 : $inset),
|
||||||
$this->x + 1 - ($east ? 0 : $inset),
|
1 - ($east ? 0 : $inset),
|
||||||
$this->y + 1.5,
|
1.5,
|
||||||
$this->z + 1 - ($south ? 0 : $inset)
|
1 - ($south ? 0 : $inset)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,18 +54,10 @@ abstract class Door extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
|
||||||
$f = 0.1875;
|
$f = 0.1875;
|
||||||
$damage = $this->getFullDamage();
|
$damage = $this->getFullDamage();
|
||||||
|
|
||||||
$bb = new AxisAlignedBB(
|
$bb = new AxisAlignedBB(0, 0, 0, 1, 2, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 2,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
|
|
||||||
$j = $damage & 0x03;
|
$j = $damage & 0x03;
|
||||||
$isOpen = (($damage & 0x04) > 0);
|
$isOpen = (($damage & 0x04) > 0);
|
||||||
@ -74,126 +66,42 @@ abstract class Door extends Transparent{
|
|||||||
if($j === 0){
|
if($j === 0){
|
||||||
if($isOpen){
|
if($isOpen){
|
||||||
if(!$isRight){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + $f
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z + 1 - $f,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + $f,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}elseif($j === 1){
|
}elseif($j === 1){
|
||||||
if($isOpen){
|
if($isOpen){
|
||||||
if(!$isRight){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
||||||
$this->x + 1 - $f,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + $f,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + $f
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}elseif($j === 2){
|
}elseif($j === 2){
|
||||||
if($isOpen){
|
if($isOpen){
|
||||||
if(!$isRight){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z + 1 - $f,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + $f
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
||||||
$this->x + 1 - $f,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}elseif($j === 3){
|
}elseif($j === 3){
|
||||||
if($isOpen){
|
if($isOpen){
|
||||||
if(!$isRight){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + $f,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
||||||
$this->x + 1 - $f,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z + 1 - $f,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,12 +57,12 @@ class EndPortalFrame extends Solid{
|
|||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
0,
|
||||||
$this->y,
|
0,
|
||||||
$this->z,
|
0,
|
||||||
$this->x + 1,
|
1,
|
||||||
$this->y + (($this->getDamage() & 0x04) > 0 ? 1 : 0.8125),
|
(($this->getDamage() & 0x04) > 0 ? 1 : 0.8125),
|
||||||
$this->z + 1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,30 +68,30 @@ class EndRod extends Flowable{
|
|||||||
switch($m){
|
switch($m){
|
||||||
case 0x00: //up/down
|
case 0x00: //up/down
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + $width,
|
$width,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + $width,
|
$width,
|
||||||
$this->x + 1 - $width,
|
1 - $width,
|
||||||
$this->y + 1,
|
1,
|
||||||
$this->z + 1 - $width
|
1 - $width
|
||||||
);
|
);
|
||||||
case 0x02: //north/south
|
case 0x02: //north/south
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
0,
|
||||||
$this->y + $width,
|
$width,
|
||||||
$this->z + $width,
|
$width,
|
||||||
$this->x + 1,
|
1,
|
||||||
$this->y + 1 - $width,
|
1 - $width,
|
||||||
$this->z + 1 - $width
|
1 - $width
|
||||||
);
|
);
|
||||||
case 0x04: //east/west
|
case 0x04: //east/west
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + $width,
|
$width,
|
||||||
$this->y + $width,
|
$width,
|
||||||
$this->z,
|
0,
|
||||||
$this->x + 1 - $width,
|
1 - $width,
|
||||||
$this->y + 1 - $width,
|
1 - $width,
|
||||||
$this->z + 1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,16 +48,8 @@ class Farmland extends Transparent{
|
|||||||
return BlockToolType::TYPE_SHOVEL;
|
return BlockToolType::TYPE_SHOVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0, 0, 0, 1, 1, 1); //TODO: y max should be 0.9375, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1, //TODO: this should be 0.9375, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -40,12 +40,12 @@ abstract class Fence extends Transparent{
|
|||||||
$width = 0.5 - $this->getThickness() / 2;
|
$width = 0.5 - $this->getThickness() / 2;
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + ($this->canConnect($this->getSide(Vector3::SIDE_WEST)) ? 0 : $width),
|
($this->canConnect($this->getSide(Vector3::SIDE_WEST)) ? 0 : $width),
|
||||||
$this->y,
|
0,
|
||||||
$this->z + ($this->canConnect($this->getSide(Vector3::SIDE_NORTH)) ? 0 : $width),
|
($this->canConnect($this->getSide(Vector3::SIDE_NORTH)) ? 0 : $width),
|
||||||
$this->x + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_EAST)) ? 0 : $width),
|
1 - ($this->canConnect($this->getSide(Vector3::SIDE_EAST)) ? 0 : $width),
|
||||||
$this->y + 1.5,
|
1.5,
|
||||||
$this->z + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_SOUTH)) ? 0 : $width)
|
1 - ($this->canConnect($this->getSide(Vector3::SIDE_SOUTH)) ? 0 : $width)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,12 +61,12 @@ abstract class Fence extends Transparent{
|
|||||||
if($connectWest or $connectEast){
|
if($connectWest or $connectEast){
|
||||||
//X axis (west/east)
|
//X axis (west/east)
|
||||||
$bbs[] = new AxisAlignedBB(
|
$bbs[] = new AxisAlignedBB(
|
||||||
$this->x + ($connectWest ? 0 : $inset),
|
($connectWest ? 0 : $inset),
|
||||||
$this->y,
|
0,
|
||||||
$this->z + $inset,
|
$inset,
|
||||||
$this->x + 1 - ($connectEast ? 0 : $inset),
|
1 - ($connectEast ? 0 : $inset),
|
||||||
$this->y + 1.5,
|
1.5,
|
||||||
$this->z + 1 - $inset
|
1 - $inset
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,12 +76,12 @@ abstract class Fence extends Transparent{
|
|||||||
if($connectNorth or $connectSouth){
|
if($connectNorth or $connectSouth){
|
||||||
//Z axis (north/south)
|
//Z axis (north/south)
|
||||||
$bbs[] = new AxisAlignedBB(
|
$bbs[] = new AxisAlignedBB(
|
||||||
$this->x + $inset,
|
$inset,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + ($connectNorth ? 0 : $inset),
|
($connectNorth ? 0 : $inset),
|
||||||
$this->x + 1 - $inset,
|
1 - $inset,
|
||||||
$this->y + 1.5,
|
1.5,
|
||||||
$this->z + 1 - ($connectSouth ? 0 : $inset)
|
1 - ($connectSouth ? 0 : $inset)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,12 +89,12 @@ abstract class Fence extends Transparent{
|
|||||||
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
|
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
|
||||||
return [
|
return [
|
||||||
new AxisAlignedBB(
|
new AxisAlignedBB(
|
||||||
$this->x + $inset,
|
$inset,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + $inset,
|
$inset,
|
||||||
$this->x + 1 - $inset,
|
1 - $inset,
|
||||||
$this->y + 1.5,
|
1.5,
|
||||||
$this->z + 1 - $inset
|
1 - $inset
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ class FenceGate extends Transparent{
|
|||||||
|
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
|
||||||
if(($this->getDamage() & 0x04) > 0){
|
if(($this->getDamage() & 0x04) > 0){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -49,21 +48,21 @@ class FenceGate extends Transparent{
|
|||||||
$i = ($this->getDamage() & 0x03);
|
$i = ($this->getDamage() & 0x03);
|
||||||
if($i === 2 or $i === 0){
|
if($i === 2 or $i === 0){
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
0,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + 0.375,
|
0.375,
|
||||||
$this->x + 1,
|
1,
|
||||||
$this->y + 1.5,
|
1.5,
|
||||||
$this->z + 0.625
|
0.625
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + 0.375,
|
0.375,
|
||||||
$this->y,
|
0,
|
||||||
$this->z,
|
0,
|
||||||
$this->x + 0.625,
|
0.625,
|
||||||
$this->y + 1.5,
|
1.5,
|
||||||
$this->z + 1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,8 @@ class FlowerPot extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return new AxisAlignedBB(
|
static $f = 0.3125;
|
||||||
$this->x + 0.3125,
|
return new AxisAlignedBB($f, 0, $f, 1 - $f, 0.375, 1 - $f);
|
||||||
$this->y,
|
|
||||||
$this->z + 0.3125,
|
|
||||||
$this->x + 0.6875,
|
|
||||||
$this->y + 0.375,
|
|
||||||
$this->z + 0.6875
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
||||||
|
@ -45,14 +45,7 @@ class GrassPath extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0, 0, 0, 1, 1, 1); //TODO: y max should be 0.9375, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1, //TODO: this should be 0.9375, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
|
@ -79,12 +79,12 @@ class Ladder extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + $minX,
|
$minX,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + $minZ,
|
$minZ,
|
||||||
$this->x + $maxX,
|
$maxX,
|
||||||
$this->y + 1,
|
1,
|
||||||
$this->z + $maxZ
|
$maxZ
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,14 +49,8 @@ class Skull extends Flowable{
|
|||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
//TODO: different bounds depending on attached face (meta)
|
//TODO: different bounds depending on attached face (meta)
|
||||||
return new AxisAlignedBB(
|
static $f = 0.25;
|
||||||
$this->x + 0.25,
|
return new AxisAlignedBB($f, 0, $f, 1 - $f, 0.5, 1 - $f);
|
||||||
$this->y,
|
|
||||||
$this->z + 0.25,
|
|
||||||
$this->x + 0.75,
|
|
||||||
$this->y + 0.5,
|
|
||||||
$this->z + 0.75
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
||||||
|
@ -107,23 +107,9 @@ abstract class Slab extends Transparent{
|
|||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
|
||||||
if(($this->meta & 0x08) > 0){
|
if(($this->meta & 0x08) > 0){
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0, 0.5, 0, 1, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y + 0.5,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(0, 0, 0, 1, 0.5, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 0.5,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,14 +46,6 @@ class SoulSand extends Solid{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
return new AxisAlignedBB(0, 0, 0, 1, 1 - 0.125, 1);
|
||||||
return new AxisAlignedBB(
|
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1 - 0.125,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,7 @@ abstract class Stair extends Transparent{
|
|||||||
$maxYSlab = $minYSlab + 0.5;
|
$maxYSlab = $minYSlab + 0.5;
|
||||||
|
|
||||||
$bbs = [
|
$bbs = [
|
||||||
new AxisAlignedBB(
|
new AxisAlignedBB(0, $minYSlab, 0, 1, $maxYSlab, 1)
|
||||||
$this->x,
|
|
||||||
$this->y + $minYSlab,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + $maxYSlab,
|
|
||||||
$this->z + 1
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$minY = ($this->meta & 0x04) === 0 ? 0.5 : 0;
|
$minY = ($this->meta & 0x04) === 0 ? 0.5 : 0;
|
||||||
@ -70,14 +63,7 @@ abstract class Stair extends Transparent{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$bbs[] = new AxisAlignedBB(
|
$bbs[] = new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ);
|
||||||
$this->x + $minX,
|
|
||||||
$this->y + $minY,
|
|
||||||
$this->z + $minZ,
|
|
||||||
$this->x + $maxX,
|
|
||||||
$this->y + $maxY,
|
|
||||||
$this->z + $maxZ
|
|
||||||
);
|
|
||||||
|
|
||||||
return $bbs;
|
return $bbs;
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@ abstract class Thin extends Transparent{
|
|||||||
$width = 0.5 - 0.125 / 2;
|
$width = 0.5 - 0.125 / 2;
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + ($this->canConnect($this->getSide(Vector3::SIDE_WEST)) ? 0 : $width),
|
($this->canConnect($this->getSide(Vector3::SIDE_WEST)) ? 0 : $width),
|
||||||
$this->y,
|
0,
|
||||||
$this->z + ($this->canConnect($this->getSide(Vector3::SIDE_NORTH)) ? 0 : $width),
|
($this->canConnect($this->getSide(Vector3::SIDE_NORTH)) ? 0 : $width),
|
||||||
$this->x + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_EAST)) ? 0 : $width),
|
1 - ($this->canConnect($this->getSide(Vector3::SIDE_EAST)) ? 0 : $width),
|
||||||
$this->y + 1,
|
1,
|
||||||
$this->z + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_SOUTH)) ? 0 : $width)
|
1 - ($this->canConnect($this->getSide(Vector3::SIDE_SOUTH)) ? 0 : $width)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,12 +53,12 @@ abstract class Thin extends Transparent{
|
|||||||
if($connectWest or $connectEast){
|
if($connectWest or $connectEast){
|
||||||
//X axis (west/east)
|
//X axis (west/east)
|
||||||
$bbs[] = new AxisAlignedBB(
|
$bbs[] = new AxisAlignedBB(
|
||||||
$this->x + ($connectWest ? 0 : $inset),
|
($connectWest ? 0 : $inset),
|
||||||
$this->y,
|
0,
|
||||||
$this->z + $inset,
|
$inset,
|
||||||
$this->x + 1 - ($connectEast ? 0 : $inset),
|
1 - ($connectEast ? 0 : $inset),
|
||||||
$this->y + 1,
|
1,
|
||||||
$this->z + 1 - $inset
|
1 - $inset
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,12 +68,12 @@ abstract class Thin extends Transparent{
|
|||||||
if($connectNorth or $connectSouth){
|
if($connectNorth or $connectSouth){
|
||||||
//Z axis (north/south)
|
//Z axis (north/south)
|
||||||
$bbs[] = new AxisAlignedBB(
|
$bbs[] = new AxisAlignedBB(
|
||||||
$this->x + $inset,
|
$inset,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + ($connectNorth ? 0 : $inset),
|
($connectNorth ? 0 : $inset),
|
||||||
$this->x + 1 - $inset,
|
1 - $inset,
|
||||||
$this->y + 1,
|
1,
|
||||||
$this->z + 1 - ($connectSouth ? 0 : $inset)
|
1 - ($connectSouth ? 0 : $inset)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,12 +81,12 @@ abstract class Thin extends Transparent{
|
|||||||
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
|
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
|
||||||
return [
|
return [
|
||||||
new AxisAlignedBB(
|
new AxisAlignedBB(
|
||||||
$this->x + $inset,
|
$inset,
|
||||||
$this->y,
|
0,
|
||||||
$this->z + $inset,
|
$inset,
|
||||||
$this->x + 1 - $inset,
|
1 - $inset,
|
||||||
$this->y + 1,
|
1,
|
||||||
$this->z + 1 - $inset
|
1 - $inset
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -59,64 +59,22 @@ class Trapdoor extends Transparent{
|
|||||||
$f = 0.1875;
|
$f = 0.1875;
|
||||||
|
|
||||||
if(($damage & self::MASK_UPPER) > 0){
|
if(($damage & self::MASK_UPPER) > 0){
|
||||||
$bb = new AxisAlignedBB(
|
$bb = new AxisAlignedBB(0, 1 - $f, 0, 1, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y + 1 - $f,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb = new AxisAlignedBB(0, 0, 0, 1, $f, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + $f,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($damage & self::MASK_OPENED) > 0){
|
if(($damage & self::MASK_OPENED) > 0){
|
||||||
if(($damage & 0x03) === self::MASK_SIDE_NORTH){
|
if(($damage & 0x03) === self::MASK_SIDE_NORTH){
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 1 - $f, 1, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z + 1 - $f,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}elseif(($damage & 0x03) === self::MASK_SIDE_SOUTH){
|
}elseif(($damage & 0x03) === self::MASK_SIDE_SOUTH){
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, 1, 1, $f);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + $f
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if(($damage & 0x03) === self::MASK_SIDE_WEST){
|
if(($damage & 0x03) === self::MASK_SIDE_WEST){
|
||||||
$bb->setBounds(
|
$bb->setBounds(1 - $f, 0, 0, 1, 1, 1);
|
||||||
$this->x + 1 - $f,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + 1,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if(($damage & 0x03) === self::MASK_SIDE_EAST){
|
if(($damage & 0x03) === self::MASK_SIDE_EAST){
|
||||||
$bb->setBounds(
|
$bb->setBounds(0, 0, 0, $f, 1, 1);
|
||||||
$this->x,
|
|
||||||
$this->y,
|
|
||||||
$this->z,
|
|
||||||
$this->x + $f,
|
|
||||||
$this->y + 1,
|
|
||||||
$this->z + 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ class Vine extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
|
|
||||||
$minX = 1;
|
$minX = 1;
|
||||||
$minY = 1;
|
$minY = 1;
|
||||||
$minZ = 1;
|
$minZ = 1;
|
||||||
@ -121,14 +120,7 @@ class Vine extends Flowable{
|
|||||||
$maxZ = 1;
|
$maxZ = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ);
|
||||||
$this->x + $minX,
|
|
||||||
$this->y + $minY,
|
|
||||||
$this->z + $minZ,
|
|
||||||
$this->x + $maxX,
|
|
||||||
$this->y + $maxY,
|
|
||||||
$this->z + $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{
|
||||||
|
@ -45,17 +45,10 @@ class WaterLily extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return new AxisAlignedBB(
|
static $f = 0.0625;
|
||||||
$this->x + 0.0625,
|
return new AxisAlignedBB($f, 0, $f, 1 - $f, 0.015625, 1 - $f);
|
||||||
$this->y,
|
|
||||||
$this->z + 0.0625,
|
|
||||||
$this->x + 0.9375,
|
|
||||||
$this->y + 0.015625,
|
|
||||||
$this->z + 0.9375
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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($blockClicked instanceof Water){
|
if($blockClicked instanceof Water){
|
||||||
$up = $blockClicked->getSide(Vector3::SIDE_UP);
|
$up = $blockClicked->getSide(Vector3::SIDE_UP);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user