diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 65040a5af..86419be3d 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -531,19 +531,23 @@ class BlockAPI{ return false; } - if($block->isReplaceable === true and $item->isPlaceable()){ + if($item->isPlaceable()){ $hand = $item->getBlock(); }else{ return $this->cancelAction($block); } + if(!($block->isReplaceable === true or ($hand->getID() === SLAB and $block->getID() === SLAB))){ + return $this->cancelAction($block); + } + if($hand->isTransparent === false and $player->entity->inBlock($block->x, $block->y, $block->z)){ return $this->cancelAction($block); //Entity in block } //$direction = $player->entity->getDirection(); - if($hand->place($this, $item, $player, $block, $target, $data["face"]) === false){ + if($hand->place($this, $item, $player, $block, $target, $data["face"], $data["fx"], $data["fy"], $data["fz"]) === false){ return false; } diff --git a/src/classes/material/Block.php b/src/classes/material/Block.php index e93df91a3..a6fcdc2c2 100644 --- a/src/classes/material/Block.php +++ b/src/classes/material/Block.php @@ -77,7 +77,7 @@ abstract class Block{ ); } - abstract function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face); + abstract function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz); abstract function onActivate(BlockAPI $level, Item $item, Player $player); diff --git a/src/classes/material/block/GenericBlock.php b/src/classes/material/block/GenericBlock.php index bddb14430..4bf14cae7 100644 --- a/src/classes/material/block/GenericBlock.php +++ b/src/classes/material/block/GenericBlock.php @@ -30,7 +30,7 @@ class GenericBlock extends Block{ public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); } - public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face){ + public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($block->inWorld === true){ $level->setBlock($block, $this->id, $this->getMetadata()); return true; diff --git a/src/classes/material/block/plant/Sapling.php b/src/classes/material/block/plant/Sapling.php index 61f5d6aab..5b69ac993 100644 --- a/src/classes/material/block/plant/Sapling.php +++ b/src/classes/material/block/plant/Sapling.php @@ -43,7 +43,7 @@ class SaplingBlock extends TransparentBlock{ $this->name = $names[$this->meta & 0x03]; } - public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face){ + 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); if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ diff --git a/src/classes/material/block/solid/Slab.php b/src/classes/material/block/solid/Slab.php index db5519da3..1b62526cd 100644 --- a/src/classes/material/block/solid/Slab.php +++ b/src/classes/material/block/solid/Slab.php @@ -41,4 +41,38 @@ class SlabBlock extends TransparentBlock{ $this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab"; } + public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + if($block->inWorld === true){ + $this->meta = $this->meta & 0x07; + if($face === 0){ + if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ + $level->setBlock($target, DOUBLE_SLAB, $this->meta & 0x07); + return true; + }else{ + $this->meta |= 0x08; + } + }elseif($face === 1){ + if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ + $level->setBlock($target, DOUBLE_SLAB, $this->meta & 0x07); + return true; + } + }else{ + if($block->getID() === SLAB){ + if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ + $level->setBlock($block, DOUBLE_SLAB, $this->meta & 0x07); + return true; + } + return false; + }else{ + if($fy > 0.5){ + $this->meta |= 0x08; + } + } + } + $level->setBlock($block, $this->id, $this->meta); + return true; + } + return false; + } + } \ No newline at end of file