Block->place() parameter refactor to make things clearer

This commit is contained in:
Dylan K. Taylor
2017-08-26 14:41:49 +01:00
parent 20f34fba53
commit 6d5620606e
44 changed files with 122 additions and 122 deletions

View File

@ -82,34 +82,34 @@ class WoodenSlab extends Transparent{
return $with !== null and $with->getId() === $this->getId() and ($with->getDamage() & 0x07) === ($this->getDamage() & 0x07);
}
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$this->meta &= 0x07;
if($face === Vector3::SIDE_DOWN){
if($target->getId() === $this->id and ($target->getDamage() & 0x08) === 0x08 and ($target->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($target, BlockFactory::get($this->doubleId, $this->meta), true);
if($blockClicked->getId() === $this->id and ($blockClicked->getDamage() & 0x08) === 0x08 and ($blockClicked->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($blockClicked, BlockFactory::get($this->doubleId, $this->meta), true);
return true;
}elseif($block->getId() === $this->id and ($block->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($block, BlockFactory::get($this->doubleId, $this->meta), true);
}elseif($blockReplace->getId() === $this->id and ($blockReplace->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->doubleId, $this->meta), true);
return true;
}else{
$this->meta |= 0x08;
}
}elseif($face === Vector3::SIDE_UP){
if($target->getId() === $this->id and ($target->getDamage() & 0x08) === 0 and ($target->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($target, BlockFactory::get($this->doubleId, $this->meta), true);
if($blockClicked->getId() === $this->id and ($blockClicked->getDamage() & 0x08) === 0 and ($blockClicked->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($blockClicked, BlockFactory::get($this->doubleId, $this->meta), true);
return true;
}elseif($block->getId() === $this->id and ($block->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($block, BlockFactory::get($this->doubleId, $this->meta), true);
}elseif($blockReplace->getId() === $this->id and ($blockReplace->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->doubleId, $this->meta), true);
return true;
}
}else{ //TODO: collision
if($block->getId() === $this->id){
if(($block->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($block, BlockFactory::get($this->doubleId, $this->meta), true);
if($blockReplace->getId() === $this->id){
if(($blockReplace->getDamage() & 0x07) === $this->meta){
$this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->doubleId, $this->meta), true);
return true;
}
@ -122,10 +122,10 @@ class WoodenSlab extends Transparent{
}
}
if($block->getId() === $this->id and ($target->getDamage() & 0x07) !== ($this->meta & 0x07)){
if($blockReplace->getId() === $this->id and ($blockClicked->getDamage() & 0x07) !== ($this->meta & 0x07)){
return false;
}
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}