Skip to content

Commit

Permalink
Update to 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed May 11, 2024
1 parent 81a46a5 commit 505921f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.11

#Fabric api
fabric_version=0.92.1+1.20.4
# Fabric API
fabric_version=0.98.0+1.20.6

# Mod Properties
mod_id=autoreconnect
mod_name=AutoReconnect
mod_version=1.20.4-2.3.0
mod_version=1.20.6-2.3.0
maven_group=autoreconnect
archives_base_name=autoreconnect

# Dependencies
modmenu_version=9.0.0
clothconfig_version=13.0.121
modmenu_version=10.0.0-beta.1
clothconfig_version=14.0.126
10 changes: 9 additions & 1 deletion src/main/java/autoreconnect/config/AutoReconnectConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ public static AutoReconnectConfig getInstance() {
}

public static void load() {
var targetFile = FabricLoader.getInstance().getConfigDir().resolve(FILE_NAME);
if (!targetFile.toFile().exists()) {
LogUtils.getLogger().info("AutoReconnect config does not yet exist, generating new file");
instance = new AutoReconnectConfig();
instance.save();
return;
}

try {
instance = GSON.fromJson(
Files.readString(FabricLoader.getInstance().getConfigDir().resolve(FILE_NAME)),
Files.readString(targetFile),
AutoReconnectConfig.class);
instance.validate();
} catch (IOException | JsonSyntaxException ex) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/autoreconnect/mixin/ConnectScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ConnectScreen;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.TransferState;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -14,8 +15,8 @@
@Mixin(ConnectScreen.class)
public class ConnectScreenMixin {
@Inject(at = @At("HEAD"), method = "connect")
private void connect(Minecraft minecraft, ServerAddress serverAddress, ServerData serverData, CallbackInfo ci) {
private void connect(Minecraft minecraft, ServerAddress serverAddress, ServerData serverData, TransferState transferState, CallbackInfo ci) {
if (serverData == null) return;
AutoReconnect.getInstance().setReconnectHandler(new MultiplayerReconnectStrategy(serverData));
AutoReconnect.getInstance().setReconnectHandler(new MultiplayerReconnectStrategy(serverData, transferState));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.TransferState;
import net.minecraft.client.multiplayer.resolver.ServerAddress;

public class MultiplayerReconnectStrategy extends ReconnectStrategy {
private final ServerData serverData;
private final TransferState transferState;

public MultiplayerReconnectStrategy(ServerData serverData) {
public MultiplayerReconnectStrategy(ServerData serverData, TransferState transferState) {
this.serverData = serverData;
this.transferState = transferState;
}

@Override
Expand All @@ -29,7 +32,8 @@ public void reconnect() {
Minecraft.getInstance(),
ServerAddress.parseString(serverData.ip),
serverData,
false
false,
transferState
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String getName() {
public void reconnect() {
var minecraft = Minecraft.getInstance();
if (!minecraft.getLevelSource().levelExists(worldName)) return;
minecraft.createWorldOpenFlows().checkForBackupAndLoad(worldName, () -> {
minecraft.createWorldOpenFlows().openWorld(worldName, () -> {
minecraft.setScreen(new TitleScreen());
});
}
Expand Down

0 comments on commit 505921f

Please sign in to comment.