From 57d3dbcfc476f09aecdb9d0ec348841efdfe4b9e Mon Sep 17 00:00:00 2001 From: Sunch233 <2125696621@qq.com> Date: Wed, 14 Aug 2024 10:56:42 +0800 Subject: [PATCH 1/3] Flower: fixed cant being able to placeside by side --- src/material/block/plant/CyanFlowerBlock.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/material/block/plant/CyanFlowerBlock.php b/src/material/block/plant/CyanFlowerBlock.php index 44529373..4bd109e9 100644 --- a/src/material/block/plant/CyanFlowerBlock.php +++ b/src/material/block/plant/CyanFlowerBlock.php @@ -14,7 +14,7 @@ class CyanFlowerBlock extends FlowableBlock{ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); - if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ + if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){ $this->level->setBlock($block, $this, true, false, true); return true; } @@ -22,7 +22,8 @@ class CyanFlowerBlock extends FlowableBlock{ } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ - if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method + $downId = $level->level->getBlockID($x, $y - 1, $z); + if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(CYAN_FLOWER)); $level->fastSetBlockUpdate($x, $y, $z, 0, 0); } From f66b6adfa161ace0a60443e7e3c4a73683a4d82f Mon Sep 17 00:00:00 2001 From: Sunch233 <2125696621@qq.com> Date: Wed, 14 Aug 2024 11:05:28 +0800 Subject: [PATCH 2/3] Dandelion: fixed cant being able to placeside by side --- src/material/block/plant/CyanFlowerBlock.php | 13 +++++++------ src/material/block/plant/DandelionBlock.php | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/material/block/plant/CyanFlowerBlock.php b/src/material/block/plant/CyanFlowerBlock.php index 4bd109e9..8486ede6 100644 --- a/src/material/block/plant/CyanFlowerBlock.php +++ b/src/material/block/plant/CyanFlowerBlock.php @@ -11,16 +11,17 @@ class CyanFlowerBlock extends FlowableBlock{ public static function getAABB(Level $level, $x, $y, $z){ return null; } - + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ - $down = $this->getSide(0); - if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){ - $this->level->setBlock($block, $this, true, false, true); - return true; - } + $down = $this->getSide(0); + if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){ + $this->level->setBlock($block, $this, true, false, true); + return true; + } return false; } + public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ $downId = $level->level->getBlockID($x, $y - 1, $z); if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method diff --git a/src/material/block/plant/DandelionBlock.php b/src/material/block/plant/DandelionBlock.php index 1d82b7e7..57f5ef64 100644 --- a/src/material/block/plant/DandelionBlock.php +++ b/src/material/block/plant/DandelionBlock.php @@ -11,17 +11,18 @@ class DandelionBlock extends FlowableBlock{ return null; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ - $down = $this->getSide(0); - if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ - $this->level->setBlock($block, $this, true, false, true); - return true; - } + $down = $this->getSide(0); + if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){ + $this->level->setBlock($block, $this, true, false, true); + return true; + } return false; } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ - if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method - ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(DANDELION)); + $downId = $level->level->getBlockID($x, $y - 1, $z); + if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method + ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(CYAN_FLOWER)); $level->fastSetBlockUpdate($x, $y, $z, 0, 0); } } From e594fc2f8cdc5afd3d5915602040f363bd42a512 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Wed, 14 Aug 2024 06:20:21 +0300 Subject: [PATCH 3/3] fixed placement on farmland of sapling and tallgrass --- src/material/block/plant/SaplingBlock.php | 5 +++-- src/material/block/plant/TallGrassBlock.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/material/block/plant/SaplingBlock.php b/src/material/block/plant/SaplingBlock.php index fafa4f57..a6acde15 100644 --- a/src/material/block/plant/SaplingBlock.php +++ b/src/material/block/plant/SaplingBlock.php @@ -44,7 +44,8 @@ class SaplingBlock extends FlowableBlock{ return false; } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ - if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method + $downID = $level->level->getBlockID($x, $y - 1, $z); + if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method [$id, $meta] = $level->level->getBlock($x, $y, $z); ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem($id, $meta)); $level->fastSetBlockUpdate($x, $y, $z, 0, 0); @@ -67,4 +68,4 @@ class SaplingBlock extends FlowableBlock{ array($this->id, $this->meta & 0x03, 1), ); } -} \ No newline at end of file +} diff --git a/src/material/block/plant/TallGrassBlock.php b/src/material/block/plant/TallGrassBlock.php index b60bbe42..df8ce39f 100644 --- a/src/material/block/plant/TallGrassBlock.php +++ b/src/material/block/plant/TallGrassBlock.php @@ -15,7 +15,8 @@ class TallGrassBlock extends FlowableBlock{ } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ - if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method + $downID = $level->level->getBlockID($x, $y - 1, $z); + if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(WHEAT_SEEDS)); $level->fastSetBlockUpdate($x, $y, $z, 0, 0); } @@ -34,7 +35,7 @@ class TallGrassBlock extends FlowableBlock{ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); - if($down->getID() == 2 or $down->getID() == 3){ + if($down->getID() == GRASS or $down->getID() == DIRT || $down->getID() == FARMLAND){ $this->level->setBlock($block, $this, true, false, true); return true; }