mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 06:55:29 +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){
|
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{
|
public function getFuelTime() : int{
|
||||||
return 300;
|
return 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\Tool;
|
use pocketmine\item\Tool;
|
||||||
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
|
||||||
class NetherBrickFence extends Transparent{
|
class NetherBrickFence extends Transparent{
|
||||||
|
|
||||||
@ -46,8 +48,21 @@ class NetherBrickFence extends Transparent{
|
|||||||
return "Nether Brick Fence";
|
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){
|
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{
|
public function getDrops(Item $item) : array{
|
||||||
@ -57,6 +72,4 @@ class NetherBrickFence extends Transparent{
|
|||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: fix bounding boxes
|
|
||||||
}
|
}
|
||||||
|
@ -1094,12 +1094,13 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return Block[]
|
* @return Block[]
|
||||||
*/
|
*/
|
||||||
public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{
|
public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{
|
||||||
$minX = Math::floorFloat($bb->minX);
|
$bbPlusOne = $bb->grow(1, 1, 1);
|
||||||
$minY = Math::floorFloat($bb->minY);
|
$minX = Math::floorFloat($bbPlusOne->minX);
|
||||||
$minZ = Math::floorFloat($bb->minZ);
|
$minY = Math::floorFloat($bbPlusOne->minY);
|
||||||
$maxX = Math::ceilFloat($bb->maxX);
|
$minZ = Math::floorFloat($bbPlusOne->minZ);
|
||||||
$maxY = Math::ceilFloat($bb->maxY);
|
$maxX = Math::ceilFloat($bbPlusOne->maxX);
|
||||||
$maxZ = Math::ceilFloat($bb->maxZ);
|
$maxY = Math::ceilFloat($bbPlusOne->maxY);
|
||||||
|
$maxZ = Math::ceilFloat($bbPlusOne->maxZ);
|
||||||
|
|
||||||
$collides = [];
|
$collides = [];
|
||||||
|
|
||||||
@ -1157,12 +1158,13 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return AxisAlignedBB[]
|
* @return AxisAlignedBB[]
|
||||||
*/
|
*/
|
||||||
public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{
|
public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{
|
||||||
$minX = Math::floorFloat($bb->minX);
|
$bbPlusOne = $bb->grow(1, 1, 1);
|
||||||
$minY = Math::floorFloat($bb->minY);
|
$minX = Math::floorFloat($bbPlusOne->minX);
|
||||||
$minZ = Math::floorFloat($bb->minZ);
|
$minY = Math::floorFloat($bbPlusOne->minY);
|
||||||
$maxX = Math::ceilFloat($bb->maxX);
|
$minZ = Math::floorFloat($bbPlusOne->minZ);
|
||||||
$maxY = Math::ceilFloat($bb->maxY);
|
$maxX = Math::ceilFloat($bbPlusOne->maxX);
|
||||||
$maxZ = Math::ceilFloat($bb->maxZ);
|
$maxY = Math::ceilFloat($bbPlusOne->maxY);
|
||||||
|
$maxZ = Math::ceilFloat($bbPlusOne->maxZ);
|
||||||
|
|
||||||
$collides = [];
|
$collides = [];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user