Some final cleanup before 1.20.3

This commit is contained in:
FlorianMichael 2023-12-02 01:14:12 +01:00
parent a6c9ed237f
commit 79631f7caf
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
136 changed files with 1625 additions and 290 deletions

View File

@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge&#10;Copyright (C) 2021-&amp;#36;today.year FlorianMichael/EnZaXD and contributors&#10;&#10;This program is free software: you can redistribute it and/or modify&#10;it under the terms of the GNU General Public License as published by&#10;the Free Software Foundation, either version 3 of the License, or&#10;(at your option) any later version.&#10;&#10;This program is distributed in the hope that it will be useful,&#10;but WITHOUT ANY WARRANTY; without even the implied warranty of&#10;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#10;GNU General Public License for more details.&#10;&#10;You should have received a copy of the GNU General Public License&#10;along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;." />
<option name="myName" value="GPL-3.0" />
</copyright>
</component>

View File

@ -0,0 +1,8 @@
<component name="CopyrightManager">
<settings default="GPL_3_0">
<module2copyright>
<element module="Project Files" copyright="GPL-3.0" />
</module2copyright>
<LanguageOptions name="__TEMPLATE__" />
</settings>
</component>

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.common; package de.florianmichael.viaforge.common;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
@ -41,8 +42,9 @@ import java.io.File;
* It is used to inject the ViaVersion pipeline into the netty pipeline. It also manages the target version. * It is used to inject the ViaVersion pipeline into the netty pipeline. It also manages the target version.
*/ */
public class ViaForgeCommon { public class ViaForgeCommon {
public final static AttributeKey<UserConnection> LOCAL_VIA_USER = AttributeKey.valueOf("local_via_user");
public final static AttributeKey<VFNetworkManager> VF_NETWORK_MANAGER = AttributeKey.valueOf("encryption_setup"); public static final AttributeKey<UserConnection> LOCAL_VIA_USER = AttributeKey.valueOf("local_via_user");
public static final AttributeKey<VFNetworkManager> VF_NETWORK_MANAGER = AttributeKey.valueOf("encryption_setup");
private static ViaForgeCommon manager; private static ViaForgeCommon manager;
@ -144,4 +146,5 @@ public class ViaForgeCommon {
public static ViaForgeCommon getManager() { public static ViaForgeCommon getManager() {
return manager; return manager;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.common.gui; package de.florianmichael.viaforge.common.gui;
import net.raphimc.vialoader.util.VersionEnum; import net.raphimc.vialoader.util.VersionEnum;
@ -24,7 +25,8 @@ import net.raphimc.vialoader.util.VersionEnum;
*/ */
public interface ExtendedServerData { public interface ExtendedServerData {
VersionEnum viaforge_getVersion(); VersionEnum viaForge$getVersion();
void viaForge$setVersion(final VersionEnum version);
void viaforge_setVersion(final VersionEnum version);
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.common.platform; package de.florianmichael.viaforge.common.platform;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
@ -54,4 +55,5 @@ public interface VFPlatform {
* @return the game profile fetcher of the platform for ViaLegacy * @return the game profile fetcher of the platform for ViaLegacy
*/ */
GameProfileFetcher getGameProfileFetcher(); GameProfileFetcher getGameProfileFetcher();
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.common.platform; package de.florianmichael.viaforge.common.platform;
import com.viaversion.viaversion.util.Config; import com.viaversion.viaversion.util.Config;
@ -10,18 +28,19 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class ViaForgeConfig extends Config { public class ViaForgeConfig extends Config {
public final static String CLIENT_SIDE_VERSION = "client-side-version";
public final static String VERIFY_SESSION_IN_OLD_VERSIONS = "verify-session-in-old-versions"; public static final String CLIENT_SIDE_VERSION = "client-side-version";
public final static String ALLOW_BETACRAFT_AUTHENTICATION = "allow-betacraft-authentication"; public static final String VERIFY_SESSION_IN_OLD_VERSIONS = "verify-session-in-old-versions";
public final static String SHOW_PROTOCOL_VERSION_IN_F3 = "show-protocol-version-in-f3"; public static final String ALLOW_BETACRAFT_AUTHENTICATION = "allow-betacraft-authentication";
public static final String SHOW_PROTOCOL_VERSION_IN_F3 = "show-protocol-version-in-f3";
public final static String SHOW_MAIN_MENU_BUTTON = "show-main-menu-button"; public static final String SHOW_MAIN_MENU_BUTTON = "show-main-menu-button";
public final static String SHOW_MULTIPLAYER_BUTTON = "show-multiplayer-button"; public static final String SHOW_MULTIPLAYER_BUTTON = "show-multiplayer-button";
public final static String SHOW_DIRECT_CONNECT_BUTTON = "show-direct-connect-button"; public static final String SHOW_DIRECT_CONNECT_BUTTON = "show-direct-connect-button";
public final static String SHOW_ADD_SERVER_BUTTON = "show-add-server-button"; public static final String SHOW_ADD_SERVER_BUTTON = "show-add-server-button";
public final static String VIA_FORGE_BUTTON_POSITION = "via-forge-button-position"; public static final String VIA_FORGE_BUTTON_POSITION = "via-forge-button-position";
public final static String ADD_SERVER_SCREEN_BUTTON_POSITION = "add-server-screen-button-position"; public static final String ADD_SERVER_SCREEN_BUTTON_POSITION = "add-server-screen-button-position";
/** /**
* @param configFile The location of where the config is loaded/saved. * @param configFile The location of where the config is loaded/saved.
@ -117,6 +136,8 @@ public class ViaForgeConfig extends Config {
public interface PositionInvoker { public interface PositionInvoker {
Pair<Integer, Integer> invoke(int width, int height); Pair<Integer, Integer> invoke(int width, int height);
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.common.protocolhack; package de.florianmichael.viaforge.common.protocolhack;
import net.raphimc.vialoader.impl.viaversion.VLInjector; import net.raphimc.vialoader.impl.viaversion.VLInjector;
@ -31,4 +32,5 @@ public class ViaForgeVLInjector extends VLInjector {
public String getEncoderName() { public String getEncoderName() {
return VLLegacyPipeline.VIA_ENCODER_NAME; return VLLegacyPipeline.VIA_ENCODER_NAME;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.common.protocolhack; package de.florianmichael.viaforge.common.protocolhack;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
@ -44,10 +45,11 @@ public class ViaForgeVLLoader extends VLLoader {
final ViaProviders providers = Via.getManager().getProviders(); final ViaProviders providers = Via.getManager().getProviders();
providers.use(VersionProvider.class, new ViaForgeVersionProvider()); providers.use(VersionProvider.class, new ViaForgeVersionProvider());
providers.use(MovementTransmitterProvider.class, new DummyMovementTransmitter()); providers.use(MovementTransmitterProvider.class, new ViaForgeMovementTransmitterProvider());
providers.use(OldAuthProvider.class, new ViaForgeOldAuthProvider()); providers.use(OldAuthProvider.class, new ViaForgeOldAuthProvider());
providers.use(GameProfileFetcher.class, platform.getGameProfileFetcher()); providers.use(GameProfileFetcher.class, platform.getGameProfileFetcher());
providers.use(EncryptionProvider.class, new ViaForgeEncryptionProvider()); providers.use(EncryptionProvider.class, new ViaForgeEncryptionProvider());
providers.use(ClassicMPPassProvider.class, new ViaForgeClassicMPPassProvider()); providers.use(ClassicMPPassProvider.class, new ViaForgeClassicMPPassProvider());
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.common.protocolhack.netty; package de.florianmichael.viaforge.common.protocolhack.netty;
import net.raphimc.vialoader.util.VersionEnum; import net.raphimc.vialoader.util.VersionEnum;
@ -8,17 +26,18 @@ public interface VFNetworkManager {
* API method to setup the decryption side of the pipeline. * API method to setup the decryption side of the pipeline.
* This method is called by the {@link de.florianmichael.viaforge.common.protocolhack.provider.ViaForgeEncryptionProvider} class. * This method is called by the {@link de.florianmichael.viaforge.common.protocolhack.provider.ViaForgeEncryptionProvider} class.
*/ */
void viaforge_setupPreNettyDecryption(); void viaForge$setupPreNettyDecryption();
/** /**
* @return the target version of the connection * @return the target version of the connection
*/ */
VersionEnum viaforge_getTrackedVersion(); VersionEnum viaForge$getTrackedVersion();
/** /**
* Sets the target version of the connection. * Sets the target version of the connection.
* *
* @param version the target version * @param version the target version
*/ */
void viaforge_setTrackedVersion(final VersionEnum version); void viaForge$setTrackedVersion(final VersionEnum version);
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.common.protocolhack.netty; package de.florianmichael.viaforge.common.protocolhack.netty;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
@ -56,4 +57,5 @@ public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
protected String lengthPrependerName() { protected String lengthPrependerName() {
return "prepender"; return "prepender";
} }
} }

View File

@ -1,12 +0,0 @@
package de.florianmichael.viaforge.common.protocolhack.provider;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
public class DummyMovementTransmitter extends MovementTransmitterProvider {
@Override
public void sendPlayer(UserConnection userConnection) {
// We are on the client side, so we can handle the idle packet properly
}
}

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.common.protocolhack.provider; package de.florianmichael.viaforge.common.protocolhack.provider;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
@ -66,4 +84,5 @@ public class ViaForgeClassicMPPassProvider extends ClassicMPPassProvider {
return null; return null;
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.common.protocolhack.provider; package de.florianmichael.viaforge.common.protocolhack.provider;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
@ -8,6 +26,7 @@ public class ViaForgeEncryptionProvider extends EncryptionProvider {
@Override @Override
public void enableDecryption(UserConnection user) { public void enableDecryption(UserConnection user) {
user.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).getAndRemove().viaforge_setupPreNettyDecryption(); user.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).getAndRemove().viaForge$setupPreNettyDecryption();
} }
} }

View File

@ -0,0 +1,31 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.common.protocolhack.provider;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
public class ViaForgeMovementTransmitterProvider extends MovementTransmitterProvider {
@Override
public void sendPlayer(UserConnection userConnection) {
// We are on the client side, so we can handle the idle packet properly
}
}

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.common.protocolhack.provider; package de.florianmichael.viaforge.common.protocolhack.provider;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
@ -12,7 +30,7 @@ public class ViaForgeOldAuthProvider extends OldAuthProvider {
if (!common.getConfig().isVerifySessionInOldVersions()) { if (!common.getConfig().isVerifySessionInOldVersions()) {
return; return;
} }
common.getPlatform().joinServer(serverId); common.getPlatform().joinServer(serverId);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.common.protocolhack.provider; package de.florianmichael.viaforge.common.protocolhack.provider;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
@ -32,9 +33,9 @@ public class ViaForgeVersionProvider extends BaseVersionProvider {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return connection.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).get().viaforge_getTrackedVersion().getVersion(); return connection.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).get().viaForge$getTrackedVersion().getVersion();
} }
return super.getClosestServerProtocol(connection); return super.getClosestServerProtocol(connection);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
@ -30,7 +31,8 @@ import java.util.function.Supplier;
@Mod(modid = "viaforge") @Mod(modid = "viaforge")
public class ViaForge112 implements VFPlatform { public class ViaForge112 implements VFPlatform {
public final static ViaForge112 PLATFORM = new ViaForge112();
public static final ViaForge112 PLATFORM = new ViaForge112();
@Override @Override
public int getGameVersion() { public int getGameVersion() {
@ -58,4 +60,5 @@ public class ViaForge112 implements VFPlatform {
public GameProfileFetcher getGameProfileFetcher() { public GameProfileFetcher getGameProfileFetcher() {
return new ViaForgeGameProfileFetcher(); return new ViaForgeGameProfileFetcher();
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.gui; package de.florianmichael.viaforge.gui;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.realmsclient.gui.ChatFormatting;
@ -170,4 +171,5 @@ public class GuiProtocolSelector extends GuiScreen {
void finished(final VersionEnum version, final GuiScreen parent); void finished(final VersionEnum version, final GuiScreen parent);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
@ -55,4 +56,5 @@ public class MixinLoader implements IFMLLoadingPlugin {
public String getAccessTransformerClass() { public String getAccessTransformerClass() {
return null; return null;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -20,7 +38,7 @@ public class MixinGuiConnecting_1 {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (Minecraft.getMinecraft().getCurrentServerData() instanceof ExtendedServerData) { if (Minecraft.getMinecraft().getCurrentServerData() instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) Minecraft.getMinecraft().getCurrentServerData()).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) Minecraft.getMinecraft().getCurrentServerData()).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -32,4 +50,5 @@ public class MixinGuiConnecting_1 {
return NetworkManager.createNetworkManagerAndConnect(address, i, b); return NetworkManager.createNetworkManagerAndConnect(address, i, b);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -51,4 +52,5 @@ public class MixinGuiMainMenu extends GuiScreen {
} }
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -50,4 +51,5 @@ public class MixinGuiMultiplayer extends GuiScreen {
} }
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -32,4 +50,5 @@ public class MixinGuiOverlayDebug {
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")"); cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -46,7 +47,7 @@ public class MixinGuiScreenAddServer extends GuiScreen {
if (config.isShowAddServerButton()) { if (config.isShowAddServerButton()) {
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion(); final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
buttonList.add(new GuiButton(1_000_000_000, pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version")); buttonList.add(new GuiButton(1_000_000_000, pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version"));
} }
} }
@ -57,10 +58,11 @@ public class MixinGuiScreenAddServer extends GuiScreen {
if (button.id == 1_000_000_000) { if (button.id == 1_000_000_000) {
mc.displayGuiScreen(new GuiProtocolSelector(this, true, (version, parent) -> { mc.displayGuiScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
// Set version and go back to the parent screen. // Set version and go back to the parent screen.
((ExtendedServerData) serverData).viaforge_setVersion(version); ((ExtendedServerData) serverData).viaForge$setVersion(version);
mc.displayGuiScreen(parent); mc.displayGuiScreen(parent);
})); }));
} }
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -50,4 +51,5 @@ public class MixinGuiScreenServerList extends GuiScreen {
} }
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinNetHandlerLoginClient {
} }
instance.joinServer(profile, authenticationToken, serverId); instance.joinServer(profile, authenticationToken, serverId);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -47,10 +48,10 @@ public class MixinNetworkManager implements VFNetworkManager {
@Shadow private Channel channel; @Shadow private Channel channel;
@Unique @Unique
private Cipher viaforge_decryptionCipher; private Cipher viaForge$decryptionCipher;
@Unique @Unique
private VersionEnum viaforge_targetVersion; private VersionEnum viaForge$targetVersion;
@Inject(method = "createNetworkManagerAndConnect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "createNetworkManagerAndConnect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) { private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
@ -58,7 +59,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set, // This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
// but for the server pinger we need to store the target version and force the pinging to use the target version. // but for the server pinger we need to store the target version and force the pinging to use the target version.
// Due to the fact that the server pinger is being called multiple times. // Due to the fact that the server pinger is being called multiple times.
((VFNetworkManager) networkmanager).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion()); ((VFNetworkManager) networkmanager).viaForge$setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
} }
@Inject(method = "enableEncryption", at = @At("HEAD"), cancellable = true) @Inject(method = "enableEncryption", at = @At("HEAD"), cancellable = true)
@ -70,7 +71,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption // Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol // So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
// tells us to do, therefore we need to store the cipher instance. // tells us to do, therefore we need to store the cipher instance.
this.viaforge_decryptionCipher = CryptManager.createNetCipherInstance(2, key); this.viaForge$decryptionCipher = CryptManager.createNetCipherInstance(2, key);
// Enabling the encryption side // Enabling the encryption side
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.createNetCipherInstance(1, key))); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.createNetCipherInstance(1, key)));
@ -89,18 +90,19 @@ public class MixinNetworkManager implements VFNetworkManager {
} }
@Override @Override
public void viaforge_setupPreNettyDecryption() { public void viaForge$setupPreNettyDecryption() {
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do // Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaForge$decryptionCipher));
} }
@Override @Override
public VersionEnum viaforge_getTrackedVersion() { public VersionEnum viaForge$getTrackedVersion() {
return viaforge_targetVersion; return viaForge$targetVersion;
} }
@Override @Override
public void viaforge_setTrackedVersion(VersionEnum version) { public void viaForge$setTrackedVersion(VersionEnum version) {
viaforge_targetVersion = version; viaForge$targetVersion = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -37,4 +38,5 @@ public class MixinNetworkManager_5 {
private void onInitChannel(Channel channel, CallbackInfo ci) { private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager); ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import de.florianmichael.viaforge.common.gui.ExtendedServerData; import de.florianmichael.viaforge.common.gui.ExtendedServerData;
@ -16,36 +34,37 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public class MixinServerData implements ExtendedServerData { public class MixinServerData implements ExtendedServerData {
@Unique @Unique
private VersionEnum viaforge_version; private VersionEnum viaForge$version;
@Inject(method = "getNBTCompound", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "getNBTCompound", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void saveVersion(CallbackInfoReturnable<NBTTagCompound> cir, NBTTagCompound nbttagcompound) { public void saveVersion(CallbackInfoReturnable<NBTTagCompound> cir, NBTTagCompound nbttagcompound) {
if (viaforge_version != null) { if (viaForge$version != null) {
nbttagcompound.setInteger("viaforge_version", viaforge_version.getVersion()); nbttagcompound.setInteger("viaForge$version", viaForge$version.getVersion());
} }
} }
@Inject(method = "getServerDataFromNBTCompound", at = @At(value = "TAIL")) @Inject(method = "getServerDataFromNBTCompound", at = @At(value = "TAIL"))
private static void getVersion(NBTTagCompound nbtCompound, CallbackInfoReturnable<ServerData> cir) { private static void getVersion(NBTTagCompound nbtCompound, CallbackInfoReturnable<ServerData> cir) {
if (nbtCompound.hasKey("viaforge_version")) { if (nbtCompound.hasKey("viaForge$version")) {
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(nbtCompound.getInteger("viaforge_version"))); ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(nbtCompound.getInteger("viaForge$version")));
} }
} }
@Inject(method = "copyFrom", at = @At("HEAD")) @Inject(method = "copyFrom", at = @At("HEAD"))
public void track(ServerData serverDataIn, CallbackInfo ci) { public void track(ServerData serverDataIn, CallbackInfo ci) {
if (serverDataIn instanceof ExtendedServerData) { if (serverDataIn instanceof ExtendedServerData) {
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion(); viaForge$version = ((ExtendedServerData) serverDataIn).viaForge$getVersion();
} }
} }
@Override @Override
public VersionEnum viaforge_getVersion() { public VersionEnum viaForge$getVersion() {
return viaforge_version; return viaForge$version;
} }
@Override @Override
public void viaforge_setVersion(VersionEnum version) { public void viaForge$setVersion(VersionEnum version) {
viaforge_version = version; viaForge$version = version;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -19,11 +37,11 @@ import java.net.InetAddress;
public class MixinServerPinger { public class MixinServerPinger {
@Unique @Unique
private ServerData viaforge_serverData; private ServerData viaForge$serverData;
@Inject(method = "ping", at = @At("HEAD")) @Inject(method = "ping", at = @At("HEAD"))
public void trackServerData(ServerData server, CallbackInfo ci) { public void trackServerData(ServerData server, CallbackInfo ci) {
viaforge_serverData = server; viaForge$serverData = server;
} }
@Redirect(method = "ping", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;createNetworkManagerAndConnect(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;")) @Redirect(method = "ping", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;createNetworkManagerAndConnect(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
@ -32,8 +50,8 @@ public class MixinServerPinger {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (viaforge_serverData instanceof ExtendedServerData) { if (viaForge$serverData instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -42,9 +60,10 @@ public class MixinServerPinger {
ViaForgeCommon.getManager().restoreVersion(); ViaForgeCommon.getManager().restoreVersion();
} }
viaforge_serverData = null; viaForge$serverData = null;
} }
return NetworkManager.createNetworkManagerAndConnect(address, i, b); return NetworkManager.createNetworkManagerAndConnect(address, i, b);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.impl.fixes; package de.florianmichael.viaforge.mixin.impl.fixes;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
} }
return prevOnGround; return prevOnGround;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.provider; package de.florianmichael.viaforge.provider;
import com.mojang.authlib.Agent; import com.mojang.authlib.Agent;
@ -16,9 +34,10 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class ViaForgeGameProfileFetcher extends GameProfileFetcher { public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
public final static HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService(); public static final HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository(); public static final MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService();
public static final GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository();
@Override @Override
public UUID loadMojangUUID(String playerName) throws Exception { public UUID loadMojangUUID(String playerName) throws Exception {
@ -54,4 +73,5 @@ public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
return gameProfile; return gameProfile;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
@ -30,7 +31,8 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge114 implements VFPlatform { public class ViaForge114 implements VFPlatform {
public final static ViaForge114 PLATFORM = new ViaForge114();
public static final ViaForge114 PLATFORM = new ViaForge114();
@Override @Override
public int getGameVersion() { public int getGameVersion() {
@ -58,4 +60,5 @@ public class ViaForge114 implements VFPlatform {
public GameProfileFetcher getGameProfileFetcher() { public GameProfileFetcher getGameProfileFetcher() {
return new ViaForgeGameProfileFetcher(); return new ViaForgeGameProfileFetcher();
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.gui; package de.florianmichael.viaforge.gui;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.realmsclient.gui.ChatFormatting;
@ -158,5 +159,7 @@ public class GuiProtocolSelector extends Screen {
public interface FinishedCallback { public interface FinishedCallback {
void finished(final VersionEnum version, final Screen parent); void finished(final VersionEnum version, final Screen parent);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -51,14 +52,15 @@ public class MixinAddServerScreen extends Screen {
if (config.isShowAddServerButton()) { if (config.isShowAddServerButton()) {
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion(); final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
addButton(new Button(pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version", b -> { addButton(new Button(pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version", b -> {
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> { minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
// Set version and go back to the parent screen. // Set version and go back to the parent screen.
((ExtendedServerData) serverData).viaforge_setVersion(version); ((ExtendedServerData) serverData).viaForge$setVersion(version);
minecraft.setScreen(parent); minecraft.setScreen(parent);
})); }));
})); }));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientLoginNetHandler {
} }
instance.joinServer(profile, authenticationToken, serverId); instance.joinServer(profile, authenticationToken, serverId);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -20,7 +38,7 @@ public class MixinConnectingScreen_1 {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) { if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -32,4 +50,5 @@ public class MixinConnectingScreen_1 {
return NetworkManager.connectToServer(address, i, b); return NetworkManager.connectToServer(address, i, b);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -32,4 +50,5 @@ public class MixinDebugOverlayGui {
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")"); cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -49,4 +50,5 @@ public class MixinMainMenuScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -46,4 +47,5 @@ public class MixinMultiplayerScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -47,10 +48,10 @@ public class MixinNetworkManager implements VFNetworkManager {
@Shadow private Channel channel; @Shadow private Channel channel;
@Unique @Unique
private Cipher viaforge_decryptionCipher; private Cipher viaForge$decryptionCipher;
@Unique @Unique
private VersionEnum viaforge_targetVersion; private VersionEnum viaForge$targetVersion;
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) { private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
@ -58,7 +59,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set, // This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
// but for the server pinger we need to store the target version and force the pinging to use the target version. // but for the server pinger we need to store the target version and force the pinging to use the target version.
// Due to the fact that the server pinger is being called multiple times. // Due to the fact that the server pinger is being called multiple times.
((VFNetworkManager) networkmanager).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion()); ((VFNetworkManager) networkmanager).viaForge$setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
} }
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true) @Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
@ -70,7 +71,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption // Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol // So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
// tells us to do, therefore we need to store the cipher instance. // tells us to do, therefore we need to store the cipher instance.
this.viaforge_decryptionCipher = CryptManager.getCipher(2, key); this.viaForge$decryptionCipher = CryptManager.getCipher(2, key);
// Enabling the encryption side // Enabling the encryption side
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.getCipher(1, key))); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.getCipher(1, key)));
@ -89,18 +90,19 @@ public class MixinNetworkManager implements VFNetworkManager {
} }
@Override @Override
public void viaforge_setupPreNettyDecryption() { public void viaForge$setupPreNettyDecryption() {
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do // Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaForge$decryptionCipher));
} }
@Override @Override
public VersionEnum viaforge_getTrackedVersion() { public VersionEnum viaForge$getTrackedVersion() {
return viaforge_targetVersion; return viaForge$targetVersion;
} }
@Override @Override
public void viaforge_setTrackedVersion(VersionEnum version) { public void viaForge$setTrackedVersion(VersionEnum version) {
viaforge_targetVersion = version; viaForge$targetVersion = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -39,4 +40,5 @@ public class MixinNetworkManager_1 {
private void onInitChannel(Channel channel, CallbackInfo ci) { private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager); ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.gui.ExtendedServerData; import de.florianmichael.viaforge.common.gui.ExtendedServerData;
@ -16,36 +34,37 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public class MixinServerData implements ExtendedServerData { public class MixinServerData implements ExtendedServerData {
@Unique @Unique
private VersionEnum viaforge_version; private VersionEnum viaForge$version;
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) { public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) {
if (viaforge_version != null) { if (viaForge$version != null) {
compoundnbt.putInt("viaforge_version", viaforge_version.getVersion()); compoundnbt.putInt("viaForge$version", viaForge$version.getVersion());
} }
} }
@Inject(method = "read", at = @At(value = "TAIL")) @Inject(method = "read", at = @At(value = "TAIL"))
private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) { private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) {
if (compoundnbt.contains("viaforge_version")) { if (compoundnbt.contains("viaForge$version")) {
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaforge_version"))); ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
} }
} }
@Inject(method = "copyFrom", at = @At("HEAD")) @Inject(method = "copyFrom", at = @At("HEAD"))
public void track(ServerData serverDataIn, CallbackInfo ci) { public void track(ServerData serverDataIn, CallbackInfo ci) {
if (serverDataIn instanceof ExtendedServerData) { if (serverDataIn instanceof ExtendedServerData) {
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion(); viaForge$version = ((ExtendedServerData) serverDataIn).viaForge$getVersion();
} }
} }
@Override @Override
public VersionEnum viaforge_getVersion() { public VersionEnum viaForge$getVersion() {
return viaforge_version; return viaForge$version;
} }
@Override @Override
public void viaforge_setVersion(VersionEnum version) { public void viaForge$setVersion(VersionEnum version) {
viaforge_version = version; viaForge$version = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -46,4 +47,5 @@ public class MixinServerListScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -19,11 +37,11 @@ import java.net.InetAddress;
public class MixinServerPinger { public class MixinServerPinger {
@Unique @Unique
private ServerData viaforge_serverData; private ServerData viaForge$serverData;
@Inject(method = "pingServer", at = @At("HEAD")) @Inject(method = "pingServer", at = @At("HEAD"))
public void trackServerData(ServerData server, CallbackInfo ci) { public void trackServerData(ServerData server, CallbackInfo ci) {
viaforge_serverData = server; viaForge$serverData = server;
} }
@Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;")) @Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
@ -32,8 +50,8 @@ public class MixinServerPinger {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (viaforge_serverData instanceof ExtendedServerData) { if (viaForge$serverData instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -42,9 +60,10 @@ public class MixinServerPinger {
ViaForgeCommon.getManager().restoreVersion(); ViaForgeCommon.getManager().restoreVersion();
} }
viaforge_serverData = null; viaForge$serverData = null;
} }
return NetworkManager.connectToServer(address, i, b); return NetworkManager.connectToServer(address, i, b);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.fixes; package de.florianmichael.viaforge.mixin.fixes;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
} }
return lastOnGround; return lastOnGround;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.provider; package de.florianmichael.viaforge.provider;
import com.mojang.authlib.Agent; import com.mojang.authlib.Agent;
@ -16,9 +34,10 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class ViaForgeGameProfileFetcher extends GameProfileFetcher { public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
public final static HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService(); public static final HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository(); public static final MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService();
public static final GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository();
@Override @Override
public UUID loadMojangUUID(String playerName) throws Exception { public UUID loadMojangUUID(String playerName) throws Exception {
@ -54,4 +73,5 @@ public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
return gameProfile; return gameProfile;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
@ -31,7 +32,7 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge115 implements VFPlatform { public class ViaForge115 implements VFPlatform {
public final static ViaForge115 PLATFORM = new ViaForge115(); public static final ViaForge115 PLATFORM = new ViaForge115();
@Override @Override
public int getGameVersion() { public int getGameVersion() {
@ -59,4 +60,5 @@ public class ViaForge115 implements VFPlatform {
public GameProfileFetcher getGameProfileFetcher() { public GameProfileFetcher getGameProfileFetcher() {
return new ViaForgeGameProfileFetcher(); return new ViaForgeGameProfileFetcher();
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.gui; package de.florianmichael.viaforge.gui;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.realmsclient.gui.ChatFormatting;
@ -158,5 +159,7 @@ public class GuiProtocolSelector extends Screen {
public interface FinishedCallback { public interface FinishedCallback {
void finished(final VersionEnum version, final Screen parent); void finished(final VersionEnum version, final Screen parent);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -51,14 +52,15 @@ public class MixinAddServerScreen extends Screen {
if (config.isShowAddServerButton()) { if (config.isShowAddServerButton()) {
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion(); final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
addButton(new Button(pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version", b -> { addButton(new Button(pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version", b -> {
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> { minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
// Set version and go back to the parent screen. // Set version and go back to the parent screen.
((ExtendedServerData) serverData).viaforge_setVersion(version); ((ExtendedServerData) serverData).viaForge$setVersion(version);
minecraft.setScreen(parent); minecraft.setScreen(parent);
})); }));
})); }));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientLoginNetHandler {
} }
instance.joinServer(profile, authenticationToken, serverId); instance.joinServer(profile, authenticationToken, serverId);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -20,7 +38,7 @@ public class MixinConnectingScreen_1 {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) { if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -32,4 +50,5 @@ public class MixinConnectingScreen_1 {
return NetworkManager.connectToServer(address, i, b); return NetworkManager.connectToServer(address, i, b);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -32,4 +50,5 @@ public class MixinDebugOverlayGui {
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")"); cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -49,4 +50,5 @@ public class MixinMainMenuScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -46,4 +47,5 @@ public class MixinMultiplayerScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -47,10 +48,10 @@ public class MixinNetworkManager implements VFNetworkManager {
@Shadow private Channel channel; @Shadow private Channel channel;
@Unique @Unique
private Cipher viaforge_decryptionCipher; private Cipher viaForge$decryptionCipher;
@Unique @Unique
private VersionEnum viaforge_targetVersion; private VersionEnum viaForge$targetVersion;
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void trackSelfTarget(InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyValue lazyvalue) { private static void trackSelfTarget(InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyValue lazyvalue) {
@ -58,7 +59,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set, // This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
// but for the server pinger we need to store the target version and force the pinging to use the target version. // but for the server pinger we need to store the target version and force the pinging to use the target version.
// Due to the fact that the server pinger is being called multiple times. // Due to the fact that the server pinger is being called multiple times.
((VFNetworkManager) networkmanager).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion()); ((VFNetworkManager) networkmanager).viaForge$setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
} }
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true) @Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
@ -70,7 +71,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption // Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol // So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
// tells us to do, therefore we need to store the cipher instance. // tells us to do, therefore we need to store the cipher instance.
this.viaforge_decryptionCipher = CryptManager.getCipher(2, key); this.viaForge$decryptionCipher = CryptManager.getCipher(2, key);
// Enabling the encryption side // Enabling the encryption side
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.getCipher(1, key))); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.getCipher(1, key)));
@ -89,18 +90,19 @@ public class MixinNetworkManager implements VFNetworkManager {
} }
@Override @Override
public void viaforge_setupPreNettyDecryption() { public void viaForge$setupPreNettyDecryption() {
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do // Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaForge$decryptionCipher));
} }
@Override @Override
public VersionEnum viaforge_getTrackedVersion() { public VersionEnum viaForge$getTrackedVersion() {
return viaforge_targetVersion; return viaForge$targetVersion;
} }
@Override @Override
public void viaforge_setTrackedVersion(VersionEnum version) { public void viaForge$setTrackedVersion(VersionEnum version) {
viaforge_targetVersion = version; viaForge$targetVersion = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -39,4 +40,5 @@ public class MixinNetworkManager_1 {
private void onInitChannel(Channel channel, CallbackInfo ci) { private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager); ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.gui.ExtendedServerData; import de.florianmichael.viaforge.common.gui.ExtendedServerData;
@ -16,36 +34,37 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public class MixinServerData implements ExtendedServerData { public class MixinServerData implements ExtendedServerData {
@Unique @Unique
private VersionEnum viaforge_version; private VersionEnum viaForge$version;
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) { public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) {
if (viaforge_version != null) { if (viaForge$version != null) {
compoundnbt.putInt("viaforge_version", viaforge_version.getVersion()); compoundnbt.putInt("viaForge$version", viaForge$version.getVersion());
} }
} }
@Inject(method = "read", at = @At(value = "TAIL")) @Inject(method = "read", at = @At(value = "TAIL"))
private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) { private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) {
if (compoundnbt.contains("viaforge_version")) { if (compoundnbt.contains("viaForge$version")) {
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaforge_version"))); ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
} }
} }
@Inject(method = "copyFrom", at = @At("HEAD")) @Inject(method = "copyFrom", at = @At("HEAD"))
public void track(ServerData serverDataIn, CallbackInfo ci) { public void track(ServerData serverDataIn, CallbackInfo ci) {
if (serverDataIn instanceof ExtendedServerData) { if (serverDataIn instanceof ExtendedServerData) {
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion(); viaForge$version = ((ExtendedServerData) serverDataIn).viaForge$getVersion();
} }
} }
@Override @Override
public VersionEnum viaforge_getVersion() { public VersionEnum viaForge$getVersion() {
return viaforge_version; return viaForge$version;
} }
@Override @Override
public void viaforge_setVersion(VersionEnum version) { public void viaForge$setVersion(VersionEnum version) {
viaforge_version = version; viaForge$version = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -46,4 +47,5 @@ public class MixinServerListScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -19,11 +37,11 @@ import java.net.InetAddress;
public class MixinServerPinger { public class MixinServerPinger {
@Unique @Unique
private ServerData viaforge_serverData; private ServerData viaForge$serverData;
@Inject(method = "pingServer", at = @At("HEAD")) @Inject(method = "pingServer", at = @At("HEAD"))
public void trackServerData(ServerData server, CallbackInfo ci) { public void trackServerData(ServerData server, CallbackInfo ci) {
viaforge_serverData = server; viaForge$serverData = server;
} }
@Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;")) @Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
@ -32,8 +50,8 @@ public class MixinServerPinger {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (viaforge_serverData instanceof ExtendedServerData) { if (viaForge$serverData instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -42,9 +60,10 @@ public class MixinServerPinger {
ViaForgeCommon.getManager().restoreVersion(); ViaForgeCommon.getManager().restoreVersion();
} }
viaforge_serverData = null; viaForge$serverData = null;
} }
return NetworkManager.connectToServer(address, i, b); return NetworkManager.connectToServer(address, i, b);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.fixes; package de.florianmichael.viaforge.mixin.fixes;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
} }
return lastOnGround; return lastOnGround;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.provider; package de.florianmichael.viaforge.provider;
import com.mojang.authlib.Agent; import com.mojang.authlib.Agent;
@ -16,9 +34,10 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class ViaForgeGameProfileFetcher extends GameProfileFetcher { public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
public final static HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService(); public static final HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository(); public static final MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService();
public static final GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository();
@Override @Override
public UUID loadMojangUUID(String playerName) throws Exception { public UUID loadMojangUUID(String playerName) throws Exception {
@ -54,4 +73,5 @@ public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
return gameProfile; return gameProfile;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
@ -31,7 +32,7 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge116 implements VFPlatform { public class ViaForge116 implements VFPlatform {
public final static ViaForge116 PLATFORM = new ViaForge116(); public static final ViaForge116 PLATFORM = new ViaForge116();
@Override @Override
public int getGameVersion() { public int getGameVersion() {
@ -59,4 +60,5 @@ public class ViaForge116 implements VFPlatform {
public GameProfileFetcher getGameProfileFetcher() { public GameProfileFetcher getGameProfileFetcher() {
return new ViaForgeGameProfileFetcher(); return new ViaForgeGameProfileFetcher();
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.gui; package de.florianmichael.viaforge.gui;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@ -159,5 +160,7 @@ public class GuiProtocolSelector extends Screen {
public interface FinishedCallback { public interface FinishedCallback {
void finished(final VersionEnum version, final Screen parent); void finished(final VersionEnum version, final Screen parent);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -52,14 +53,15 @@ public class MixinAddServerScreen extends Screen {
if (config.isShowAddServerButton()) { if (config.isShowAddServerButton()) {
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion(); final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent(target != null ? target.getName() : "Set Version"), b -> { addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent(target != null ? target.getName() : "Set Version"), b -> {
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> { minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
// Set version and go back to the parent screen. // Set version and go back to the parent screen.
((ExtendedServerData) serverData).viaforge_setVersion(version); ((ExtendedServerData) serverData).viaForge$setVersion(version);
minecraft.setScreen(parent); minecraft.setScreen(parent);
})); }));
})); }));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientLoginNetHandler {
} }
instance.joinServer(profile, authenticationToken, serverId); instance.joinServer(profile, authenticationToken, serverId);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -20,7 +38,7 @@ public class MixinConnectingScreen_1 {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) { if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -32,4 +50,5 @@ public class MixinConnectingScreen_1 {
return NetworkManager.connectToServer(address, i, b); return NetworkManager.connectToServer(address, i, b);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -32,4 +50,5 @@ public class MixinDebugOverlayGui {
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")"); cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -50,4 +51,5 @@ public class MixinMainMenuScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -47,4 +48,5 @@ public class MixinMultiplayerScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -47,10 +48,10 @@ public class MixinNetworkManager implements VFNetworkManager {
@Shadow private Channel channel; @Shadow private Channel channel;
@Unique @Unique
private Cipher viaforge_decryptionCipher; private Cipher viaForge$decryptionCipher;
@Unique @Unique
private VersionEnum viaforge_targetVersion; private VersionEnum viaForge$targetVersion;
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void trackSelfTarget(InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyValue lazyvalue) { private static void trackSelfTarget(InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyValue lazyvalue) {
@ -58,7 +59,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set, // This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
// but for the server pinger we need to store the target version and force the pinging to use the target version. // but for the server pinger we need to store the target version and force the pinging to use the target version.
// Due to the fact that the server pinger is being called multiple times. // Due to the fact that the server pinger is being called multiple times.
((VFNetworkManager) networkmanager).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion()); ((VFNetworkManager) networkmanager).viaForge$setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
} }
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true) @Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
@ -70,7 +71,7 @@ public class MixinNetworkManager implements VFNetworkManager {
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption // Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol // So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
// tells us to do, therefore we need to store the cipher instance. // tells us to do, therefore we need to store the cipher instance.
this.viaforge_decryptionCipher = p_244777_1_; this.viaForge$decryptionCipher = p_244777_1_;
// Enabling the encryption side // Enabling the encryption side
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(p_244777_2_)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(p_244777_2_));
@ -89,18 +90,19 @@ public class MixinNetworkManager implements VFNetworkManager {
} }
@Override @Override
public void viaforge_setupPreNettyDecryption() { public void viaForge$setupPreNettyDecryption() {
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do // Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaForge$decryptionCipher));
} }
@Override @Override
public VersionEnum viaforge_getTrackedVersion() { public VersionEnum viaForge$getTrackedVersion() {
return viaforge_targetVersion; return viaForge$targetVersion;
} }
@Override @Override
public void viaforge_setTrackedVersion(VersionEnum version) { public void viaForge$setTrackedVersion(VersionEnum version) {
viaforge_targetVersion = version; viaForge$targetVersion = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -39,4 +40,5 @@ public class MixinNetworkManager_1 {
private void onInitChannel(Channel channel, CallbackInfo ci) { private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager); ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.gui.ExtendedServerData; import de.florianmichael.viaforge.common.gui.ExtendedServerData;
@ -16,36 +34,37 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public class MixinServerData implements ExtendedServerData { public class MixinServerData implements ExtendedServerData {
@Unique @Unique
private VersionEnum viaforge_version; private VersionEnum viaForge$version;
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) { public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) {
if (viaforge_version != null) { if (viaForge$version != null) {
compoundnbt.putInt("viaforge_version", viaforge_version.getVersion()); compoundnbt.putInt("viaForge$version", viaForge$version.getVersion());
} }
} }
@Inject(method = "read", at = @At(value = "TAIL")) @Inject(method = "read", at = @At(value = "TAIL"))
private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) { private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) {
if (compoundnbt.contains("viaforge_version")) { if (compoundnbt.contains("viaForge$version")) {
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaforge_version"))); ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
} }
} }
@Inject(method = "copyFrom", at = @At("HEAD")) @Inject(method = "copyFrom", at = @At("HEAD"))
public void track(ServerData serverDataIn, CallbackInfo ci) { public void track(ServerData serverDataIn, CallbackInfo ci) {
if (serverDataIn instanceof ExtendedServerData) { if (serverDataIn instanceof ExtendedServerData) {
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion(); viaForge$version = ((ExtendedServerData) serverDataIn).viaForge$getVersion();
} }
} }
@Override @Override
public VersionEnum viaforge_getVersion() { public VersionEnum viaForge$getVersion() {
return viaforge_version; return viaForge$version;
} }
@Override @Override
public void viaforge_setVersion(VersionEnum version) { public void viaForge$setVersion(VersionEnum version) {
viaforge_version = version; viaForge$version = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -47,4 +48,5 @@ public class MixinServerListScreen extends Screen {
addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft))); addButton(new Button(pos.key(), pos.value(), 100, 20, new StringTextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -19,11 +37,11 @@ import java.net.InetAddress;
public class MixinServerPinger { public class MixinServerPinger {
@Unique @Unique
private ServerData viaforge_serverData; private ServerData viaForge$serverData;
@Inject(method = "pingServer", at = @At("HEAD")) @Inject(method = "pingServer", at = @At("HEAD"))
public void trackServerData(ServerData server, Runnable p_147224_2_, CallbackInfo ci) { public void trackServerData(ServerData server, Runnable p_147224_2_, CallbackInfo ci) {
viaforge_serverData = server; viaForge$serverData = server;
} }
@Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;")) @Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
@ -32,8 +50,8 @@ public class MixinServerPinger {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (viaforge_serverData instanceof ExtendedServerData) { if (viaForge$serverData instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -42,9 +60,10 @@ public class MixinServerPinger {
ViaForgeCommon.getManager().restoreVersion(); ViaForgeCommon.getManager().restoreVersion();
} }
viaforge_serverData = null; viaForge$serverData = null;
} }
return NetworkManager.connectToServer(address, i, b); return NetworkManager.connectToServer(address, i, b);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.fixes; package de.florianmichael.viaforge.mixin.fixes;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
} }
return lastOnGround; return lastOnGround;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.provider; package de.florianmichael.viaforge.provider;
import com.mojang.authlib.Agent; import com.mojang.authlib.Agent;
@ -16,9 +34,10 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class ViaForgeGameProfileFetcher extends GameProfileFetcher { public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
public final static HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService(); public static final HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository(); public static final MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService();
public static final GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository();
@Override @Override
public UUID loadMojangUUID(String playerName) throws Exception { public UUID loadMojangUUID(String playerName) throws Exception {
@ -54,4 +73,5 @@ public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
return gameProfile; return gameProfile;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
@ -31,7 +32,7 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge117 implements VFPlatform { public class ViaForge117 implements VFPlatform {
public final static ViaForge117 PLATFORM = new ViaForge117(); public static final ViaForge117 PLATFORM = new ViaForge117();
@Override @Override
public int getGameVersion() { public int getGameVersion() {
@ -59,4 +60,5 @@ public class ViaForge117 implements VFPlatform {
public GameProfileFetcher getGameProfileFetcher() { public GameProfileFetcher getGameProfileFetcher() {
return new ViaForgeGameProfileFetcher(); return new ViaForgeGameProfileFetcher();
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.gui; package de.florianmichael.viaforge.gui;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
@ -164,5 +165,7 @@ public class GuiProtocolSelector extends Screen {
public interface FinishedCallback { public interface FinishedCallback {
void finished(final VersionEnum version, final Screen parent); void finished(final VersionEnum version, final Screen parent);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientHandshakePacketListenerImpl {
} }
instance.joinServer(profile, authenticationToken, serverId); instance.joinServer(profile, authenticationToken, serverId);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -20,7 +38,7 @@ public class MixinConnectScreen_1 {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) { if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -32,4 +50,5 @@ public class MixinConnectScreen_1 {
return Connection.connectToServer(oclass, lazyloadedvalue); return Connection.connectToServer(oclass, lazyloadedvalue);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -44,10 +45,10 @@ public class MixinConnection implements VFNetworkManager {
@Shadow private Channel channel; @Shadow private Channel channel;
@Unique @Unique
private Cipher viaforge_decryptionCipher; private Cipher viaForge$decryptionCipher;
@Unique @Unique
private VersionEnum viaforge_targetVersion; private VersionEnum viaForge$targetVersion;
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, CallbackInfoReturnable<Connection> cir, final Connection connection) { private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, CallbackInfoReturnable<Connection> cir, final Connection connection) {
@ -55,7 +56,7 @@ public class MixinConnection implements VFNetworkManager {
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set, // This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
// but for the server pinger we need to store the target version and force the pinging to use the target version. // but for the server pinger we need to store the target version and force the pinging to use the target version.
// Due to the fact that the server pinger is being called multiple times. // Due to the fact that the server pinger is being called multiple times.
((VFNetworkManager) connection).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion()); ((VFNetworkManager) connection).viaForge$setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
} }
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true) @Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
@ -67,7 +68,7 @@ public class MixinConnection implements VFNetworkManager {
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption // Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol // So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
// tells us to do, therefore we need to store the cipher instance. // tells us to do, therefore we need to store the cipher instance.
this.viaforge_decryptionCipher = p_244777_1_; this.viaForge$decryptionCipher = p_244777_1_;
// Enabling the encryption side // Enabling the encryption side
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new CipherEncoder(p_244777_2_)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new CipherEncoder(p_244777_2_));
@ -86,18 +87,19 @@ public class MixinConnection implements VFNetworkManager {
} }
@Override @Override
public void viaforge_setupPreNettyDecryption() { public void viaForge$setupPreNettyDecryption() {
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do // Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new CipherDecoder(this.viaforge_decryptionCipher)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new CipherDecoder(this.viaForge$decryptionCipher));
} }
@Override @Override
public VersionEnum viaforge_getTrackedVersion() { public VersionEnum viaForge$getTrackedVersion() {
return viaforge_targetVersion; return viaForge$targetVersion;
} }
@Override @Override
public void viaforge_setTrackedVersion(VersionEnum version) { public void viaForge$setTrackedVersion(VersionEnum version) {
viaforge_targetVersion = version; viaForge$targetVersion = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -39,4 +40,5 @@ public class MixinConnection_1 {
private void onInitChannel(Channel channel, CallbackInfo ci) { private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection); ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -32,4 +50,5 @@ public class MixinDebugScreenOverlay {
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")"); cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -47,4 +48,5 @@ public class MixinDirectJoinServerScreen extends Screen {
addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft))); addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -54,14 +55,15 @@ public class MixinEditServerScreen extends Screen {
if (config.isShowAddServerButton()) { if (config.isShowAddServerButton()) {
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion(); final VersionEnum target = ((ExtendedServerData) serverData).viaForge$getVersion();
addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent(target != null ? target.getName() : "Set Version"), b -> { addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent(target != null ? target.getName() : "Set Version"), b -> {
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> { minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
// Set version and go back to the parent screen. // Set version and go back to the parent screen.
((ExtendedServerData) serverData).viaforge_setVersion(version); ((ExtendedServerData) serverData).viaForge$setVersion(version);
minecraft.setScreen(parent); minecraft.setScreen(parent);
})); }));
})); }));
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -47,4 +48,5 @@ public class MixinJoinMultiplayerScreen extends Screen {
addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft))); addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.gui.ExtendedServerData; import de.florianmichael.viaforge.common.gui.ExtendedServerData;
@ -16,36 +34,37 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public class MixinServerData implements ExtendedServerData { public class MixinServerData implements ExtendedServerData {
@Unique @Unique
private VersionEnum viaforge_version; private VersionEnum viaForge$version;
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void saveVersion(CallbackInfoReturnable<CompoundTag> cir, CompoundTag compoundtag) { public void saveVersion(CallbackInfoReturnable<CompoundTag> cir, CompoundTag compoundtag) {
if (viaforge_version != null) { if (viaForge$version != null) {
compoundtag.putInt("viaforge_version", viaforge_version.getVersion()); compoundtag.putInt("viaForge$version", viaForge$version.getVersion());
} }
} }
@Inject(method = "read", at = @At(value = "TAIL")) @Inject(method = "read", at = @At(value = "TAIL"))
private static void getVersion(CompoundTag compoundnbt, CallbackInfoReturnable<ServerData> cir) { private static void getVersion(CompoundTag compoundnbt, CallbackInfoReturnable<ServerData> cir) {
if (compoundnbt.contains("viaforge_version")) { if (compoundnbt.contains("viaForge$version")) {
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaforge_version"))); ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaForge$version")));
} }
} }
@Inject(method = "copyFrom", at = @At("HEAD")) @Inject(method = "copyFrom", at = @At("HEAD"))
public void track(ServerData serverDataIn, CallbackInfo ci) { public void track(ServerData serverDataIn, CallbackInfo ci) {
if (serverDataIn instanceof ExtendedServerData) { if (serverDataIn instanceof ExtendedServerData) {
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion(); viaForge$version = ((ExtendedServerData) serverDataIn).viaForge$getVersion();
} }
} }
@Override @Override
public VersionEnum viaforge_getVersion() { public VersionEnum viaForge$getVersion() {
return viaforge_version; return viaForge$version;
} }
@Override @Override
public void viaforge_setVersion(VersionEnum version) { public void viaForge$setVersion(VersionEnum version) {
viaforge_version = version; viaForge$version = version;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -19,11 +37,11 @@ import java.net.InetSocketAddress;
public class MixinServerStatusPinger { public class MixinServerStatusPinger {
@Unique @Unique
private ServerData viaforge_serverData; private ServerData viaForge$serverData;
@Inject(method = "pingServer", at = @At("HEAD")) @Inject(method = "pingServer", at = @At("HEAD"))
public void trackServerData(ServerData server, Runnable p_147224_2_, CallbackInfo ci) { public void trackServerData(ServerData server, Runnable p_147224_2_, CallbackInfo ci) {
viaforge_serverData = server; viaForge$serverData = server;
} }
@Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Connection;connectToServer(Ljava/net/InetSocketAddress;Z)Lnet/minecraft/network/Connection;")) @Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Connection;connectToServer(Ljava/net/InetSocketAddress;Z)Lnet/minecraft/network/Connection;"))
@ -32,8 +50,8 @@ public class MixinServerStatusPinger {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (viaforge_serverData instanceof ExtendedServerData) { if (viaForge$serverData instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -42,9 +60,10 @@ public class MixinServerStatusPinger {
ViaForgeCommon.getManager().restoreVersion(); ViaForgeCommon.getManager().restoreVersion();
} }
viaforge_serverData = null; viaForge$serverData = null;
} }
return Connection.connectToServer(oclass, lazyloadedvalue); return Connection.connectToServer(oclass, lazyloadedvalue);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -50,4 +51,5 @@ public class MixinTitleScreen extends Screen {
addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft))); addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), buttons -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin.fixes; package de.florianmichael.viaforge.mixin.fixes;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinLocalPlayer extends AbstractClientPlayer {
} }
return lastOnGround; return lastOnGround;
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.provider; package de.florianmichael.viaforge.provider;
import com.mojang.authlib.Agent; import com.mojang.authlib.Agent;
@ -16,9 +34,10 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class ViaForgeGameProfileFetcher extends GameProfileFetcher { public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
public final static HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService(); public static final HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
public final static GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository(); public static final MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService();
public static final GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository();
@Override @Override
public UUID loadMojangUUID(String playerName) throws Exception { public UUID loadMojangUUID(String playerName) throws Exception {
@ -54,4 +73,5 @@ public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
return gameProfile; return gameProfile;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
@ -31,7 +32,7 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge118 implements VFPlatform { public class ViaForge118 implements VFPlatform {
public final static ViaForge118 PLATFORM = new ViaForge118(); public static final ViaForge118 PLATFORM = new ViaForge118();
@Override @Override
public int getGameVersion() { public int getGameVersion() {
@ -59,4 +60,5 @@ public class ViaForge118 implements VFPlatform {
public GameProfileFetcher getGameProfileFetcher() { public GameProfileFetcher getGameProfileFetcher() {
return new ViaForgeGameProfileFetcher(); return new ViaForgeGameProfileFetcher();
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.gui; package de.florianmichael.viaforge.gui;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
@ -164,5 +165,7 @@ public class GuiProtocolSelector extends Screen {
public interface FinishedCallback { public interface FinishedCallback {
void finished(final VersionEnum version, final Screen parent); void finished(final VersionEnum version, final Screen parent);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -34,4 +52,5 @@ public class MixinClientHandshakePacketListenerImpl {
} }
instance.joinServer(profile, authenticationToken, serverId); instance.joinServer(profile, authenticationToken, serverId);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -20,7 +38,7 @@ public class MixinConnectScreen_1 {
// use it to determine the protocol version to use. // use it to determine the protocol version to use.
// We hope that the current server data is not null // We hope that the current server data is not null
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) { if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion(); final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaForge$getVersion();
if (version != null) { if (version != null) {
ViaForgeCommon.getManager().setTargetVersionSilent(version); ViaForgeCommon.getManager().setTargetVersionSilent(version);
} else { } else {
@ -32,4 +50,5 @@ public class MixinConnectScreen_1 {
return Connection.connectToServer(oclass, lazyloadedvalue); return Connection.connectToServer(oclass, lazyloadedvalue);
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -44,10 +45,10 @@ public class MixinConnection implements VFNetworkManager {
@Shadow private Channel channel; @Shadow private Channel channel;
@Unique @Unique
private Cipher viaforge_decryptionCipher; private Cipher viaForge$decryptionCipher;
@Unique @Unique
private VersionEnum viaforge_targetVersion; private VersionEnum viaForge$targetVersion;
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD) @Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, CallbackInfoReturnable<Connection> cir, final Connection connection) { private static void trackSelfTarget(InetSocketAddress p_178301_, boolean p_178302_, CallbackInfoReturnable<Connection> cir, final Connection connection) {
@ -55,7 +56,7 @@ public class MixinConnection implements VFNetworkManager {
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set, // This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
// but for the server pinger we need to store the target version and force the pinging to use the target version. // but for the server pinger we need to store the target version and force the pinging to use the target version.
// Due to the fact that the server pinger is being called multiple times. // Due to the fact that the server pinger is being called multiple times.
((VFNetworkManager) connection).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion()); ((VFNetworkManager) connection).viaForge$setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
} }
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true) @Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
@ -67,7 +68,7 @@ public class MixinConnection implements VFNetworkManager {
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption // Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol // So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
// tells us to do, therefore we need to store the cipher instance. // tells us to do, therefore we need to store the cipher instance.
this.viaforge_decryptionCipher = p_244777_1_; this.viaForge$decryptionCipher = p_244777_1_;
// Enabling the encryption side // Enabling the encryption side
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new CipherEncoder(p_244777_2_)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new CipherEncoder(p_244777_2_));
@ -86,18 +87,19 @@ public class MixinConnection implements VFNetworkManager {
} }
@Override @Override
public void viaforge_setupPreNettyDecryption() { public void viaForge$setupPreNettyDecryption() {
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do // Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new CipherDecoder(this.viaforge_decryptionCipher)); this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new CipherDecoder(this.viaForge$decryptionCipher));
} }
@Override @Override
public VersionEnum viaforge_getTrackedVersion() { public VersionEnum viaForge$getTrackedVersion() {
return viaforge_targetVersion; return viaForge$targetVersion;
} }
@Override @Override
public void viaforge_setTrackedVersion(VersionEnum version) { public void viaForge$setTrackedVersion(VersionEnum version) {
viaforge_targetVersion = version; viaForge$targetVersion = version;
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -39,4 +40,5 @@ public class MixinConnection_1 {
private void onInitChannel(Channel channel, CallbackInfo ci) { private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection); ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection);
} }
} }

View File

@ -1,3 +1,21 @@
/*
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
@ -32,4 +50,5 @@ public class MixinDebugScreenOverlay {
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")"); cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
} }
} }
} }

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
@ -47,4 +48,5 @@ public class MixinDirectJoinServerScreen extends Screen {
addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft))); addRenderableWidget(new Button(pos.key(), pos.value(), 100, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More