This commit is contained in:
ArkQuark 2021-12-22 23:37:59 +03:00
commit 8f4a1807ae

View file

@ -37,12 +37,12 @@ class SugarcaneBlock extends FlowableBlock{
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){ if($b->getID() === AIR){
//$this->level->setBlock($b, new SugarcaneBlock(), true, false, true); $this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
break; break;
} }
} }
$this->meta = 0; $this->meta = 0;
//$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
} }
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
@ -56,25 +56,25 @@ class SugarcaneBlock extends FlowableBlock{
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace with common break method if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace with common break method
//ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
}elseif($type === BLOCK_UPDATE_RANDOM){ }elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){ if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
if($this->meta === 0x0F){ if($this->meta === 0x0F){
//for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
//$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
//if($b->getID() === AIR){ if($b->getID() === AIR){
// $this->level->setBlock($b, new SugarcaneBlock(), true, false, true); $this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
//break; break;
//} }
//} }
$this->meta = 0; $this->meta = 0;
//$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
}else{ }else{
++$this->meta; ++$this->meta;
//$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
} }
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
@ -85,7 +85,7 @@ class SugarcaneBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === SUGARCANE_BLOCK){ if($down->getID() === SUGARCANE_BLOCK){
//$this->level->setBlock($block, new SugarcaneBlock(), true, false, true); $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
return true; return true;
}elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){ }elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
$block0 = $down->getSide(2); $block0 = $down->getSide(2);
@ -93,8 +93,8 @@ class SugarcaneBlock extends FlowableBlock{
$block2 = $down->getSide(4); $block2 = $down->getSide(4);
$block3 = $down->getSide(5); $block3 = $down->getSide(5);
if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){ if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){
// $this->level->setBlock($block, new SugarcaneBlock(), true, false, true); $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
// $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
} }