mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
fixed wall collision detection
walls have to be weird...
This commit is contained in:
parent
061a9444cc
commit
60b62a4890
@ -27,7 +27,7 @@ use pocketmine\item\Tool;
|
|||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
|
|
||||||
class CobblestoneWall extends Fence{
|
class CobblestoneWall extends Transparent{
|
||||||
const NONE_MOSSY_WALL = 0;
|
const NONE_MOSSY_WALL = 0;
|
||||||
const MOSSY_WALL = 1;
|
const MOSSY_WALL = 1;
|
||||||
|
|
||||||
@ -53,8 +53,38 @@ class CobblestoneWall extends Fence{
|
|||||||
return "Cobblestone Wall";
|
return "Cobblestone Wall";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThickness() : float{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return 0.5;
|
//walls don't have any special collision boxes like fences do
|
||||||
|
|
||||||
|
$north = $this->canConnect($this->getSide(Vector3::SIDE_NORTH));
|
||||||
|
$south = $this->canConnect($this->getSide(Vector3::SIDE_SOUTH));
|
||||||
|
$west = $this->canConnect($this->getSide(Vector3::SIDE_WEST));
|
||||||
|
$east = $this->canConnect($this->getSide(Vector3::SIDE_EAST));
|
||||||
|
|
||||||
|
$inset = 0.25;
|
||||||
|
if(
|
||||||
|
$this->getSide(Vector3::SIDE_UP)->getId() === Block::AIR and //if there is a block on top, it stays as a post
|
||||||
|
(
|
||||||
|
($north and $south and !$west and !$east) or
|
||||||
|
(!$north and !$south and $west and $east)
|
||||||
|
)
|
||||||
|
){
|
||||||
|
//If connected to two sides on the same axis but not any others, AND there is not a block on top, there is no post and the wall is thinner
|
||||||
|
$inset = 0.3125;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AxisAlignedBB(
|
||||||
|
$this->x + ($west ? 0 : $inset),
|
||||||
|
$this->y,
|
||||||
|
$this->z + ($north ? 0 : $inset),
|
||||||
|
$this->x + 1 - ($east ? 0 : $inset),
|
||||||
|
$this->y + 1.5,
|
||||||
|
$this->z + 1 - ($south ? 0 : $inset)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canConnect(Block $block){
|
||||||
|
return $block instanceof static or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user