diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientPlayerInteractionManager1_18_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientPlayerInteractionManager1_18_2.java index 3ffc43e5..75589173 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientPlayerInteractionManager1_18_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientPlayerInteractionManager1_18_2.java @@ -33,11 +33,11 @@ import net.raphimc.vialoader.util.VersionEnum; import org.apache.commons.lang3.tuple.Pair; public class ClientPlayerInteractionManager1_18_2 { - private static final Object2ObjectLinkedOpenHashMap, Pair> UN_ACKED_ACTIONS = new Object2ObjectLinkedOpenHashMap<>(); - public static void trackPlayerAction(final PlayerActionC2SPacket.Action action, final BlockPos blockPos) { + private final Object2ObjectLinkedOpenHashMap, Pair> unAckedActions = new Object2ObjectLinkedOpenHashMap<>(); + + public void trackPlayerAction(final PlayerActionC2SPacket.Action action, final BlockPos blockPos) { final var player = MinecraftClient.getInstance().player; - if (player == null) return; final Vec2f rotation; if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_1)) { @@ -45,15 +45,15 @@ public class ClientPlayerInteractionManager1_18_2 { } else { rotation = new Vec2f(player.getYaw(), player.getPitch()); } - UN_ACKED_ACTIONS.put(Pair.of(blockPos, action), Pair.of(player.getPos(), rotation)); + unAckedActions.put(Pair.of(blockPos, action), Pair.of(player.getPos(), rotation)); } - public static void handleBlockBreakAck(final BlockPos blockPos, final BlockState expectedState, final PlayerActionC2SPacket.Action action, final boolean allGood) { + public void handleBlockBreakAck(final BlockPos blockPos, final BlockState expectedState, final PlayerActionC2SPacket.Action action, final boolean allGood) { final var player = MinecraftClient.getInstance().player; if (player == null) return; final var world = MinecraftClient.getInstance().getNetworkHandler().getWorld(); - final var oldPlayerState = UN_ACKED_ACTIONS.remove(Pair.of(blockPos, action)); + final var oldPlayerState = unAckedActions.remove(Pair.of(blockPos, action)); final var actualState = world.getBlockState(blockPos); if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2))) { @@ -68,14 +68,10 @@ public class ClientPlayerInteractionManager1_18_2 { } } - while (UN_ACKED_ACTIONS.size() >= 50) { - ViaFabricPlus.global().getLogger().warn("Too many unacked block actions, dropping {}", UN_ACKED_ACTIONS.firstKey()); - UN_ACKED_ACTIONS.removeFirst(); + while (unAckedActions.size() >= 50) { + ViaFabricPlus.global().getLogger().warn("Too many unacked block actions, dropping {}", unAckedActions.firstKey()); + unAckedActions.removeFirst(); } } - public static void clearUnackedActions() { - UN_ACKED_ACTIONS.clear(); - } - } diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java index fd507e19..03db0207 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java @@ -20,15 +20,13 @@ package de.florianmichael.viafabricplus.fixes; import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback; -import de.florianmichael.viafabricplus.event.DisconnectCallback; import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback; import de.florianmichael.viafabricplus.event.PostGameLoadCallback; -import de.florianmichael.viafabricplus.fixes.data.ResourcePackHeaderDiff; -import de.florianmichael.viafabricplus.fixes.entity.EntityDimensionReplacements; import de.florianmichael.viafabricplus.fixes.classic.CPEAdditions; import de.florianmichael.viafabricplus.fixes.classic.GridItemSelectionScreen; +import de.florianmichael.viafabricplus.fixes.data.ResourcePackHeaderDiff; +import de.florianmichael.viafabricplus.fixes.entity.EntityDimensionReplacements; import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin; -import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider; import net.minecraft.block.*; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.FontStorage; @@ -77,17 +75,6 @@ public class ClientsideFixes { ArmorHudEmulation1_8.init(); }); - DisconnectCallback.EVENT.register(() -> { - // Reset the MP-pass - ViaFabricPlusClassicMPPassProvider.classiCubeMPPass = null; - - // Remove all previous unacked player actions - ClientPlayerInteractionManager1_18_2.clearUnackedActions(); - - // Rebuilt the item selection screen grid next time the screen is opened - GridItemSelectionScreen.INSTANCE.itemGrid = null; - }); - // Reloads some clientside stuff when the protocol version changes ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> { // Calculates the current chat length limit diff --git a/src/main/java/de/florianmichael/viafabricplus/event/DisconnectCallback.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IClientPlayerInteractionManager.java similarity index 62% rename from src/main/java/de/florianmichael/viafabricplus/event/DisconnectCallback.java rename to src/main/java/de/florianmichael/viafabricplus/injection/access/IClientPlayerInteractionManager.java index db662459..bcfad7bf 100644 --- a/src/main/java/de/florianmichael/viafabricplus/event/DisconnectCallback.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IClientPlayerInteractionManager.java @@ -17,21 +17,12 @@ * along with this program. If not, see . */ -package de.florianmichael.viafabricplus.event; +package de.florianmichael.viafabricplus.injection.access; -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; +import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2; -/** - * This event is fired when the user disconnects from a server. - */ -public interface DisconnectCallback { +public interface IClientPlayerInteractionManager { - Event EVENT = EventFactory.createArrayBacked(DisconnectCallback.class, listeners -> () -> { - for (DisconnectCallback listener : listeners) { - listener.onDisconnect(); - } - }); + ClientPlayerInteractionManager1_18_2 viaFabricPlus$get1_18_2InteractionManager(); - void onDisconnect(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java index 9fa2d8a3..d72dd8fa 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java @@ -21,7 +21,6 @@ package de.florianmichael.viafabricplus.injection.mixin.base.connect; import com.llamalad7.mixinextras.sugar.Local; import com.viaversion.viaversion.api.connection.UserConnection; -import de.florianmichael.viafabricplus.event.DisconnectCallback; import de.florianmichael.viafabricplus.injection.access.IClientConnection; import de.florianmichael.viafabricplus.injection.access.IPerformanceLog; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; @@ -37,7 +36,6 @@ import net.minecraft.network.ClientConnection; import net.minecraft.network.encryption.PacketDecryptor; import net.minecraft.network.encryption.PacketEncryptor; import net.minecraft.network.packet.Packet; -import net.minecraft.text.Text; import net.minecraft.util.profiler.PerformanceLog; import net.raphimc.vialoader.netty.CompressionReorderEvent; import net.raphimc.vialoader.netty.VLLegacyPipeline; @@ -171,11 +169,6 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler< return instance.connect(inetHost, inetPort); } - @Inject(method = "disconnect", at = @At("RETURN")) - private void callDisconnectCallback(Text disconnectReason, CallbackInfo ci) { - DisconnectCallback.EVENT.invoker().onDisconnect(); - } - @Unique public void viaFabricPlus$setupPreNettyEncryption(final Cipher encryptionCipher) { if (encryptionCipher == null) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java index 824670b3..b4395a53 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java @@ -19,6 +19,8 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.injection.access.IServerInfo; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; @@ -26,19 +28,19 @@ import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabric import de.florianmichael.viafabricplus.protocolhack.util.ProtocolVersionDetector; import de.florianmichael.viafabricplus.protocolhack.util.VersionEnumExtension; import de.florianmichael.viafabricplus.settings.impl.AuthenticationSettings; +import io.netty.channel.ChannelFuture; import net.minecraft.client.gui.screen.ConnectScreen; import net.minecraft.client.network.ServerInfo; import net.minecraft.client.session.Session; +import net.minecraft.network.ClientConnection; import net.minecraft.text.Text; import net.raphimc.vialoader.util.VersionEnum; 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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.net.InetSocketAddress; @@ -53,9 +55,34 @@ public abstract class MixinConnectScreen_1 { @Final ConnectScreen field_2416; + @Unique + private boolean viaFabricPlus$useClassiCubeAccount; + + @WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;")) + private ChannelFuture setServerInfoAndHandleDisconnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, Operation original) { + final IServerInfo mixinServerInfo = (IServerInfo) this.field_40415; + + VersionEnum targetVersion = ProtocolHack.getTargetVersion(); + if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) { + targetVersion = mixinServerInfo.viaFabricPlus$forcedVersion(); + } + if (targetVersion == VersionEnumExtension.AUTO_DETECT) { + this.field_2416.setStatus(Text.translatable("base.viafabricplus.detecting_server_version")); + targetVersion = ProtocolVersionDetector.get(address, ProtocolHack.NATIVE_VERSION); + } + ProtocolHack.setTargetVersion(targetVersion, true); + + this.viaFabricPlus$useClassiCubeAccount = AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classicMpPassForNextJoin != null; + + final ChannelFuture future = original.call(address, useEpoll, connection); + future.channel().closeFuture().addListener(channel -> ProtocolHack.resetPreviousVersion()); + + return future; + } + @Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/session/Session;getUsername()Ljava/lang/String;")) private String useClassiCubeUsername(Session instance) { - if (AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classiCubeMPPass != null) { + if (this.viaFabricPlus$useClassiCubeAccount) { final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); if (account != null) { return account.username(); @@ -65,22 +92,4 @@ public abstract class MixinConnectScreen_1 { return instance.getUsername(); } - @SuppressWarnings("InvalidInjectorMethodSignature") - @Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) - private void setServerInfo(CallbackInfo ci, InetSocketAddress inetSocketAddress) { - final IServerInfo mixinServerInfo = (IServerInfo) this.field_40415; - VersionEnum targetVersion = ProtocolHack.getTargetVersion(); - - if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) { - targetVersion = mixinServerInfo.viaFabricPlus$forcedVersion(); - } - - if (targetVersion == VersionEnumExtension.AUTO_DETECT) { - this.field_2416.setStatus(Text.translatable("base.viafabricplus.detecting_server_version")); - targetVersion = ProtocolVersionDetector.get(inetSocketAddress, ProtocolHack.NATIVE_VERSION); - } - - ProtocolHack.setTargetVersion(targetVersion, true); - } - } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java index ad06a5a4..421ad555 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_ import de.florianmichael.viafabricplus.fixes.ActionResultException1_12_2; import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2; import de.florianmichael.viafabricplus.injection.access.IClientConnection; +import de.florianmichael.viafabricplus.injection.access.IClientPlayerInteractionManager; import de.florianmichael.viafabricplus.injection.access.IScreenHandler; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusHandItemProvider; @@ -72,7 +73,7 @@ import java.util.List; @SuppressWarnings("DataFlowIssue") @Mixin(ClientPlayerInteractionManager.class) -public abstract class MixinClientPlayerInteractionManager { +public abstract class MixinClientPlayerInteractionManager implements IClientPlayerInteractionManager { @Shadow @Final @@ -103,6 +104,9 @@ public abstract class MixinClientPlayerInteractionManager { @Unique private List viaFabricPlus$oldItems; + @Unique + private final ClientPlayerInteractionManager1_18_2 viaFabricPlus$1_18_2InteractionManager = new ClientPlayerInteractionManager1_18_2(); + @Inject(method = "getBlockBreakingProgress", at = @At("HEAD"), cancellable = true) private void changeCalculation(CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) { @@ -113,14 +117,14 @@ public abstract class MixinClientPlayerInteractionManager { @Inject(method = "sendSequencedPacket", at = @At("HEAD")) private void trackPlayerAction(ClientWorld world, SequencedPacketCreator packetCreator, CallbackInfo ci) { if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_14_4, VersionEnum.r1_18_2) && packetCreator instanceof PlayerActionC2SPacket playerActionC2SPacket) { - ClientPlayerInteractionManager1_18_2.trackPlayerAction(playerActionC2SPacket.getAction(), playerActionC2SPacket.getPos()); + this.viaFabricPlus$1_18_2InteractionManager.trackPlayerAction(playerActionC2SPacket.getAction(), playerActionC2SPacket.getPos()); } } @Redirect(method = {"attackBlock", "cancelBlockBreaking"}, at = @At(value = "NEW", target = "(Lnet/minecraft/network/packet/c2s/play/PlayerActionC2SPacket$Action;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;)Lnet/minecraft/network/packet/c2s/play/PlayerActionC2SPacket;")) private PlayerActionC2SPacket trackPlayerAction(PlayerActionC2SPacket.Action action, BlockPos pos, Direction direction) { if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_14_4, VersionEnum.r1_18_2)) { - ClientPlayerInteractionManager1_18_2.trackPlayerAction(action, pos); + this.viaFabricPlus$1_18_2InteractionManager.trackPlayerAction(action, pos); } return new PlayerActionC2SPacket(action, pos, direction); } @@ -321,4 +325,9 @@ public abstract class MixinClientPlayerInteractionManager { return type == SlotActionType.PICKUP && slot == -999; } + @Override + public ClientPlayerInteractionManager1_18_2 viaFabricPlus$get1_18_2InteractionManager() { + return this.viaFabricPlus$1_18_2InteractionManager; + } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPackets1_19.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPackets1_19.java index 5d4d88ca..46eeee35 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPackets1_19.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPackets1_19.java @@ -25,9 +25,10 @@ import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.WorldPackets; -import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2; import de.florianmichael.viafabricplus.fixes.ClientsideFixes; +import de.florianmichael.viafabricplus.injection.access.IClientPlayerInteractionManager; import de.florianmichael.viafabricplus.protocolhack.translator.BlockStateTranslator; +import net.minecraft.client.MinecraftClient; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -48,7 +49,8 @@ public abstract class MixinWorldPackets1_19 { final var action = data.readEnumConstant(PlayerActionC2SPacket.Action.class); final var allGood = data.readBoolean(); - ClientPlayerInteractionManager1_18_2.handleBlockBreakAck(pos, blockState, action, allGood); + final IClientPlayerInteractionManager interactionManager = (IClientPlayerInteractionManager) MinecraftClient.getInstance().interactionManager; + interactionManager.viaFabricPlus$get1_18_2InteractionManager().handleBlockBreakAck(pos, blockState, action, allGood); } catch (Throwable t) { throw new RuntimeException("Failed to handle BlockBreakAck packet data", t); } diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java index 72f3d9df..4fd130f0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java @@ -31,7 +31,6 @@ import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.connection.UserConnectionImpl; import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback; -import de.florianmichael.viafabricplus.event.DisconnectCallback; import de.florianmichael.viafabricplus.event.PostViaVersionLoadCallback; import de.florianmichael.viafabricplus.injection.access.IClientConnection; import de.florianmichael.viafabricplus.protocolhack.command.ViaFabricPlusVLCommandHandler; @@ -159,6 +158,16 @@ public class ProtocolHack { } } + /** + * Resets the previous version if it is set. Calling {@link #setTargetVersion(VersionEnum, boolean)} with revertOnDisconnect set to true will set it. + */ + public static void resetPreviousVersion() { + if (previousVersion != null) { // Revert the version if the player disconnects and a previous version is set + setTargetVersion(previousVersion); + previousVersion = null; + } + } + /** * @param clientVersion The client version * @param serverVersion The server version @@ -228,13 +237,6 @@ public class ProtocolHack { * @return A CompletableFuture that will be completed when the initialization is done */ public static CompletableFuture init(final File directory) { - DisconnectCallback.EVENT.register(() -> { - if (previousVersion != null) { // Revert the version if the player disconnects and a previous version is set - setTargetVersion(previousVersion); - previousVersion = null; - } - }); - patchConfigs(directory); // Register command callback for /viaversion and /viafabricplus diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusClassicMPPassProvider.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusClassicMPPassProvider.java index bf22b217..e1b09768 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusClassicMPPassProvider.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusClassicMPPassProvider.java @@ -29,12 +29,15 @@ import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.provide import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage; public class ViaFabricPlusClassicMPPassProvider extends ClassicMPPassProvider { - public static String classiCubeMPPass; + + public static String classicMpPassForNextJoin; @Override public String getMpPass(UserConnection user) { - if (classiCubeMPPass != null) { - return classiCubeMPPass; + if (classicMpPassForNextJoin != null) { + final String mpPass = classicMpPassForNextJoin; + classicMpPassForNextJoin = null; + return mpPass; } if (AuthenticationSettings.global().useBetaCraftAuthentication.getValue()) { @@ -56,4 +59,5 @@ public class ViaFabricPlusClassicMPPassProvider extends ClassicMPPassProvider { return super.getMpPass(user); } } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java index f7fd20c4..ce79813c 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java @@ -26,9 +26,9 @@ import de.florianmichael.classic4j.model.classicube.server.CCServerInfo; import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.injection.access.IServerInfo; import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider; +import de.florianmichael.viafabricplus.screen.MainScreen; import de.florianmichael.viafabricplus.screen.base.VFPListEntry; import de.florianmichael.viafabricplus.screen.base.VFPScreen; -import de.florianmichael.viafabricplus.screen.MainScreen; import de.florianmichael.viafabricplus.settings.impl.AuthenticationSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -137,7 +137,7 @@ public class ClassiCubeServerListScreen extends VFPScreen { public void mappedMouseClicked(double mouseX, double mouseY, int button) { final ServerAddress serverAddress = ServerAddress.parse(classiCubeServerInfo.ip() + ":" + classiCubeServerInfo.port()); final ServerInfo entry = new ServerInfo(classiCubeServerInfo.name(), serverAddress.getAddress(), ServerInfo.ServerType.OTHER); - ViaFabricPlusClassicMPPassProvider.classiCubeMPPass = classiCubeServerInfo.mpPass(); + ViaFabricPlusClassicMPPassProvider.classicMpPassForNextJoin = classiCubeServerInfo.mpPass(); if (AuthenticationSettings.global().automaticallySelectCPEInClassiCubeServerList.getValue()) { ((IServerInfo) entry).viaFabricPlus$forceVersion(VersionEnum.c0_30cpe); diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 79eadaa9..50a39b6b 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -193,15 +193,13 @@ "viabedrock.MixinBlobCache", "viabedrock.MixinJoinPackets", "vialegacy.MixinExtensionProtocolMetadataStorage", + "vialegacy.MixinViaLegacyConfig", "viaversion.MixinAbstractFenceConnectionHandler", + "viaversion.MixinConfig", "viaversion.MixinGlassConnectionHandler", "viaversion.MixinProtocolVersion" ], "injectors": { "defaultRequire": 1 - }, - "mixins": [ - "vialegacy.MixinViaLegacyConfig", - "viaversion.MixinConfig" - ] + } }