From a8d4797cf27047b4589da5a906214d108b5cb6f5 Mon Sep 17 00:00:00 2001 From: ArkQuark <74979909+ArkQuark@users.noreply.github.com> Date: Sun, 5 Jun 2022 17:59:54 +0300 Subject: [PATCH] Plant fix --- src/material/block/{solid => nonfull}/Chest.php | 0 src/material/block/nonfull/Farmland.php | 3 +-- src/material/block/plant/Beetroot.php | 2 +- src/material/block/plant/Carrot.php | 2 +- src/material/block/plant/MelonStem.php | 16 ++++++++++++---- src/material/block/plant/PotatoBlock.php | 2 +- src/material/block/plant/PumpkinStem.php | 16 ++++++++++++---- src/material/block/plant/Wheat.php | 5 +++-- 8 files changed, 31 insertions(+), 15 deletions(-) rename src/material/block/{solid => nonfull}/Chest.php (100%) diff --git a/src/material/block/solid/Chest.php b/src/material/block/nonfull/Chest.php similarity index 100% rename from src/material/block/solid/Chest.php rename to src/material/block/nonfull/Chest.php diff --git a/src/material/block/nonfull/Farmland.php b/src/material/block/nonfull/Farmland.php index c2ebf0c3..0a3c3963 100644 --- a/src/material/block/nonfull/Farmland.php +++ b/src/material/block/nonfull/Farmland.php @@ -38,17 +38,16 @@ class FarmlandBlock extends TransparentBlock{ } return false; } - $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); if($type === BLOCK_UPDATE_RANDOM){ if($this->checkWater()){ $this->level->setBlock($this, BlockAPI::get(FARMLAND, 1), true, false, true); return BLOCK_UPDATE_RANDOM; } else{ + if($this->getSide(1)->isFlowable) return BLOCK_UPDATE_RANDOM; $this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true); return BLOCK_UPDATE_RANDOM; } - } return false; } diff --git a/src/material/block/plant/Beetroot.php b/src/material/block/plant/Beetroot.php index 6b5372ab..b9516eea 100644 --- a/src/material/block/plant/Beetroot.php +++ b/src/material/block/plant/Beetroot.php @@ -53,7 +53,7 @@ class BeetrootBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ //Replace with common break method + if($this->getSide(0)->getID() != 60){ ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS, 0, 1)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; diff --git a/src/material/block/plant/Carrot.php b/src/material/block/plant/Carrot.php index ff72b88a..8c39024d 100644 --- a/src/material/block/plant/Carrot.php +++ b/src/material/block/plant/Carrot.php @@ -53,7 +53,7 @@ class CarrotBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ //Replace with common break method + if($this->getSide(0)->getID() != 60){ ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(CARROT, 0, 1)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; diff --git a/src/material/block/plant/MelonStem.php b/src/material/block/plant/MelonStem.php index 3ca92ad9..171eb14e 100644 --- a/src/material/block/plant/MelonStem.php +++ b/src/material/block/plant/MelonStem.php @@ -37,7 +37,7 @@ class MelonStemBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ //Replace with common break method + if($this->getSide(0)->getID() != 60){ ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2))); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; @@ -83,8 +83,16 @@ class MelonStemBlock extends FlowableBlock{ } public function getDrops(Item $item, Player $player){ - return array( - array(MELON_SEEDS, 0, mt_rand(0, 2)), - ); + $drops = array(); + if($this->meta >= 0x07){ + $drops[] = array(MELON_SEEDS, 0, mt_rand(1, 2)); + } + elseif($this->meta >= 0x01 and $this->meta <= 0x07){ + $drops[] = array(MELON_SEEDS, 0, 1); + } + else{ + $drops[] = array(MELON_SEEDS, 0, 0); + } + return $drops; } } \ No newline at end of file diff --git a/src/material/block/plant/PotatoBlock.php b/src/material/block/plant/PotatoBlock.php index 562b7954..01da777c 100644 --- a/src/material/block/plant/PotatoBlock.php +++ b/src/material/block/plant/PotatoBlock.php @@ -53,7 +53,7 @@ class PotatoBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ //Replace with common break method + if($this->getSide(0)->getID() != 60){ ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(POTATO, 0, 1)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; diff --git a/src/material/block/plant/PumpkinStem.php b/src/material/block/plant/PumpkinStem.php index 8e0a2aa1..63bc4b98 100644 --- a/src/material/block/plant/PumpkinStem.php +++ b/src/material/block/plant/PumpkinStem.php @@ -37,7 +37,7 @@ class PumpkinStemBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ //Replace with common break method + if($this->getSide(0)->getID() != 60){ ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2))); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; @@ -83,8 +83,16 @@ class PumpkinStemBlock extends FlowableBlock{ } public function getDrops(Item $item, Player $player){ - return array( - array(PUMPKIN_SEEDS, 0, mt_rand(0, 2)), - ); + $drops = array(); + if($this->meta >= 0x07){ + $drops[] = array(PUMPKIN_SEEDS, 0, mt_rand(1, 2)); + } + elseif($this->meta >= 0x01 and $this->meta <= 0x07){ + $drops[] = array(PUMPKIN_SEEDS, 0, 1); + } + else{ + $drops[] = array(PUMPKIN_SEEDS, 0, 0); + } + return $drops; } } \ No newline at end of file diff --git a/src/material/block/plant/Wheat.php b/src/material/block/plant/Wheat.php index d29b5b6f..baeecc5e 100644 --- a/src/material/block/plant/Wheat.php +++ b/src/material/block/plant/Wheat.php @@ -53,12 +53,13 @@ class WheatBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ //Replace with common break method + if($this->getSide(0)->getID() != 60){ ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS, 0, 1)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } - }elseif($type === BLOCK_UPDATE_RANDOM){ + } + elseif($type === BLOCK_UPDATE_RANDOM){ if(mt_rand(0, 2) == 1){ if($this->meta < 0x07){ ++$this->meta;