Fixed Bed Breaking & added return info

This commit is contained in:
Shoghi Cervantes Pueyo 2013-02-25 20:49:34 +01:00
parent 66d43228cd
commit 53b79a1f7b

View File

@ -27,7 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
class BedBlock extends TransparentBlock{ class BedBlock extends TransparentBlock{
public function __construct($type = 0){ public function __construct($type = 0){
parent::__construct(BED_BLOCK, $type, "Bed"); parent::__construct(BED_BLOCK, $type, "Bed Block");
$this->isActivable = true; $this->isActivable = true;
} }
@ -57,37 +57,39 @@ class BedBlock extends TransparentBlock{
public function onBreak(BlockAPI $level, Item $item, Player $player){ public function onBreak(BlockAPI $level, Item $item, Player $player){
if($this->inWorld === true){//Checks if the block was in the world or not. Just in case if($this->inWorld === true){//Checks if the block was in the world or not. Just in case
$blockNorth = $level->getBlockFace($this, 2);//Gets the blocks around them $blockNorth = $level->getBlockFace($this, 2); //Gets the blocks around them
$blockSouth = $level->getBlockFace($this, 3); $blockSouth = $level->getBlockFace($this, 3);
$blockEast = $level->getBlockFace($this, 5); $blockEast = $level->getBlockFace($this, 5);
$blockWest = $level->getBlockFace($this, 4); $blockWest = $level->getBlockFace($this, 4);
if(($this->meta & 0x08) === 0x08){//This is the Top part of bed if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
if($blockNorth->getID() === $this->id and $blockNorth->meta !== 0x08){ //Checks if the block ID and meta are right
if($blockNorth->getID() === $this->id and $blockNorth->meta != 0x08)//Checks if the block ID and meta are right
$level->setBlock($blockNorth, 0, 0); $level->setBlock($blockNorth, 0, 0);
if($blockSouth->getID() === $this->id and $blockSouth->meta != 0x08) }elseif($blockSouth->getID() === $this->id and $blockSouth->meta !== 0x08){
$level->setBlock($blockSouth, 0, 0); $level->setBlock($blockSouth, 0, 0);
if($blockEast->getID() === $this->id and $blockEast->meta != 0x08) }elseif($blockEast->getID() === $this->id and $blockEast->meta !== 0x08){
$level->setBlock($blockEast, 0, 0); $level->setBlock($blockEast, 0, 0);
if($blockWest->getID() === $this->id and $blockWest->meta != 0x08) }elseif($blockWest->getID() === $this->id and $blockWest->meta !== 0x08){
$level->setBlock($blockWest, 0, 0); $level->setBlock($blockWest, 0, 0);
} }else{
else return false;
{
if(($this->meta & 0x08) != 0x08)//Bottom Part of Bed
{
if($blockNorth->getID() === $this->id and $blockNorth->meta === 0x08)
$level->setBlock($blockNorth, 0, 0);
if($blockSouth->getID() === $this->id and $blockSouth->meta === 0x08)
$level->setBlock($blockSouth, 0, 0);
if($blockEast->getID() === $this->id and $blockEast->meta === 0x08)
$level->setBlock($blockEast, 0, 0);
if($blockWest->getID() === $this->id and $blockWest->meta === 0x08)
$level->setBlock($blockWest, 0, 0);
} }
return true;
}else{ //Bottom Part of Bed
if($blockNorth->getID() === $this->id and $blockNorth->meta === 0x08){
$level->setBlock($blockNorth, 0, 0);
}elseif($blockSouth->getID() === $this->id and $blockSouth->meta === 0x08){
$level->setBlock($blockSouth, 0, 0);
}elseif($blockEast->getID() === $this->id and $blockEast->meta === 0x08){
$level->setBlock($blockEast, 0, 0);
}elseif($blockWest->getID() === $this->id and $blockWest->meta === 0x08){
$level->setBlock($blockWest, 0, 0);
}else{
return false;
}
return true;
} }
return false;
} }
} }