From 2ad06e202f2a60044da63675082bef6a4662515e Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 25 May 2024 13:30:14 +0300 Subject: [PATCH] sugracane & cactus fixed, fixed sigsegv too early --- src/PocketMinecraftServer.php | 6 ++---- src/material/block/plant/CactusBlock.php | 2 +- src/material/block/plant/SugarcaneBlock.php | 18 +++++++++++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index e0a0a43c..2e35a343 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -194,12 +194,11 @@ class PocketMinecraftServer{ console("[WARNING] Can't keep up! Is the server overloaded?"); } } - + private static $_tmp; /** * @param string $reason */ public function close($reason = "server stop"){ - usleep(2); $this->onShutdown(); if($this->stop !== true){ if(is_int($reason)){ @@ -208,13 +207,12 @@ class PocketMinecraftServer{ if(($this->api instanceof ServerAPI) === true){ if(($this->api->chat instanceof ChatAPI) === true){ $this->api->chat->send(false, "Stopping server..."); - new StopMessageThread($this, "[INFO] Stopping server..."); //broadcast didnt want to send message to discord for some reason + self::$_tmp = new StopMessageThread($this, "[INFO] Stopping server..."); //broadcast didnt want to send message to discord for some reason } } $this->stop = true; $this->trigger("server.close", $reason); $this->interface->close(); - if(!defined("NO_THREADS")){ $this->asyncThread->synchronized(function ($t){ $t->stop = true; diff --git a/src/material/block/plant/CactusBlock.php b/src/material/block/plant/CactusBlock.php index 48d1dffb..b81aaed5 100644 --- a/src/material/block/plant/CactusBlock.php +++ b/src/material/block/plant/CactusBlock.php @@ -39,7 +39,7 @@ class CactusBlock extends TransparentBlock{ } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ - $down = $level->level->getBlockID($x, $y, $z); + $down = $level->level->getBlockID($x, $y - 1, $z); $b0 = $level->level->getBlockID($x, $y, $z - 1); $b1 = $level->level->getBlockID($x, $y, $z + 1); $b2 = $level->level->getBlockID($x - 1, $y, $z); diff --git a/src/material/block/plant/SugarcaneBlock.php b/src/material/block/plant/SugarcaneBlock.php index b7eee207..46bdeced 100644 --- a/src/material/block/plant/SugarcaneBlock.php +++ b/src/material/block/plant/SugarcaneBlock.php @@ -75,13 +75,17 @@ class SugarcaneBlock extends FlowableBlock{ $this->level->setBlock($block, new SugarcaneBlock(), true, false, true); return true; }elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){ - $block0 = $down->getSide(2); - $block1 = $down->getSide(3); - $block2 = $down->getSide(4); - $block3 = $down->getSide(5); - if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){ - $this->level->setBlock($block, new SugarcaneBlock(), true, false, true); - $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); + $level = $this->level; + $x = $this->x; + $y = $this->y; + $z = $this->z; + + $b0 = $level->level->getBlockID($x, $y - 1, $z - 1); + $b1 = $level->level->getBlockID($x, $y - 1, $z + 1); + $b2 = $level->level->getBlockID($x - 1, $y - 1, $z); + $b3 = $level->level->getBlockID($x + 1, $y - 1, $z); + if($b0 == WATER || $b0 == STILL_WATER || $b1 == WATER || $b1 == STILL_WATER || $b2 == WATER || $b2 == STILL_WATER || $b3 == WATER || $b3 == STILL_WATER){ + $level->fastSetBlockUpdate($block->x, $block->y, $block->z, SUGARCANE_BLOCK, 0, true); return true; } }