Revert "Fixed slab placement, close #145", reopen #145, close #1314

This reverts commit f2ff0198cca01db0e93a9b45d428e624822f18e9.
This commit is contained in:
Dylan K. Taylor 2017-09-21 14:41:18 +01:00
parent 5aba87b250
commit 1b5fed983b
9 changed files with 17 additions and 20 deletions

View File

@ -54,7 +54,7 @@ class Air extends Transparent{
return true; return true;
} }
public function canBeReplaced(Block $with = null) : bool{ public function canBeReplaced() : bool{
return true; return true;
} }

View File

@ -284,11 +284,9 @@ class Block extends Position implements BlockIds, Metadatable{
} }
/** /**
* @param Block|null $with
*
* @return bool * @return bool
*/ */
public function canBeReplaced(Block $with = null) : bool{ public function canBeReplaced() : bool{
return false; return false;
} }

View File

@ -38,7 +38,7 @@ class DoublePlant extends Flowable{
$this->meta = $meta; $this->meta = $meta;
} }
public function canBeReplaced(Block $with = null) : bool{ public function canBeReplaced() : bool{
return $this->meta === 2 or $this->meta === 3; //grass or fern return $this->meta === 2 or $this->meta === 3; //grass or fern
} }

View File

@ -57,7 +57,7 @@ class Fire extends Flowable{
return false; return false;
} }
public function canBeReplaced(Block $with = null) : bool{ public function canBeReplaced() : bool{
return true; return true;
} }

View File

@ -41,7 +41,7 @@ abstract class Liquid extends Transparent{
return false; return false;
} }
public function canBeReplaced(Block $with = null) : bool{ public function canBeReplaced() : bool{
return true; return true;
} }

View File

@ -42,7 +42,7 @@ class SnowLayer extends Flowable{
return "Snow Layer"; return "Snow Layer";
} }
public function canBeReplaced(Block $with = null) : bool{ public function canBeReplaced() : bool{
return true; return true;
} }

View File

@ -37,7 +37,7 @@ class TallGrass extends Flowable{
$this->meta = $meta; $this->meta = $meta;
} }
public function canBeReplaced(Block $with = null) : bool{ public function canBeReplaced() : bool{
return true; return true;
} }

View File

@ -78,10 +78,6 @@ class WoodenSlab extends Transparent{
} }
} }
public function canBeReplaced(Block $with = null) : bool{
return $with !== null and $with->getId() === $this->getId() and ($with->getDamage() & 0x07) === ($this->getDamage() & 0x07);
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, 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; $this->meta &= 0x07;
if($face === Vector3::SIDE_DOWN){ if($face === Vector3::SIDE_DOWN){

View File

@ -1723,19 +1723,22 @@ class Level implements ChunkManager, Metadatable{
return true; return true;
} }
if(!$item->canBePlaced()){ if($item->canBePlaced()){
return false;
}
$hand = $item->getBlock(); $hand = $item->getBlock();
$hand->position($blockReplace);
if($blockClicked->canBeReplaced($hand)){ }else{
$blockReplace = $blockClicked;
}elseif(!$blockReplace->canBeReplaced($hand)){
return false; return false;
} }
if(!($blockReplace->canBeReplaced() === true or ($hand->getId() === Item::WOODEN_SLAB and $blockReplace->getId() === Item::WOODEN_SLAB) or ($hand->getId() === Item::STONE_SLAB and $blockReplace->getId() === Item::STONE_SLAB))){
return false;
}
if($blockClicked->canBeReplaced() === true){
$blockReplace = $blockClicked;
$hand->position($blockReplace); $hand->position($blockReplace);
//$face = -1;
}
if($hand->isSolid() === true and $hand->getBoundingBox() !== null){ if($hand->isSolid() === true and $hand->getBoundingBox() !== null){
$entities = $this->getCollidingEntities($hand->getBoundingBox()); $entities = $this->getCollidingEntities($hand->getBoundingBox());