From 1fd52e82a5a48e3ae56484768e1b9e8a65b95a3b Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:44:41 +0800 Subject: [PATCH 1/5] Level: remove useless var --- src/world/Level.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/world/Level.php b/src/world/Level.php index 7f2b4bfc..ea5d1ad9 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -395,7 +395,6 @@ class Level{ if(count($this->changedCount) > 0){ arsort($this->changedCount); - $resendChunks = []; $reorder = false; foreach($this->changedCount as $index => $count){ if($count < 582){//Optimal value, calculated using the relation between minichunks and single packets From 6fb46ccfae863a6eb8c6241da1fccc6e3f39f2bf Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:48:33 +0800 Subject: [PATCH 2/5] remove useless parameters --- src/API/BanAPI.php | 2 +- src/API/EntityAPI.php | 2 +- src/API/PlayerAPI.php | 2 +- src/entity/Living.php | 2 +- src/entity/object/Minecart.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/API/BanAPI.php b/src/API/BanAPI.php index efc80b49..81082cee 100644 --- a/src/API/BanAPI.php +++ b/src/API/BanAPI.php @@ -161,7 +161,7 @@ class BanAPI{ $player = $this->server->api->player->get($user); if(!($player instanceof Player)){ $this->ops->set($user); - $this->ops->save($user); + $this->ops->save(); $output .= $user . " is now op\n"; break; } diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index 5167617f..6d64f453 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -150,7 +150,7 @@ class EntityAPI{ "y" => $pos->y, "z" => $pos->z ] + $data); - $this->spawnToAll($entity, $pos->level); + $this->spawnToAll($entity); } public function getNextEID(){ diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 613c0736..0d7311ae 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -12,7 +12,7 @@ class PlayerAPI{ $this->server->addHandler("player.death", [$this, "handle"], 1); $this->registerCmd("list"); $this->registerCmd("kill", ""); - $this->registerCmd("gamemode", " [player]", [$this, "commandHandler"]); + $this->registerCmd("gamemode", " [player]"); $this->registerCmd("tp", "[target player] OR /tp [target player] "); $this->registerCmd("spawnpoint", "[player] [x] [y] [z]"); $this->registerCmd("spawn"); diff --git a/src/entity/Living.php b/src/entity/Living.php index b2e94bdf..d00f9bfb 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -99,7 +99,7 @@ abstract class Living extends Entity implements Pathfindable{ foreach($this->level->entityListPositioned[$ind] ?? [] as $entid){ if(($this->level->entityList[$entid] ?? null) instanceof Entity){ if($this->level->entityList[$entid]->isPushable() && $bb->intersectsWith($this->level->entityList[$entid]->boundingBox)){ - $this->level->entityList[$entid]->applyCollision($this, true); + $this->level->entityList[$entid]->applyCollision($this); } } } diff --git a/src/entity/object/Minecart.php b/src/entity/object/Minecart.php index f76ddd96..f10ab47e 100644 --- a/src/entity/object/Minecart.php +++ b/src/entity/object/Minecart.php @@ -397,7 +397,7 @@ class Minecart extends Vehicle{ if($e instanceof Entity && $e->eid != $this->eid && $e->eid != $this->linkedEntity){ if($e->isPushable() && $e->boundingBox->intersectsWith($bb)){ if($e->isPlayer()){ - $this->applyCollision($e, true); + $this->applyCollision($e); }else{ $e->applyCollision($this); } From 6034357f781e376e5fb8e8223b8aa65183d53f30 Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:57:51 +0800 Subject: [PATCH 3/5] some clean --- src/recipes/CraftingRecipes.php | 2 +- src/recipes/SmeltingData.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index 204fb77d..47064577 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -295,7 +295,7 @@ class CraftingRecipes{ break; } } - if($continue === false or $craftItem[0] !== $recipe[1][0] or $recipe[1][1] !== $recipe[1][1] or $recipe[1][2] !== $recipe[1][2]){ + if($continue === false or $craftItem[0] !== $recipe[1][0]){ $continue = false; continue; } diff --git a/src/recipes/SmeltingData.php b/src/recipes/SmeltingData.php index aab7c5a6..1dd447d3 100644 --- a/src/recipes/SmeltingData.php +++ b/src/recipes/SmeltingData.php @@ -15,7 +15,6 @@ class SmeltingData{ RED_MUSHROOM => [DYE, 1], RAW_BEEF => [STEAK, 0], RAW_CHICKEN => [COOKED_CHICKEN, 0], - RED_MUSHROOM => [DYE, 1], POTATO => [BAKED_POTATO, 0], ]; } \ No newline at end of file From 7d3fac87ab2b9ee2c219735a85970f23a7cd160f Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:00:15 +0800 Subject: [PATCH 4/5] more ?? --- src/world/generator/SuperflatGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/world/generator/SuperflatGenerator.php b/src/world/generator/SuperflatGenerator.php index 30f8f207..a36d4415 100644 --- a/src/world/generator/SuperflatGenerator.php +++ b/src/world/generator/SuperflatGenerator.php @@ -41,8 +41,8 @@ class SuperflatGenerator implements LevelGenerator{ $preset = explode(";", $preset); $version = (int) $preset[0]; $blocks = @$preset[1]; - $biome = isset($preset[2]) ? $preset[2] : 1; - $options = isset($preset[3]) ? $preset[3] : ""; + $biome = $preset[2] ?? 1; + $options = $preset[3] ?? ""; preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches); $y = 0; $this->structure = []; From 165388c8ae1c03b3b7fdf54ba81666312013ab7c Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:22:31 +0800 Subject: [PATCH 5/5] remove some useless code --- src/PocketMinecraftServer.php | 1 - src/utils/RailLogic.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 1e741b52..42083285 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -591,7 +591,6 @@ class PocketMinecraftServer{ $this->clients[$CID] = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session! $pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_2); $pk->serverID = $this->serverID; - $pk->port = $this->port; $pk->mtuSize = $packet->mtuSize; $pk->ip = $packet->ip; $pk->port = $packet->port; diff --git a/src/utils/RailLogic.php b/src/utils/RailLogic.php index 6f293a5f..92eb05ab 100644 --- a/src/utils/RailLogic.php +++ b/src/utils/RailLogic.php @@ -63,7 +63,7 @@ class RailLogic } public function canConnectTo(RailLogic $rail){ - return $this->connectsTo($rail) || ((count($this->railPositions) == 2 ? false : (empty($this->railPositions) ? true : true))); + return $this->connectsTo($rail) || !(count($this->railPositions) == 2); } public function hasNeighborRail($x, $y, $z){