-
Notifications
You must be signed in to change notification settings - Fork 2
chore: update to 26.1 snapshots #6
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b68bbf4
chore(ci): standardize workflow and Gradle for Java 25
galvincraft-bot 87526ac
Merge pull request #5 from GalvinCraft/ci/chore-updates-2026-01-24
GalvinPython d6555d1
backing up before moving to mixins
GalvinPython fc7ae50
moved to mixins
GalvinPython 425a85d
remove old code
GalvinPython f076499
add logging & make mixin more thread safe
GalvinPython File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,18 @@ | ||
| # Done to increase the memory available to gradle. | ||
| org.gradle.jvmargs=-Xmx1G | ||
| # Done to increase the memory available to Gradle. | ||
| org.gradle.jvmargs=-Xmx2G | ||
| org.gradle.parallel=true | ||
|
|
||
| # IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349 | ||
| org.gradle.configuration-cache=false | ||
|
|
||
| # Fabric Properties | ||
| # check these on https://fabricmc.net/develop | ||
| minecraft_version=1.21.10 | ||
| yarn_mappings=1.21.10+build.2 | ||
| loader_version=0.17.3 | ||
| loom_version=1.12-SNAPSHOT | ||
|
|
||
| minecraft_version=26.1-snapshot-6 | ||
| loader_version=0.18.4 | ||
| loom_version=1.15-SNAPSHOT | ||
|
|
||
| # Mod Properties | ||
| mod_version=1.0.0+1.21.10 | ||
| mod_version=1.0.1-beta+26.1-snapshots_fabric | ||
| maven_group=me.imgalvin | ||
| archives_base_name=auto-lan | ||
|
|
||
| # Dependencies | ||
| fabric_version=0.137.0+1.21.10 | ||
| fabric_api_version=0.143.2+26.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,16 @@ | ||
| package me.imgalvin; | ||
|
|
||
| import net.fabricmc.api.ClientModInitializer; | ||
| import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
| import net.minecraft.server.integrated.IntegratedServer; | ||
| import net.minecraft.text.Text; | ||
| import net.minecraft.world.GameMode; | ||
|
|
||
| import static net.minecraft.util.NetworkUtils.findLocalPort; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class Autolan implements ClientModInitializer { | ||
| private boolean opened = false; | ||
| public static final String MOD_ID = "AutoLan"; | ||
| public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); | ||
|
|
||
| @Override | ||
| public void onInitializeClient() { | ||
| ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
| if (!opened && client.player != null && client.getServer() != null) { | ||
| IntegratedServer server = client.getServer(); | ||
|
|
||
| if (server.isSingleplayer()) { | ||
| int port = findLocalPort(); | ||
| server.openToLan(GameMode.CREATIVE, true, port); | ||
| client.player.sendMessage(Text.of("§aOpened to LAN on port " + port), false); | ||
| opened = true; | ||
| } | ||
| } | ||
| }); | ||
| LOGGER.info("AutoLan initialized!"); | ||
| } | ||
|
GalvinPython marked this conversation as resolved.
|
||
| } | ||
68 changes: 68 additions & 0 deletions
68
src/main/java/me/imgalvin/Mixin/PublishLANServerMixin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package me.imgalvin.Mixin; | ||
|
|
||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.network.chat.Component; | ||
| import net.minecraft.server.MinecraftServer; | ||
| import net.minecraft.util.HttpUtil; | ||
| import net.minecraft.world.level.GameType; | ||
| import org.jspecify.annotations.Nullable; | ||
| import org.slf4j.Logger; | ||
| import org.spongepowered.asm.mixin.Final; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
| 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 java.util.concurrent.Executors; | ||
| import java.util.concurrent.ScheduledExecutorService; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| @Mixin(MinecraftServer.class) | ||
| public abstract class PublishLANServerMixin { | ||
| @Shadow | ||
| public abstract boolean publishServer(@Nullable GameType gameMode, boolean allowCommands, int port); | ||
|
|
||
| @Shadow | ||
| @Final | ||
| private static Logger LOGGER; | ||
| // Scheduler to check for connection readiness without blocking the main thread | ||
| @Unique | ||
| private static final ScheduledExecutorService SCHEDULER = Executors.newSingleThreadScheduledExecutor(); | ||
|
|
||
| // Inject at the end of loadLevel | ||
| @Inject(at = @At("TAIL"), method = "loadLevel") | ||
| private void init(CallbackInfo info) { | ||
| MinecraftServer server = (MinecraftServer) (Object) this; | ||
| attemptLanPublish(server); | ||
| } | ||
|
|
||
| @Unique | ||
| private void attemptLanPublish(MinecraftServer server) { | ||
| // Schedule a check every 500ms | ||
| SCHEDULER.scheduleAtFixedRate(() -> { | ||
| // Check if the connection is ready | ||
| if (Minecraft.getInstance().getConnection() != null) { | ||
| // Back to the main server thread for the actual logic | ||
| server.execute(() -> { | ||
| int port = HttpUtil.getAvailablePort(); | ||
| boolean success = publishServer(GameType.CREATIVE, true, port); | ||
|
|
||
| if (success) { | ||
| server.getPlayerList().broadcastSystemMessage( | ||
| Component.literal("§aOpened to LAN on port " + port), false); | ||
| LOGGER.info("Successfully opened to LAN on port {}", port); | ||
| } else { | ||
| server.getPlayerList().broadcastSystemMessage( | ||
| Component.literal("§cFailed to open to LAN!"), false); | ||
| LOGGER.error("Failed to open to LAN on port {}", port); | ||
| } | ||
| }); | ||
|
|
||
| // End scheduler | ||
| throw new RuntimeException("attemptLanPublish Complete"); | ||
| } | ||
| }, 0, 500, TimeUnit.MILLISECONDS); | ||
| } | ||
|
GalvinPython marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "required": true, | ||
| "package": "me.imgalvin.Mixin", | ||
| "compatibilityLevel": "JAVA_25", | ||
| "client": [ | ||
| "PublishLANServerMixin" | ||
| ], | ||
| "injectors": { | ||
| "defaultRequire": 1 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.