Disable placing a chest when a chest already exists on the side

This commit is contained in:
Shoghi Cervantes Pueyo 2013-03-19 18:21:18 +01:00
parent a3268d2405
commit e1c5d965a0

View File

@ -32,6 +32,11 @@ class ChestBlock extends SolidBlock{
} }
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($block->inWorld === true){ if($block->inWorld === true){
$block0 = $level->getBlockFace($block, 2);
$block1 = $level->getBlockFace($block, 3);
$block2 = $level->getBlockFace($block, 4);
$block3 = $level->getBlockFace($block, 5);
if($block0->getID() !== CHEST and $block1->getID() !== CHEST and $block2->getID() !== CHEST and $block3->getID() !== CHEST){
$faces = array( $faces = array(
0 => 4, 0 => 4,
1 => 2, 1 => 2,
@ -49,6 +54,7 @@ class ChestBlock extends SolidBlock{
)); ));
return true; return true;
} }
}
return false; return false;
} }