cocoa beans can grow now

This commit is contained in:
GameHerobrine 2023-03-02 08:46:34 +03:00
parent fc93387ff1
commit 09e9c4d1a3

View file

@ -24,12 +24,9 @@ class CocoaBlock extends FlowableBlock{
return false; return false;
} }
/*public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($this->getGrowthStage() < 0x02 && $item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta++; $this->meta += 0b0100; //TODO limit
if($this->meta > 0x02){
$this->meta = 0x02;
}
$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){
$player->removeItem(DYE, 0x0F, 1); $player->removeItem(DYE, 0x0F, 1);
@ -42,8 +39,8 @@ class CocoaBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_RANDOM){ if($type === BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){ if(mt_rand(0, 2) == 1){
if($this->meta < 0x03){ if($this->getGrowthStage() < 0x02){
++$this->meta; $this->meta += 0b0100;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
@ -52,11 +49,13 @@ class CocoaBlock extends FlowableBlock{
} }
} }
return false; return false;
}*/ }
public function getGrowthStage(){
return $this->meta >> 2;
}
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
$drops = []; $drops = [];
if($this->meta >= 0x02){ //hum? if($this->getGrowthStage() >= 0x02){ //hum?
$drops[] = [DYE, 3, mt_rand(1, 4)]; $drops[] = [DYE, 3, mt_rand(1, 4)];
}else{ }else{
$drops[] = [DYE, 3, 1]; $drops[] = [DYE, 3, 1];