mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
Fixed slab placement, close #145
This commit is contained in:
parent
c394aea803
commit
f2ff0198cc
@ -54,7 +54,7 @@ class Air extends Transparent{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced(Block $with = null) : bool{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,9 +597,11 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Block|null $with
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced(Block $with = null) : bool{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class DoublePlant extends Flowable{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced(Block $with = null) : bool{
|
||||||
return $this->meta === 2 or $this->meta === 3; //grass or fern
|
return $this->meta === 2 or $this->meta === 3; //grass or fern
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class Fire extends Flowable{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced(Block $with = null) : bool{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ abstract class Liquid extends Transparent{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced(Block $with = null) : bool{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class SnowLayer extends Flowable{
|
|||||||
return "Snow Layer";
|
return "Snow Layer";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced(Block $with = null) : bool{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class TallGrass extends Flowable{
|
|||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced(Block $with = null) : bool{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,10 @@ 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 $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||||
$this->meta &= 0x07;
|
$this->meta &= 0x07;
|
||||||
if($face === Vector3::SIDE_DOWN){
|
if($face === Vector3::SIDE_DOWN){
|
||||||
|
@ -1777,23 +1777,20 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($item->canBePlaced()){
|
if(!$item->canBePlaced()){
|
||||||
$hand = $item->getBlock();
|
|
||||||
$hand->position($block);
|
|
||||||
}else{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!($block->canBeReplaced() === true or ($hand->getId() === Item::WOODEN_SLAB and $block->getId() === Item::WOODEN_SLAB) or ($hand->getId() === Item::STONE_SLAB and $block->getId() === Item::STONE_SLAB))){
|
$hand = $item->getBlock();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($target->canBeReplaced() === true){
|
if($target->canBeReplaced($hand)){
|
||||||
$block = $target;
|
$block = $target;
|
||||||
$hand->position($block);
|
}elseif(!$block->canBeReplaced($hand)){
|
||||||
//$face = -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hand->position($block);
|
||||||
|
|
||||||
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());
|
||||||
$realCount = 0;
|
$realCount = 0;
|
||||||
@ -1834,7 +1831,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($hand->place($item, $block, $target, $face, $facePos, $player) === false){
|
if(!$hand->place($item, $block, $target, $face, $facePos, $player)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user