mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
fix collision detection not detecting fence & fence-gate, fixed nether-brick fence gate AABB, close #1299
This commit is contained in:
parent
a33be643c4
commit
27798c69ee
@ -85,11 +85,10 @@ class Fence extends Transparent{
|
||||
}
|
||||
|
||||
public function canConnect(Block $block){
|
||||
return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
|
||||
return $block instanceof Fence or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class NetherBrickFence extends Transparent{
|
||||
|
||||
@ -46,8 +48,21 @@ class NetherBrickFence extends Transparent{
|
||||
return "Nether Brick Fence";
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
$width = 0.375;
|
||||
|
||||
return new AxisAlignedBB(
|
||||
$this->x + ($this->canConnect($this->getSide(Vector3::SIDE_WEST)) ? 0 : $width),
|
||||
$this->y,
|
||||
$this->z + ($this->canConnect($this->getSide(Vector3::SIDE_NORTH)) ? 0 : $width),
|
||||
$this->x + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_EAST)) ? 0 : $width),
|
||||
$this->y + 1.5,
|
||||
$this->z + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_SOUTH)) ? 0 : $width)
|
||||
);
|
||||
}
|
||||
|
||||
public function canConnect(Block $block){
|
||||
return ($block instanceof NetherBrickFence) or ($block->isSolid() and !$block->isTransparent());
|
||||
return $block instanceof NetherBrickFence or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
@ -57,6 +72,4 @@ class NetherBrickFence extends Transparent{
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
//TODO: fix bounding boxes
|
||||
}
|
||||
|
@ -1094,12 +1094,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{
|
||||
$minX = Math::floorFloat($bb->minX);
|
||||
$minY = Math::floorFloat($bb->minY);
|
||||
$minZ = Math::floorFloat($bb->minZ);
|
||||
$maxX = Math::ceilFloat($bb->maxX);
|
||||
$maxY = Math::ceilFloat($bb->maxY);
|
||||
$maxZ = Math::ceilFloat($bb->maxZ);
|
||||
$bbPlusOne = $bb->grow(1, 1, 1);
|
||||
$minX = Math::floorFloat($bbPlusOne->minX);
|
||||
$minY = Math::floorFloat($bbPlusOne->minY);
|
||||
$minZ = Math::floorFloat($bbPlusOne->minZ);
|
||||
$maxX = Math::ceilFloat($bbPlusOne->maxX);
|
||||
$maxY = Math::ceilFloat($bbPlusOne->maxY);
|
||||
$maxZ = Math::ceilFloat($bbPlusOne->maxZ);
|
||||
|
||||
$collides = [];
|
||||
|
||||
@ -1157,12 +1158,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{
|
||||
$minX = Math::floorFloat($bb->minX);
|
||||
$minY = Math::floorFloat($bb->minY);
|
||||
$minZ = Math::floorFloat($bb->minZ);
|
||||
$maxX = Math::ceilFloat($bb->maxX);
|
||||
$maxY = Math::ceilFloat($bb->maxY);
|
||||
$maxZ = Math::ceilFloat($bb->maxZ);
|
||||
$bbPlusOne = $bb->grow(1, 1, 1);
|
||||
$minX = Math::floorFloat($bbPlusOne->minX);
|
||||
$minY = Math::floorFloat($bbPlusOne->minY);
|
||||
$minZ = Math::floorFloat($bbPlusOne->minZ);
|
||||
$maxX = Math::ceilFloat($bbPlusOne->maxX);
|
||||
$maxY = Math::ceilFloat($bbPlusOne->maxY);
|
||||
$maxZ = Math::ceilFloat($bbPlusOne->maxZ);
|
||||
|
||||
$collides = [];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user