sugracane & cactus fixed, fixed sigsegv too early

This commit is contained in:
GameHerobrine 2024-05-25 13:30:14 +03:00
parent b52e050f8c
commit 2ad06e202f
3 changed files with 14 additions and 12 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;
}
}