mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
cleanup block dual bounding box clusterfuck
"bounding box" serves no tangible purpose, only collision boxes do right now.
This commit is contained in:
parent
d58339b2fd
commit
4898a35613
@ -93,10 +93,12 @@ This version features substantial changes to the network system, improving coher
|
||||
- `Block->onEntityCollide()` -> `Block->onEntityInside()`
|
||||
- The following API methods have changed signatures:
|
||||
- `Block->onInteract()` now has the signature `onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool`
|
||||
- `Block->getCollisionBoxes()` is now final. Classes should override `recalculateCollisionBoxes()`.
|
||||
- The following API methods have been removed:
|
||||
- `Block->canPassThrough()`
|
||||
- `Block->setDamage()`
|
||||
- `Block::get()`: this was superseded by `BlockFactory::get()` a long time ago
|
||||
- `Block->getBoundingBox()`
|
||||
- The following classes have been renamed:
|
||||
- `BlockIds` -> `BlockLegacyIds`
|
||||
- `CobblestoneWall` -> `Wall`
|
||||
|
@ -50,10 +50,9 @@ class Air extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
@ -57,8 +57,11 @@ class Anvil extends Transparent implements Fallable{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->squash(Facing::axis(Facing::rotateY($this->facing, false)), 1 / 8);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->squash(Facing::axis(Facing::rotateY($this->facing, false)), 1 / 8)];
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -141,8 +141,11 @@ class Banner extends Transparent{
|
||||
$this->patterns = $checked;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return null;
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -88,8 +88,11 @@ class Bed extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 7 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 7 / 16)];
|
||||
}
|
||||
|
||||
public function isHeadPart() : bool{
|
||||
|
@ -64,8 +64,6 @@ class Block{
|
||||
/** @var Position */
|
||||
protected $pos;
|
||||
|
||||
/** @var AxisAlignedBB */
|
||||
protected $boundingBox = null;
|
||||
/** @var AxisAlignedBB[]|null */
|
||||
protected $collisionBoxes = null;
|
||||
|
||||
@ -167,7 +165,6 @@ class Block{
|
||||
* AABBs and force recalculation.
|
||||
*/
|
||||
public function readStateFromWorld() : void{
|
||||
$this->boundingBox = null;
|
||||
$this->collisionBoxes = null;
|
||||
}
|
||||
|
||||
@ -687,31 +684,7 @@ class Block{
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
if($bb = $this->recalculateBoundingBox()){
|
||||
return [$bb];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB|null
|
||||
*/
|
||||
final public function getBoundingBox() : ?AxisAlignedBB{
|
||||
if($this->boundingBox === null){
|
||||
$this->boundingBox = $this->recalculateBoundingBox();
|
||||
if($this->boundingBox !== null){
|
||||
$this->boundingBox->offset($this->pos->x, $this->pos->y, $this->pos->z);
|
||||
}
|
||||
}
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB|null
|
||||
*/
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one();
|
||||
return [AxisAlignedBB::one()];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,9 +60,12 @@ class Cactus extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
static $shrinkSize = 1 / 16;
|
||||
return AxisAlignedBB::one()->contract($shrinkSize, 0, $shrinkSize)->trim(Facing::UP, $shrinkSize);
|
||||
return [AxisAlignedBB::one()->contract($shrinkSize, 0, $shrinkSize)->trim(Facing::UP, $shrinkSize)];
|
||||
}
|
||||
|
||||
public function onEntityInside(Entity $entity) : void{
|
||||
|
@ -55,11 +55,16 @@ class Cake extends Transparent implements FoodSource{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()
|
||||
->contract(1 / 16, 0, 1 / 16)
|
||||
->trim(Facing::UP, 0.5)
|
||||
->trim(Facing::WEST, $this->bites / 8);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [
|
||||
AxisAlignedBB::one()
|
||||
->contract(1 / 16, 0, 1 / 16)
|
||||
->trim(Facing::UP, 0.5)
|
||||
->trim(Facing::WEST, $this->bites / 8)
|
||||
];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -40,8 +40,11 @@ class Carpet extends Flowable{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 15 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 15 / 16)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -53,9 +53,12 @@ class Chest extends Transparent{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
//these are slightly bigger than in PC
|
||||
return AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05);
|
||||
return [AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -63,13 +63,18 @@ class CocoaBlock extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()
|
||||
->squash(Facing::axis(Facing::rotateY($this->facing, true)), (6 - $this->age) / 16) //sides
|
||||
->trim(Facing::DOWN, (7 - $this->age * 2) / 16)
|
||||
->trim(Facing::UP, 0.25)
|
||||
->trim(Facing::opposite($this->facing), 1 / 16) //gap between log and pod
|
||||
->trim($this->facing, (11 - $this->age * 2) / 16); //outward face
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [
|
||||
AxisAlignedBB::one()
|
||||
->squash(Facing::axis(Facing::rotateY($this->facing, true)), (6 - $this->age) / 16) //sides
|
||||
->trim(Facing::DOWN, (7 - $this->age * 2) / 16)
|
||||
->trim(Facing::UP, 0.25)
|
||||
->trim(Facing::opposite($this->facing), 1 / 16) //gap between log and pod
|
||||
->trim($this->facing, (11 - $this->age * 2) / 16) //outward face
|
||||
];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -83,8 +83,11 @@ class DaylightSensor extends Transparent{
|
||||
return 300;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 10 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 10 / 16)];
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -92,8 +92,11 @@ class Door extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim($this->open ? Facing::rotateY($this->facing, !$this->hingeRight) : $this->facing, 13 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim($this->open ? Facing::rotateY($this->facing, !$this->hingeRight) : $this->facing, 13 / 16)];
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
|
@ -37,8 +37,11 @@ class EnchantingTable extends Transparent{
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel(), 6000.0));
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 0.25);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 0.25)];
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -59,8 +59,11 @@ class EndPortalFrame extends Opaque{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 3 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 3 / 16)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -78,7 +78,10 @@ class EndRod extends Flowable{
|
||||
return 14;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
$myAxis = Facing::axis($this->facing);
|
||||
|
||||
$bb = AxisAlignedBB::one();
|
||||
@ -88,6 +91,6 @@ class EndRod extends Flowable{
|
||||
}
|
||||
$bb->squash($axis, 6 / 16);
|
||||
}
|
||||
return $bb;
|
||||
return [$bb];
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +58,12 @@ class EnderChest extends Transparent{
|
||||
return 7;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
//these are slightly bigger than in PC
|
||||
return AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05);
|
||||
return [AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -49,8 +49,11 @@ class Farmland extends Transparent{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one(); //TODO: this should be trimmed at the top by 1/16, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()]; //TODO: this should be trimmed at the top by 1/16, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
|
@ -47,19 +47,9 @@ class Fence extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
$width = 0.5 - $this->getThickness() / 2;
|
||||
|
||||
$bb = AxisAlignedBB::one()
|
||||
->extend(Facing::UP, 0.5);
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
if(!isset($this->connections[$facing])){
|
||||
$bb->trim($facing, $width);
|
||||
}
|
||||
}
|
||||
return $bb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
$inset = 0.5 - $this->getThickness() / 2;
|
||||
|
||||
|
@ -60,12 +60,11 @@ class FenceGate extends Transparent{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
if($this->open){
|
||||
return null;
|
||||
}
|
||||
|
||||
return AxisAlignedBB::one()->extend(Facing::UP, 0.5)->squash(Facing::axis($this->facing), 6 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return $this->open ? [] : [AxisAlignedBB::one()->extend(Facing::UP, 0.5)->squash(Facing::axis($this->facing), 6 / 16)];
|
||||
}
|
||||
|
||||
private function checkInWall() : bool{
|
||||
|
@ -35,7 +35,10 @@ abstract class Flowable extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return null;
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -111,8 +111,11 @@ class FlowerPot extends Flowable{
|
||||
//TODO: bamboo
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->contract(3 / 16, 0, 3 / 16)->trim(Facing::UP, 5 / 8);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->contract(3 / 16, 0, 3 / 16)->trim(Facing::UP, 5 / 8)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -33,8 +33,11 @@ class GrassPath extends Transparent{
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6, BlockToolType::SHOVEL));
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one(); //TODO: this should be trimmed at the top by 1/16, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()]; //TODO: this should be trimmed at the top by 1/16, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
|
@ -72,11 +72,13 @@ class Ladder extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim($this->facing, 13 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim($this->facing, 13 / 16)];
|
||||
}
|
||||
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$blockClicked->isTransparent() and Facing::axis($face) !== Facing::AXIS_Y){
|
||||
$this->facing = $face;
|
||||
|
@ -51,12 +51,17 @@ class Lantern extends Transparent{
|
||||
return 15;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()
|
||||
->trim(Facing::UP, $this->hanging ? 6 / 16 : 8 / 16)
|
||||
->trim(Facing::DOWN, $this->hanging ? 2 / 16 : 0)
|
||||
->squash(Facing::AXIS_X, 5 / 16)
|
||||
->squash(Facing::AXIS_Z, 5 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [
|
||||
AxisAlignedBB::one()
|
||||
->trim(Facing::UP, $this->hanging ? 6 / 16 : 8 / 16)
|
||||
->trim(Facing::DOWN, $this->hanging ? 2 / 16 : 0)
|
||||
->squash(Facing::AXIS_X, 5 / 16)
|
||||
->squash(Facing::AXIS_Z, 5 / 16)
|
||||
];
|
||||
}
|
||||
|
||||
protected function canAttachTo(Block $b) : bool{
|
||||
|
@ -99,8 +99,11 @@ abstract class Liquid extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return null;
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
|
@ -74,8 +74,11 @@ class NetherPortal extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return null;
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
|
@ -143,8 +143,11 @@ class RedstoneComparator extends Flowable{
|
||||
$this->signalStrength = $signalStrength;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 7 / 8);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 7 / 8)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -64,8 +64,11 @@ class RedstoneRepeater extends Flowable{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 7 / 8);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 7 / 8)];
|
||||
}
|
||||
|
||||
public function isPowered() : bool{
|
||||
|
@ -60,8 +60,11 @@ class SeaPickle extends Transparent{
|
||||
return $this->underwater ? ($this->count + 1) * 3 : 0;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return null;
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{
|
||||
|
@ -107,8 +107,11 @@ class Sign extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return null;
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -90,9 +90,12 @@ class Skull extends Flowable{
|
||||
return $this->skullType;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
//TODO: different bounds depending on attached face
|
||||
return AxisAlignedBB::one()->contract(0.25, 0, 0.25)->trim(Facing::UP, 0.5);
|
||||
return [AxisAlignedBB::one()->contract(0.25, 0, 0.25)->trim(Facing::UP, 0.5)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -119,11 +119,14 @@ class Slab extends Transparent{
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
if($this->slabType->equals(SlabType::DOUBLE())){
|
||||
return parent::recalculateBoundingBox();
|
||||
return [AxisAlignedBB::one()];
|
||||
}
|
||||
return AxisAlignedBB::one()->trim($this->slabType->equals(SlabType::TOP()) ? Facing::DOWN : Facing::UP, 0.5);
|
||||
return [AxisAlignedBB::one()->trim($this->slabType->equals(SlabType::TOP()) ? Facing::DOWN : Facing::UP, 0.5)];
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
|
@ -63,9 +63,12 @@ class SnowLayer extends Flowable implements Fallable{
|
||||
return $this->layers < 8;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
//TODO: this zero-height BB is intended to stay in lockstep with a MCPE bug
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, $this->layers >= 4 ? 0.5 : 1);
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, $this->layers >= 4 ? 0.5 : 1)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -32,7 +32,10 @@ class SoulSand extends Opaque{
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5, BlockToolType::SHOVEL));
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 1 / 8);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 1 / 8)];
|
||||
}
|
||||
}
|
||||
|
@ -43,16 +43,6 @@ class Thin extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
$bb = AxisAlignedBB::one();
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
if(!isset($this->connections[$facing])){
|
||||
$bb->trim($facing, 7 / 16);
|
||||
}
|
||||
}
|
||||
return $bb;
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
$inset = 7 / 16;
|
||||
|
||||
|
@ -57,8 +57,11 @@ class Trapdoor extends Transparent{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim($this->open ? $this->facing : ($this->top ? Facing::DOWN : Facing::UP), 13 / 16);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->trim($this->open ? $this->facing : ($this->top ? Facing::DOWN : Facing::UP), 13 / 16)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -86,17 +86,6 @@ class Vine extends Flowable{
|
||||
$entity->resetFallDistance();
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
switch(count($this->faces)){
|
||||
case 0:
|
||||
return AxisAlignedBB::one()->trim(Facing::DOWN, 15 / 16);
|
||||
case 1:
|
||||
return AxisAlignedBB::one()->trim(Facing::opposite(array_keys($this->faces)[0]), 15 / 16);
|
||||
default:
|
||||
return AxisAlignedBB::one();
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class Wall extends Transparent{
|
||||
$this->up = $this->getSide(Facing::UP)->getId() !== BlockLegacyIds::AIR;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
//walls don't have any special collision boxes like fences do
|
||||
|
||||
$north = isset($this->connections[Facing::NORTH]);
|
||||
@ -73,11 +73,13 @@ class Wall extends Transparent{
|
||||
$inset = 0.3125;
|
||||
}
|
||||
|
||||
return AxisAlignedBB::one()
|
||||
->extend(Facing::UP, 0.5)
|
||||
->trim(Facing::NORTH, $north ? 0 : $inset)
|
||||
->trim(Facing::SOUTH, $south ? 0 : $inset)
|
||||
->trim(Facing::WEST, $west ? 0 : $inset)
|
||||
->trim(Facing::EAST, $east ? 0 : $inset);
|
||||
return [
|
||||
AxisAlignedBB::one()
|
||||
->extend(Facing::UP, 0.5)
|
||||
->trim(Facing::NORTH, $north ? 0 : $inset)
|
||||
->trim(Facing::SOUTH, $south ? 0 : $inset)
|
||||
->trim(Facing::WEST, $west ? 0 : $inset)
|
||||
->trim(Facing::EAST, $east ? 0 : $inset)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,11 @@ class WaterLily extends Flowable{
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6));
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->contract(1 / 16, 0, 1 / 16)->trim(Facing::UP, 63 / 64);
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()->contract(1 / 16, 0, 1 / 16)->trim(Facing::UP, 63 / 64)];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
Loading…
x
Reference in New Issue
Block a user