mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Added Doors bounding boxes
This commit is contained in:
@ -23,6 +23,7 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\network\protocol\LevelEventPacket;
|
use pocketmine\network\protocol\LevelEventPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
@ -34,6 +35,152 @@ abstract class Door extends Transparent{
|
|||||||
$this->isSolid = false;
|
$this->isSolid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBoundingBox(){
|
||||||
|
$f = 0.1875;
|
||||||
|
$damage = $this->getDamage();
|
||||||
|
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 2,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
|
||||||
|
$j = $damage & 0x03;
|
||||||
|
$flag = (($damage & 0x04) > 0);
|
||||||
|
$flag1 = (($damage & 0x0f) > 0);
|
||||||
|
|
||||||
|
if($j === 0){
|
||||||
|
if($flag){
|
||||||
|
if(!$flag1){
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + $f
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z + 1 - $f,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + $f,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}elseif($j === 1){
|
||||||
|
if($flag){
|
||||||
|
if(!$flag1){
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x + 1 - $f,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + $f,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + $f
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}elseif($j === 2){
|
||||||
|
if($flag){
|
||||||
|
if(!$flag1){
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z + 1 - $f,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + $f
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x + 1 - $f,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}elseif($j === 3){
|
||||||
|
if($flag){
|
||||||
|
if(!$flag1){
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + $f,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x + 1 - $f,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$bb = new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z + 1 - $f,
|
||||||
|
$this->x + 1,
|
||||||
|
$this->y + 1,
|
||||||
|
$this->z + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bb;
|
||||||
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
||||||
|
Reference in New Issue
Block a user