Skip to content

Commit

Permalink
Fixed ViaVersion loading
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jun 8, 2023
1 parent 57fde74 commit 110264b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mc1122/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ dependencies {
include "org.spongepowered:mixin:${mixin_version}"

for (final def via in viaLibs) {
implementation(via)
include(via)
}

annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
Expand Down
30 changes: 21 additions & 9 deletions mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,22 @@
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.raphimc.vialoader.ViaLoader;
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
import net.raphimc.vialoader.impl.viaversion.VLInjector;
import net.raphimc.vialoader.impl.viaversion.VLLoader;
import net.raphimc.vialoader.netty.VLLegacyPipeline;
import net.raphimc.vialoader.util.VersionEnum;

@Mod(modid = "viaforge", name = "ViaForge", version = "3.3.3")
public class ViaForge {
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_12_2;

public static VersionEnum targetVersion = VersionEnum.r1_12_2;

@Mod.EventHandler
public void init(FMLPreInitializationEvent event) {
VersionEnum.SORTED_VERSIONS.remove(VersionEnum.r1_7_6tor1_7_10);
VersionEnum.SORTED_VERSIONS.remove(VersionEnum.r1_7_2tor1_7_5);
private static boolean loaded;

public static void initViaVersion() {
if (loaded) return;

ViaLoader.init(
null,
Expand All @@ -56,11 +54,25 @@ public int getClosestServerProtocol(UserConnection connection) throws Exception
return super.getClosestServerProtocol(connection);
}
});

VersionEnum.SORTED_VERSIONS.remove(VersionEnum.r1_7_6tor1_7_10);
VersionEnum.SORTED_VERSIONS.remove(VersionEnum.r1_7_2tor1_7_5);
}
},
new VLInjector() {
@Override
public String getDecoderName() {
return VLLegacyPipeline.VIA_DECODER_NAME;
}

@Override
public String getEncoderName() {
return VLLegacyPipeline.VIA_ENCODER_NAME;
}
},
null,
null,
ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new
);
loaded = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package de.florianmichael.viaforge.mixin.impl;

import de.florianmichael.viaforge.ViaForge;
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
import net.minecraft.client.gui.*;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -30,6 +31,8 @@ public class MixinGuiMainMenu extends GuiScreen {
@Inject(method = "initGui", at = @At("RETURN"))
public void hookCustomButton(CallbackInfo ci) {
buttonList.add(new GuiButton(1337, 5, 6, 98, 20, "ViaForge"));

ViaForge.initViaVersion();
}

@Inject(method = "actionPerformed", at = @At("RETURN"))
Expand Down

0 comments on commit 110264b

Please sign in to comment.