From 7d167f70554a78f0171df1ba97744807ff15dbc9 Mon Sep 17 00:00:00 2001 From: yefengeeeeeeeeeee <121912649+yefengeeeeeeeeeee@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:15:26 +0800 Subject: [PATCH 1/6] Bucket Water/Lava can be placed at torch block Vanilla feature --- src/material/item/generic/BucketItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/material/item/generic/BucketItem.php b/src/material/item/generic/BucketItem.php index 79e9d765..a96ede89 100644 --- a/src/material/item/generic/BucketItem.php +++ b/src/material/item/generic/BucketItem.php @@ -39,7 +39,7 @@ class BucketItem extends Item{ return true; } }elseif($this->meta === WATER){ - if($block->getID() === AIR || $block instanceof LiquidBlock){ + if($block->getID() === AIR || $block->getID() === TORCH || $block instanceof LiquidBlock){ $water = new WaterBlock(); $level->setBlock($block, $water, true, false, true); //$water->place($this, $player, $block, $target, $face, $fx, $fy, $fz); @@ -54,7 +54,7 @@ class BucketItem extends Item{ return true; } }elseif($this->meta === LAVA){ - if($block->getID() === AIR || $block instanceof LiquidBlock){ + if($block->getID() === AIR || $block->getID() === TORCH || $block instanceof LiquidBlock){ $lava = new LavaBlock(); $level->setBlock($block, $lava, true, false, true); //$lava->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz); From c984b31c25becd70f95bb1f559751bd980dd01ac Mon Sep 17 00:00:00 2001 From: yefengeeeeeeeeeee <403749250@qq.com> Date: Sat, 28 Mar 2026 15:26:27 +0800 Subject: [PATCH 2/6] Sign should be placable on glass pane, ironbars and stonewalls --- src/material/block/attachable/SignPostBlock.php | 2 +- src/material/block/attachable/WallSignBlock.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/material/block/attachable/SignPostBlock.php b/src/material/block/attachable/SignPostBlock.php index 8a1db4e2..eab861ba 100644 --- a/src/material/block/attachable/SignPostBlock.php +++ b/src/material/block/attachable/SignPostBlock.php @@ -21,7 +21,7 @@ class SignPostBlock extends TransparentBlock{ } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ - if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN) && $face !== 0){ + if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN || $target->getID() === GLASS_PANE || $target->getID() === IRON_BARS || $target->getID() === STONE_WALL) && $face !== 0){ if(!isset(self::$faces[$face])){ $this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F; $this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true); diff --git a/src/material/block/attachable/WallSignBlock.php b/src/material/block/attachable/WallSignBlock.php index 5fe7179d..d92d67ba 100644 --- a/src/material/block/attachable/WallSignBlock.php +++ b/src/material/block/attachable/WallSignBlock.php @@ -23,7 +23,7 @@ class WallSignBlock extends SignPostBlock{ default => WALL_SIGN }; - if(!StaticBlock::getIsSolid($attached) && $attached != SIGN_POST && $attached != WALL_SIGN){ + if(!StaticBlock::getIsSolid($attached) && $attached != SIGN_POST && $attached != WALL_SIGN && $attached != GLASS_PANE && $attached != IRON_BARS && $attached != STONE_WALL){ $level->fastSetBlockUpdate($x, $y, $z, 0, 0, true, true); (ServerAPI::request())->api->entity->drop(new Position($x + 0.5, $y + 0.5, $z + 0.5, $level), BlockAPI::getItem(SIGN, 0, 1)); } From f2dfd91cbdb2e5f8f0aac3babf23ac6e07c4b9bc Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Wed, 22 Apr 2026 10:18:27 +0800 Subject: [PATCH 3/6] Fixed timezone error caused by WMIC deprecation in new Windows --- src/config_post.php | 74 +++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/src/config_post.php b/src/config_post.php index 879a941a..bb7d82ec 100644 --- a/src/config_post.php +++ b/src/config_post.php @@ -39,34 +39,70 @@ function parseOffset(string $offset) : string|false{ if(ini_get("date.timezone") == ""){ //No Timezone set date_default_timezone_set("GMT"); - if(str_contains(" " . strtoupper(php_uname("s")), " WIN")){ - - $regex = '/(UTC)(\+*\-*\d*\d*\:*\d*\d*)/'; + if(str_contains(" " . strtoupper(php_uname("s")), " WIN")){ //windows + $keyPath = 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation'; + $timezone = 'UTC'; //default /* - * wmic timezone get Caption - * Get the timezone offset + * Get the timezone offset through the registry * * Sample Output var_dump - * array(3) { - * [0] => - * string(7) "Caption" - * [1] => - * string(20) "(UTC+09:30) Adelaide" - * [2] => - * string(0) "" - * } + * array(13) { + * [0]=> + * string(0) "" + * [1]=> + * string(71) "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" + * [2]=> + * string(35) " Bias REG_DWORD 0xfffffe20" + * [3]=> + * string(43) " DaylightBias REG_DWORD 0xffffffc4" + * [4]=> + * string(45) " DaylightName REG_SZ @tzres.dll,-571" + * [5]=> + * string(67) " DaylightStart REG_BINARY 00000000000000000000000000000000" + * [6]=> + * string(36) " StandardBias REG_DWORD 0x0" + * [7]=> + * string(45) " StandardName REG_SZ @tzres.dll,-572" + * [8]=> + * string(67) " StandardStart REG_BINARY 00000000000000000000000000000000" + * [9]=> + * string(52) " TimeZoneKeyName REG_SZ China Standard Time" + * [10]=> + * string(51) " DynamicDaylightTimeDisabled REG_DWORD 0x0" + * [11]=> + * string(45) " ActiveTimeBias REG_DWORD 0xfffffe20" + * [12]=> + * string(0) "" + * } */ - exec("wmic timezone get Caption", $output); + exec("reg query " . escapeshellarg($keyPath), $output); - $string = trim(implode("\n", $output)); + foreach($output as $line){ + if(preg_match('/ActiveTimeBias\s+REG_DWORD\s+0x([0-9a-fA-F]+)/', $line, $matches) > 0){ + $offsetMinutes = ((int) hexdec(trim($matches[1]))) << 32 >> 32; //sign int - //Detect the Time Zone string - preg_match($regex, $string, $matches); + if($offsetMinutes === 0){ + break; //UTC + } - if(!isset($matches[2]) or ($timezone = parseOffset($matches[2])) === false){ - $timezone = 'UTC'; + $sign = $offsetMinutes <= 0 ? '+' : '-'; //windows timezone + and - are opposite + $absMinutes = abs($offsetMinutes); + $hours = floor($absMinutes / 60); + $minutes = $absMinutes % 60; + + $offset = sprintf( + "%s%02d:%02d", + $sign, + $hours, + $minutes + ); + + $timezone = parseOffset($offset); + break; + } } + if(date_default_timezone_set($timezone)){ ini_set("date.timezone", $timezone); } From 6f5d62f302c25ffb3f3bc133917fd6d753f23062 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Thu, 14 May 2026 22:56:37 +0300 Subject: [PATCH 4/6] fixed crash exploit --- src/Player.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Player.php b/src/Player.php index 117db768..89b3a716 100755 --- a/src/Player.php +++ b/src/Player.php @@ -2423,8 +2423,24 @@ class Player{ break; } if($this->isSleeping) break; + + + //prevent crash caused by nan values + if(is_nan($packet->x) || is_nan($packet->y) || is_nan($packet->z)){ + ConsoleAPI::warn("{$this->username} Attempted to crash the server using NaN position!"); + $this->close("invalid position"); + break; + } + if(($this->entity instanceof Entity) && $packet->messageIndex > $this->lastMovement){ $this->lastMovement = $packet->messageIndex; + //prevent all movement this far - vanilla collisions break there + //farther distances(like inf) may cause client and server crash + if(abs($packet->x) >= 8388608 || abs($packet->y) >= 8388608 || abs($packet->z) >= 8388608){ + $this->addEntityMovementUpdateToQueue($this->entity); + break; + } + $newPos = new Vector3($packet->x, $packet->y, $packet->z); if($this->forceMovement instanceof Vector3){ if($this->forceMovement->distance($newPos) <= 0.7){ From 171390260dab425b037d82faafdc2659198ffc97 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 16 May 2026 07:01:22 +0300 Subject: [PATCH 5/6] fixed client crash using inf rot, fixed invisibility using nan rot --- src/Player.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Player.php b/src/Player.php index 89b3a716..4ad26a57 100755 --- a/src/Player.php +++ b/src/Player.php @@ -2432,6 +2432,19 @@ class Player{ break; } + if(is_infinite($packet->yaw) || is_infinite($packet->pitch) || is_infinite($packet->bodyYaw)){ + ConsoleAPI::warn("{$this->username} Attempted to crash other clients using INF rotation!"); + $this->close("invalid rotation"); + break; + } + + //doesnt crash anything but allows players to break their model rendering(make them/head invisible) + if(is_nan($packet->yaw) || is_nan($packet->pitch) || is_nan($packet->bodyYaw)){ + ConsoleAPI::warn("{$this->username} Attempted to break their model using NAN rotation!"); + $this->close("invalid rotation"); + break; + } + if(($this->entity instanceof Entity) && $packet->messageIndex > $this->lastMovement){ $this->lastMovement = $packet->messageIndex; //prevent all movement this far - vanilla collisions break there From 11737d0bda4e46acb76612e4a31dec4416275a9c Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 16 May 2026 07:03:36 +0300 Subject: [PATCH 6/6] fixed setBlock with non int coords --- src/entity/ai/tasks/TaskEatTileGoal.php | 8 ++++---- src/pmf/PMFLevel.php | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/entity/ai/tasks/TaskEatTileGoal.php b/src/entity/ai/tasks/TaskEatTileGoal.php index 8bc3766e..a71274e1 100644 --- a/src/entity/ai/tasks/TaskEatTileGoal.php +++ b/src/entity/ai/tasks/TaskEatTileGoal.php @@ -24,14 +24,14 @@ class TaskEatTileGoal extends TaskBase if (--$this->selfCounter == 4) { - $id = $ai->entity->level->level->getBlockID($ai->entity->x, $ai->entity->y, $ai->entity->z); - $idb = $ai->entity->level->level->getBlockID($ai->entity->x, $ai->entity->y - 1, $ai->entity->z); + $id = $ai->entity->level->level->getBlockID((int)$ai->entity->x, (int)$ai->entity->y, (int)$ai->entity->z); + $idb = $ai->entity->level->level->getBlockID((int)$ai->entity->x, (int)$ai->entity->y - 1, (int)$ai->entity->z); if($id === TALL_GRASS){ - $ai->entity->level->fastSetBlockUpdate($ai->entity->x, $ai->entity->y, $ai->entity->z, AIR, 0); + $ai->entity->level->fastSetBlockUpdate((int)$ai->entity->x, (int)$ai->entity->y, (int)$ai->entity->z, AIR, 0); $ai->entity->eatGrass(); }elseif($idb === GRASS){ - $ai->entity->level->fastSetBlockUpdate($ai->entity->x, $ai->entity->y - 1, $ai->entity->z, DIRT, 0); + $ai->entity->level->fastSetBlockUpdate((int)$ai->entity->x, (int)$ai->entity->y - 1, (int)$ai->entity->z, DIRT, 0); $ai->entity->eatGrass(); } } diff --git a/src/pmf/PMFLevel.php b/src/pmf/PMFLevel.php index 0d03bd15..b86a0f28 100644 --- a/src/pmf/PMFLevel.php +++ b/src/pmf/PMFLevel.php @@ -663,9 +663,11 @@ class PMFLevel extends PMF{ }elseif($this->chunks[$index][$Y] === false){ $this->fillMiniChunk($X, $Z, $Y); } - $aX = $x - ($X << 4); - $aZ = $z - ($Z << 4); - $aY = $y - ($Y << 4); + + $aX = $x & 0xf; + $aZ = $z & 0xf; + $aY = $y & 0xf; + $bindex = (int) ($aY + ($aX << 5) + ($aZ << 9)); $mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9)); $old_b = ord($this->chunks[$index][$Y][$bindex]);