Update Sugarcane.php

This commit is contained in:
kotyaralih 2021-12-22 12:23:15 -08:00
parent f73e7f8504
commit cf9023d3c0

View file

@ -37,12 +37,12 @@ class SugarcaneBlock extends FlowableBlock{
for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){
//$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
break;
}
}
$this->meta = 0;
//$this->level->setBlock($this, $this, true, false, true);
$this->level->setBlock($this, $this, true, false, true);
}
if(($player->gamemode & 0x01) === 0){
$item->count--;
@ -56,25 +56,25 @@ class SugarcaneBlock extends FlowableBlock{
if($type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
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);
return BLOCK_UPDATE_NORMAL;
}
}elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
if($this->meta === 0x0F){
//for($y = 1; $y < 3; ++$y){
//$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
//if($b->getID() === AIR){
// $this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
//break;
//}
//}
for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){
$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
break;
}
}
$this->meta = 0;
//$this->level->setBlock($this, $this, true, false, true);
$this->level->setBlock($this, $this, true, false, true);
}else{
++$this->meta;
//$this->level->setBlock($this, $this, true, false, true);
$this->level->setBlock($this, $this, true, false, true);
}
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){
$down = $this->getSide(0);
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;
}elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
$block0 = $down->getSide(2);
@ -93,8 +93,8 @@ class SugarcaneBlock extends FlowableBlock{
$block2 = $down->getSide(4);
$block3 = $down->getSide(5);
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->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
$this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true;
}
}