From 923dffa3cb0485f9a7629324d9fb592c897c6a77 Mon Sep 17 00:00:00 2001 From: ArkQuark <74979909+ArkQuark@users.noreply.github.com> Date: Thu, 5 May 2022 19:24:27 +0300 Subject: [PATCH] Plant drop fix --- src/material/block/plant/Beetroot.php | 2 +- src/material/block/plant/BrownMushroom.php | 2 +- src/material/block/plant/Cactus.php | 2 +- src/material/block/plant/Carrot.php | 2 +- src/material/block/plant/CyanFlower.php | 2 +- src/material/block/plant/Dandelion.php | 2 +- src/material/block/plant/MelonStem.php | 2 +- src/material/block/plant/PotatoBlock.php | 2 +- src/material/block/plant/PumpkinStem.php | 2 +- src/material/block/plant/RedMushroom.php | 2 +- src/material/block/plant/Sapling.php | 2 +- src/material/block/plant/Sugarcane.php | 2 +- src/material/block/plant/TallGrass.php | 2 ++ src/material/block/plant/Wheat.php | 2 +- 14 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/material/block/plant/Beetroot.php b/src/material/block/plant/Beetroot.php index 207919c4..fecad0da 100644 --- a/src/material/block/plant/Beetroot.php +++ b/src/material/block/plant/Beetroot.php @@ -51,7 +51,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 - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(BEETROOT_SEEDS, 0, 1)); + 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/BrownMushroom.php b/src/material/block/plant/BrownMushroom.php index a4796966..fdd43fa7 100644 --- a/src/material/block/plant/BrownMushroom.php +++ b/src/material/block/plant/BrownMushroom.php @@ -28,7 +28,7 @@ class BrownMushroomBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ //Replace with common break method - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); + ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem($this->id)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } diff --git a/src/material/block/plant/Cactus.php b/src/material/block/plant/Cactus.php index ad2202ee..99080aec 100644 --- a/src/material/block/plant/Cactus.php +++ b/src/material/block/plant/Cactus.php @@ -31,7 +31,7 @@ class CactusBlock extends TransparentBlock{ $down = $this->getSide(0); if($down->getID() !== SAND and $down->getID() !== CACTUS){ //Replace with common break method $this->level->setBlock($this, new AirBlock(), false); - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); + ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id)); return BLOCK_UPDATE_NORMAL; } }elseif($type === BLOCK_UPDATE_RANDOM){ diff --git a/src/material/block/plant/Carrot.php b/src/material/block/plant/Carrot.php index fd1f7839..a6e36da3 100644 --- a/src/material/block/plant/Carrot.php +++ b/src/material/block/plant/Carrot.php @@ -51,7 +51,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 - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(CARROT, 0, 1)); + 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/CyanFlower.php b/src/material/block/plant/CyanFlower.php index 0d35ebe8..8bc3be2d 100644 --- a/src/material/block/plant/CyanFlower.php +++ b/src/material/block/plant/CyanFlower.php @@ -37,7 +37,7 @@ class CyanFlowerBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ //Replace with common break method - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); + ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } diff --git a/src/material/block/plant/Dandelion.php b/src/material/block/plant/Dandelion.php index 75761b87..583ef3a0 100644 --- a/src/material/block/plant/Dandelion.php +++ b/src/material/block/plant/Dandelion.php @@ -37,7 +37,7 @@ class DandelionBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ //Replace with common break method - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); + ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem($this->id)); $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 1ce0641e..bdd32ad2 100644 --- a/src/material/block/plant/MelonStem.php +++ b/src/material/block/plant/MelonStem.php @@ -38,7 +38,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 - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2))); + 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; } diff --git a/src/material/block/plant/PotatoBlock.php b/src/material/block/plant/PotatoBlock.php index f4cbc02d..67fcf239 100644 --- a/src/material/block/plant/PotatoBlock.php +++ b/src/material/block/plant/PotatoBlock.php @@ -51,7 +51,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 - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(POTATO, 0, 1)); + 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 07b799c7..5f47b40c 100644 --- a/src/material/block/plant/PumpkinStem.php +++ b/src/material/block/plant/PumpkinStem.php @@ -38,7 +38,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 - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2))); + 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; } diff --git a/src/material/block/plant/RedMushroom.php b/src/material/block/plant/RedMushroom.php index 288c4f93..84b51c38 100644 --- a/src/material/block/plant/RedMushroom.php +++ b/src/material/block/plant/RedMushroom.php @@ -28,7 +28,7 @@ class RedMushroomBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ //Replace with common break method - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); + ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem($this->id)); $this->level->setBlock($this, new AirBlock(), false); return BLOCK_UPDATE_NORMAL; } diff --git a/src/material/block/plant/Sapling.php b/src/material/block/plant/Sapling.php index 5af0a24f..b3c54273 100644 --- a/src/material/block/plant/Sapling.php +++ b/src/material/block/plant/Sapling.php @@ -62,7 +62,7 @@ class SaplingBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ //Replace with common break method - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->getMetadata())); + ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id, $this->getMetadata())); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } diff --git a/src/material/block/plant/Sugarcane.php b/src/material/block/plant/Sugarcane.php index 0b10d495..3009dd1a 100644 --- a/src/material/block/plant/Sugarcane.php +++ b/src/material/block/plant/Sugarcane.php @@ -56,7 +56,7 @@ 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(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(SUGARCANE)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } diff --git a/src/material/block/plant/TallGrass.php b/src/material/block/plant/TallGrass.php index 2f5293e1..91be948a 100644 --- a/src/material/block/plant/TallGrass.php +++ b/src/material/block/plant/TallGrass.php @@ -36,6 +36,8 @@ class TallGrassBlock extends FlowableBlock{ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ //Replace with common break method $this->level->setBlock($this, new AirBlock(), false, false, true); + $random = mt_rand(0,3); + if($random == 3) ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS)); return BLOCK_UPDATE_NORMAL; } } diff --git a/src/material/block/plant/Wheat.php b/src/material/block/plant/Wheat.php index fc920bb9..c43c80ac 100644 --- a/src/material/block/plant/Wheat.php +++ b/src/material/block/plant/Wheat.php @@ -51,7 +51,7 @@ class WheatBlock extends FlowableBlock{ public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ //Replace with common break method - ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(WHEAT_SEEDS, 0, 1)); + 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; }