mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
PMF & Multiworld [part 2]
This commit is contained in:
@ -31,9 +31,8 @@ class BedBlock extends TransparentBlock{
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->inWorld === true){
|
||||
$down = $level->getBlockFace($block, 0);
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->isTransparent === false){
|
||||
$faces = array(
|
||||
0 => 3,
|
||||
@ -42,50 +41,47 @@ class BedBlock extends TransparentBlock{
|
||||
3 => 5,
|
||||
);
|
||||
$d = $player->entity->getDirection();
|
||||
$next = $level->getBlockFace($block, $faces[(($d + 3) % 4)]);
|
||||
$downNext = $level->getBlockFace($next, 0);
|
||||
$next = $this->level->getBlockFace($block, $faces[(($d + 3) % 4)]);
|
||||
$downNext = $this->level->getBlockFace($next, 0);
|
||||
if($next->isReplaceable === true and $downNext->isTransparent === false){
|
||||
$meta = (($d + 3) % 4) & 0x03;
|
||||
$level->setBlock($block, $this->id, $meta);
|
||||
$level->setBlock($next, $this->id, $meta | 0x08);
|
||||
$this->level->setBlock($block, BlockAPI::get($this->id, $meta));
|
||||
$this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
$blockNorth = $level->getBlockFace($this, 2); //Gets the blocks around them
|
||||
$blockSouth = $level->getBlockFace($this, 3);
|
||||
$blockEast = $level->getBlockFace($this, 5);
|
||||
$blockWest = $level->getBlockFace($this, 4);
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$blockNorth = $this->getSide(2); //Gets the blocks around them
|
||||
$blockSouth = $this->getSide(3);
|
||||
$blockEast = $this->getSide(5);
|
||||
$blockWest = $this->getSide(4);
|
||||
|
||||
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
|
||||
$level->setBlock($blockNorth, AIR, 0);
|
||||
$this->level->setBlock($blockNorth, new AirBlock());
|
||||
}elseif($blockSouth->getID() === $this->id and $blockSouth->meta !== 0x08){
|
||||
$level->setBlock($blockSouth, AIR, 0);
|
||||
$this->level->setBlock($blockSouth, new AirBlock());
|
||||
}elseif($blockEast->getID() === $this->id and $blockEast->meta !== 0x08){
|
||||
$level->setBlock($blockEast, AIR, 0);
|
||||
$this->level->setBlock($blockEast, new AirBlock());
|
||||
}elseif($blockWest->getID() === $this->id and $blockWest->meta !== 0x08){
|
||||
$level->setBlock($blockWest, AIR, 0);
|
||||
$this->level->setBlock($blockWest, new AirBlock());
|
||||
}
|
||||
}else{ //Bottom Part of Bed
|
||||
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
|
||||
$level->setBlock($blockNorth, AIR, 0);
|
||||
$this->level->setBlock($blockNorth, new AirBlock());
|
||||
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
|
||||
$level->setBlock($blockSouth, AIR, 0);
|
||||
$this->level->setBlock($blockSouth, new AirBlock());
|
||||
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
|
||||
$level->setBlock($blockEast, AIR, 0);
|
||||
$this->level->setBlock($blockEast, new AirBlock());
|
||||
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
||||
$level->setBlock($blockWest, AIR, 0);
|
||||
$this->level->setBlock($blockWest, new AirBlock());
|
||||
}
|
||||
}
|
||||
$level->setBlock($this, AIR, 0);
|
||||
$this->level->setBlock($this, new AirBlock());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
Reference in New Issue
Block a user