Merge remote-tracking branch 'origin/master'

This commit is contained in:
FlorianMichael 2024-04-28 18:54:48 +02:00
commit cb49b6d819
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
13 changed files with 60 additions and 29 deletions

View File

@ -25,9 +25,9 @@ import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
import de.florianmichael.viaforge.common.platform.ViaForgeConfig; import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
import de.florianmichael.viaforge.common.protocoltranslator.ViaForgeVLInjector; import de.florianmichael.viaforge.common.protocoltranslator.ViaForgeVLInjector;
import de.florianmichael.viaforge.common.protocoltranslator.ViaForgeVLLoader;
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager; import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
import de.florianmichael.viaforge.common.protocoltranslator.netty.ViaForgeVLLegacyPipeline; import de.florianmichael.viaforge.common.protocoltranslator.netty.ViaForgeVLLegacyPipeline;
import de.florianmichael.viaforge.common.protocoltranslator.ViaForgeVLLoader;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.util.AttributeKey; import io.netty.util.AttributeKey;
@ -63,9 +63,6 @@ public class ViaForgeCommon {
* @param platform the platform fields * @param platform the platform fields
*/ */
public static void init(final VFPlatform platform) { public static void init(final VFPlatform platform) {
if (manager != null) {
return; // Already initialized, ignore it then :tm:
}
final ProtocolVersion version = ProtocolVersion.getProtocol(platform.getGameVersion()); // ViaForge will only load on post-netty versions final ProtocolVersion version = ProtocolVersion.getProtocol(platform.getGameVersion()); // ViaForge will only load on post-netty versions
if (version == ProtocolVersion.unknown) { if (version == ProtocolVersion.unknown) {
throw new IllegalArgumentException("Unknown version " + platform.getGameVersion()); throw new IllegalArgumentException("Unknown version " + platform.getGameVersion());

View File

@ -18,12 +18,14 @@
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher; import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.realms.RealmsSharedConstants; import net.minecraft.realms.RealmsSharedConstants;
import net.minecraft.util.Session; import net.minecraft.util.Session;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
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;
import java.io.File; import java.io.File;
@ -32,7 +34,10 @@ import java.util.function.Supplier;
@Mod(modid = "viaforge") @Mod(modid = "viaforge")
public class ViaForge112 implements VFPlatform { public class ViaForge112 implements VFPlatform {
public static final ViaForge112 PLATFORM = new ViaForge112(); @Mod.EventHandler
public void onInit(FMLInitializationEvent event) {
ViaForgeCommon.init(this);
}
@Override @Override
public int getGameVersion() { public int getGameVersion() {

View File

@ -19,11 +19,12 @@
package de.florianmichael.viaforge.mixin.impl; package de.florianmichael.viaforge.mixin.impl;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
import de.florianmichael.viaforge.ViaForge112;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.ViaForgeConfig; import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
import de.florianmichael.viaforge.gui.GuiProtocolSelector; import de.florianmichael.viaforge.gui.GuiProtocolSelector;
import net.minecraft.client.gui.*; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiScreen;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@ -34,8 +35,6 @@ public class MixinGuiMainMenu extends GuiScreen {
@Inject(method = "initGui", at = @At("RETURN")) @Inject(method = "initGui", at = @At("RETURN"))
public void hookViaForgeButton(CallbackInfo ci) { public void hookViaForgeButton(CallbackInfo ci) {
ViaForgeCommon.init(ViaForge112.PLATFORM);
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig(); final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
if (config.isShowMainMenuButton()) { if (config.isShowMainMenuButton()) {
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);

View File

@ -18,12 +18,15 @@
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher; import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.Session; import net.minecraft.util.Session;
import net.minecraft.util.SharedConstants; import net.minecraft.util.SharedConstants;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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;
import java.io.File; import java.io.File;
@ -32,7 +35,13 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge116 implements VFPlatform { public class ViaForge116 implements VFPlatform {
public static final ViaForge116 PLATFORM = new ViaForge116(); public ViaForge116() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onInit);
}
public void onInit(FMLCommonSetupEvent event) {
ViaForgeCommon.init(this);
}
@Override @Override
public int getGameVersion() { public int getGameVersion() {

View File

@ -19,7 +19,6 @@
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
import de.florianmichael.viaforge.ViaForge116;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.ViaForgeConfig; import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
import de.florianmichael.viaforge.gui.GuiProtocolSelector; import de.florianmichael.viaforge.gui.GuiProtocolSelector;
@ -42,8 +41,6 @@ public class MixinMainMenuScreen extends Screen {
@Inject(method = "init", at = @At("RETURN")) @Inject(method = "init", at = @At("RETURN"))
public void hookViaForgeButton(CallbackInfo ci) { public void hookViaForgeButton(CallbackInfo ci) {
ViaForgeCommon.init(ViaForge116.PLATFORM);
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig(); final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
if (config.isShowMainMenuButton()) { if (config.isShowMainMenuButton()) {
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);

View File

@ -18,12 +18,15 @@
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher; import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.User; import net.minecraft.client.User;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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;
import java.io.File; import java.io.File;
@ -32,7 +35,13 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge117 implements VFPlatform { public class ViaForge117 implements VFPlatform {
public static final ViaForge117 PLATFORM = new ViaForge117(); public ViaForge117() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onInit);
}
public void onInit(FMLCommonSetupEvent event) {
ViaForgeCommon.init(this);
}
@Override @Override
public int getGameVersion() { public int getGameVersion() {

View File

@ -19,7 +19,6 @@
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
import de.florianmichael.viaforge.ViaForge117;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.ViaForgeConfig; import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
import de.florianmichael.viaforge.gui.GuiProtocolSelector; import de.florianmichael.viaforge.gui.GuiProtocolSelector;
@ -42,8 +41,6 @@ public class MixinTitleScreen extends Screen {
@Inject(method = "init", at = @At("RETURN")) @Inject(method = "init", at = @At("RETURN"))
public void hookViaForgeButton(CallbackInfo ci) { public void hookViaForgeButton(CallbackInfo ci) {
ViaForgeCommon.init(ViaForge117.PLATFORM);
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig(); final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
if (config.isShowMainMenuButton()) { if (config.isShowMainMenuButton()) {
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);

View File

@ -18,12 +18,15 @@
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher; import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.User; import net.minecraft.client.User;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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;
import java.io.File; import java.io.File;
@ -32,7 +35,13 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge118 implements VFPlatform { public class ViaForge118 implements VFPlatform {
public static final ViaForge118 PLATFORM = new ViaForge118(); public ViaForge118() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onInit);
}
private void onInit(FMLCommonSetupEvent event) {
ViaForgeCommon.init(this);
}
@Override @Override
public int getGameVersion() { public int getGameVersion() {

View File

@ -19,7 +19,6 @@
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
import de.florianmichael.viaforge.ViaForge118;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.ViaForgeConfig; import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
import de.florianmichael.viaforge.gui.GuiProtocolSelector; import de.florianmichael.viaforge.gui.GuiProtocolSelector;
@ -42,8 +41,6 @@ public class MixinTitleScreen extends Screen {
@Inject(method = "init", at = @At("RETURN")) @Inject(method = "init", at = @At("RETURN"))
public void hookViaForgeButton(CallbackInfo ci) { public void hookViaForgeButton(CallbackInfo ci) {
ViaForgeCommon.init(ViaForge118.PLATFORM);
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig(); final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
if (config.isShowMainMenuButton()) { if (config.isShowMainMenuButton()) {
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);

View File

@ -18,12 +18,15 @@
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher; import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.User; import net.minecraft.client.User;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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;
import java.io.File; import java.io.File;
@ -32,7 +35,13 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge119 implements VFPlatform { public class ViaForge119 implements VFPlatform {
public static final ViaForge119 PLATFORM = new ViaForge119(); public ViaForge119() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onInit);
}
private void onInit(FMLCommonSetupEvent event) {
ViaForgeCommon.init(this);
}
@Override @Override
public int getGameVersion() { public int getGameVersion() {

View File

@ -19,7 +19,6 @@
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
import de.florianmichael.viaforge.ViaForge119;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.ViaForgeConfig; import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
import de.florianmichael.viaforge.gui.GuiProtocolSelector; import de.florianmichael.viaforge.gui.GuiProtocolSelector;
@ -41,8 +40,6 @@ public class MixinTitleScreen extends Screen {
@Inject(method = "init", at = @At("RETURN")) @Inject(method = "init", at = @At("RETURN"))
public void hookViaForgeButton(CallbackInfo ci) { public void hookViaForgeButton(CallbackInfo ci) {
ViaForgeCommon.init(ViaForge119.PLATFORM);
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig(); final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
if (config.isShowMainMenuButton()) { if (config.isShowMainMenuButton()) {
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);

View File

@ -18,12 +18,15 @@
package de.florianmichael.viaforge; package de.florianmichael.viaforge;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.common.platform.VFPlatform;
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher; import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.User; import net.minecraft.client.User;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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;
import java.io.File; import java.io.File;
@ -32,7 +35,13 @@ import java.util.function.Supplier;
@Mod("viaforge") @Mod("viaforge")
public class ViaForge120 implements VFPlatform { public class ViaForge120 implements VFPlatform {
public static final ViaForge120 PLATFORM = new ViaForge120(); public ViaForge120() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onInit);
}
private void onInit(FMLCommonSetupEvent event) {
ViaForgeCommon.init(this);
}
@Override @Override
public int getGameVersion() { public int getGameVersion() {

View File

@ -19,7 +19,6 @@
package de.florianmichael.viaforge.mixin; package de.florianmichael.viaforge.mixin;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
import de.florianmichael.viaforge.ViaForge120;
import de.florianmichael.viaforge.common.ViaForgeCommon; import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.platform.ViaForgeConfig; import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
import de.florianmichael.viaforge.gui.GuiProtocolSelector; import de.florianmichael.viaforge.gui.GuiProtocolSelector;
@ -41,8 +40,6 @@ public class MixinTitleScreen extends Screen {
@Inject(method = "init", at = @At("RETURN")) @Inject(method = "init", at = @At("RETURN"))
public void hookViaForgeButton(CallbackInfo ci) { public void hookViaForgeButton(CallbackInfo ci) {
ViaForgeCommon.init(ViaForge120.PLATFORM);
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig(); final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
if (config.isShowMainMenuButton()) { if (config.isShowMainMenuButton()) {
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);