fixed sapling growth & sugarcane

This commit is contained in:
GameHerobrine 2023-06-28 22:43:34 +03:00
parent 6d1d7cb8a5
commit 83dad024b1
4 changed files with 16 additions and 17 deletions

View file

@ -47,22 +47,21 @@ class SaplingBlock extends FlowableBlock{
$this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL;
}
}elseif($type === BLOCK_UPDATE_RANDOM){ //Growth
if(mt_rand(1,7) === 1){
if(($this->meta & 0x08) === 0x08){
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
}else{
$this->meta |= 0x08;
$this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM;
}
}else{
return BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public static function onRandomTick(Level $level, $x, $y, $z){
if(mt_rand(1,7) === 1){
$meta = $level->level->getBlockDamage($x, $y, $z);
if(($meta & 0x08) === 0x08){
TreeObject::growTree($level, new Vector3($x, $y, $z), new Random(), $meta & 0x03);
}else{
$meta |= 0x08;
$level->fastSetBlockUpdate($x, $y, $z, SAPLING, $meta);
//$level->setBlock($this, $this, true, false, true);
}
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, $this->meta & 0x03, 1),

View file

@ -64,11 +64,12 @@ class SugarcaneBlock extends FlowableBlock{
$id = $b[0];
$meta = $b[1];
if($underID !== SUGARCANE_BLOCK){
if($meta == 0x0F){
if($meta === 0x0F){
for($yy = 1; $yy < 3; ++$yy){
$bID = $level->level->getBlockID($x, $y + $yy, $z);
if($bID === AIR){
$level->setBlock(new Position($x, $y, $z, $level), new SugarcaneBlock(), true, false, true);
//$level->setBlock(new Position($x, $y, $z, $level), new SugarcaneBlock(), true, false, true);
$level->fastSetBlockUpdate($x, $y + $yy, $z, SUGARCANE_BLOCK, 0);
}
}
$meta = 0;
@ -76,7 +77,6 @@ class SugarcaneBlock extends FlowableBlock{
}else{
$level->fastSetBlockUpdate($x, $y, $z, $id, $meta + 1);
}
return BLOCK_UPDATE_RANDOM;
}
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -74,7 +74,6 @@ abstract class ProtocolInfo{
}
/*Unused:
* 0xb5
* 0xb9
* 0x96
* 0x17
* 0x14

View file

@ -19,6 +19,7 @@ class Level{
FARMLAND => true,
GLOWING_REDSTONE_ORE => true,
BEETROOT_BLOCK => true,
SAPLING => true,
CACTUS => true,
CARROT_BLOCK => true,
MELON_STEM => true,