Allow vanilla trapdoor placement

This commit is contained in:
Dylan K. Taylor 2016-09-23 10:12:30 +01:00
parent 7145e16bce
commit e2e31d345d

View File

@ -126,26 +126,22 @@ class Trapdoor extends Transparent{
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if(($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1){ $directions = [
$faces = [ 0 => 1,
self::SIDE_SOUTH => self::MASK_SIDE_SOUTH, 1 => 3,
self::SIDE_NORTH => self::MASK_SIDE_NORTH, 2 => 0,
self::SIDE_EAST => self::MASK_SIDE_EAST, 3 => 2
self::SIDE_WEST => self::MASK_SIDE_WEST,
]; ];
echo $face, PHP_EOL, $faces[$face], PHP_EOL; if($player !== null){
$this->meta = $faces[$face] & self::MASK_SIDE; $this->meta = $directions[$player->getDirection() & 0x03];
if($fy > 0.5){ }
$this->meta |= self::MASK_UPPER; if(($fy > 0.5 and $face !== self::SIDE_UP) or $face === self::SIDE_DOWN){
$this->meta |= self::MASK_UPPER; //top half of block
} }
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
return true; return true;
} }
return false;
}
public function getDrops(Item $item){ public function getDrops(Item $item){
return [ return [
[$this->id, 0, 1], [$this->id, 0, 1],