-
Notifications
You must be signed in to change notification settings - Fork 2
feat: improve detections #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,10 +11,21 @@ With AutoLan, your singleplayer world will automatically open to LAN whenever yo | |||||
| # How to use | ||||||
| Just install the mod, and whenever you open a singleplayer world, AutoLan will start working automatically | ||||||
|
|
||||||
| ## Suggested mod | ||||||
| # Note | ||||||
| As mentioned in the changelog, cheats are always enabled when opening to LAN. This is because I was not able to find a reproducible way to get whether cheats were enabled or not. This is to be addressed in a future update. | ||||||
|
|
||||||
| (Not that it's legal for Minecraft speedrunning anyway.) | ||||||
|
|
||||||
| # Suggested mod | ||||||
| I have another mod, [Force Port](https://modrinth.com/mod/forceport), which allows you to configure which port you want your LAN server to run on. This is useful if you want to run multiple servers at once, or for added security. | ||||||
|
|
||||||
| # Supported versions | ||||||
| AutoTorcher is available for Minecraft versions 1.21.10 and above! | ||||||
| AutoLan supports all versions 1.21.10 and above! | ||||||
|
|
||||||
| Due to the frequency of Minecraft updates now, each Minecraft version has its own .jar file. This is mainly to prevent crashes from each minor update. | ||||||
|
|
||||||
| # Changelog | ||||||
| ## 1.1.0 | ||||||
| - Optimised the CPU usage of the mod | ||||||
| - Open up to lan using world settings for difficulty | ||||||
|
||||||
| - Open up to lan using world settings for difficulty | |
| - Open up to LAN using world settings for game mode |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||||||||||||||||||||||
| package me.imgalvin.autolan; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import net.fabricmc.api.ClientModInitializer; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public class Autolan implements ClientModInitializer { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||
| public void onInitializeClient() { | ||||||||||||||||||||||||||
| System.out.println("Autolan initialised!"); | ||||||||||||||||||||||||||
|
Comment on lines
+5
to
+9
|
||||||||||||||||||||||||||
| public class Autolan implements ClientModInitializer { | |
| @Override | |
| public void onInitializeClient() { | |
| System.out.println("Autolan initialised!"); | |
| public class AutoLan implements ClientModInitializer { | |
| @Override | |
| public void onInitializeClient() { | |
| System.out.println("AutoLan initialised!"); |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spelling of "initialised" should be "initialized" (with a 'z') to maintain consistency with American English spelling conventions used throughout the codebase and standard in software development. For example, the method implemented is "onInitializeClient" (with a 'z'), not "onInitialiseClient".
| System.out.println("Autolan initialised!"); | |
| System.out.println("Autolan initialized!"); |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||||||||||||
| package me.imgalvin.autolan.mixin; | ||||||||||||||
|
|
||||||||||||||
| import net.minecraft.client.MinecraftClient; | ||||||||||||||
| import net.minecraft.client.network.ClientPlayNetworkHandler; | ||||||||||||||
| import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; | ||||||||||||||
| import net.minecraft.server.integrated.IntegratedServer; | ||||||||||||||
| import net.minecraft.text.Text; | ||||||||||||||
| import net.minecraft.world.GameMode; | ||||||||||||||
| import org.spongepowered.asm.mixin.Mixin; | ||||||||||||||
| import org.spongepowered.asm.mixin.Unique; | ||||||||||||||
| import org.spongepowered.asm.mixin.injection.At; | ||||||||||||||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||||||||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||||||||||||
|
|
||||||||||||||
| import static net.minecraft.util.NetworkUtils.findLocalPort; | ||||||||||||||
|
|
||||||||||||||
| @Mixin(ClientPlayNetworkHandler.class) | ||||||||||||||
| public class AutoLanMixin { | ||||||||||||||
|
|
||||||||||||||
| @Unique | ||||||||||||||
| private boolean autolan$opened = false; | ||||||||||||||
|
||||||||||||||
| private boolean autolan$opened = false; | |
| private static boolean autolan$opened = false; |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If retrieving the game mode fails (line 37), the gameMode variable remains null and is passed to server.openToLan(null, true, port) on line 50. While this may work with a fallback to a default game mode in the Minecraft API, the behavior is unclear. Consider either: 1) returning early if gameMode retrieval fails, or 2) providing an explicit fallback game mode, or 3) adding a comment explaining that passing null is intentional and will use a default.
| // Fallback to a sensible default if game mode could not be retrieved | |
| if (gameMode == null) { | |
| gameMode = GameMode.SURVIVAL; | |
| } |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The success message is excessively long and includes implementation notes that should be in the README or changelog, not shown to users every time they open a world. Consider shortening this message to something like "Opened to LAN on port [port] in [gameMode] mode" and move the note about cheats to documentation only.
| Text.literal("Opened to LAN on port " + port + " in mode: " + gameMode + ". Note: LAN worlds automatically open with cheats enabled. This will be addressed in a future update.").formatted(net.minecraft.util.Formatting.GREEN), | |
| Text.literal("Opened to LAN on port " + port + " in " + gameMode + " mode.").formatted(net.minecraft.util.Formatting.GREEN), |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "required": true, | ||
| "minVersion": "0.8", | ||
| "package": "me.imgalvin.autolan.mixin", | ||
| "compatibilityLevel": "JAVA_21", | ||
| "mixins": [], | ||
| "client": [ | ||
| "AutoLanMixin" | ||
| ], | ||
| "server": [], | ||
| "injectors": { | ||
| "defaultRequire": 1 | ||
| }, | ||
| "overwrites": { | ||
| "requireAnnotations": true | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.