mirror of
https://github.com/ViaVersion/ViaForge.git
synced 2024-11-28 13:05:15 +01:00
updated to new API
This commit is contained in:
parent
1cffc9c3b9
commit
c92f20ee65
@ -12,7 +12,7 @@ mod_base_package=de.enzaxd
|
||||
mixin_version=0.8.3
|
||||
|
||||
# via-version
|
||||
viaprotocolhack_version=ba5dcf9ce6
|
||||
viaversion_version=4.5.2-SNAPSHOT
|
||||
viabackwards_version=4.5.2-SNAPSHOT
|
||||
viarewind_version=2.0.2-SNAPSHOT
|
||||
vialoadingbase_version=ad5fd83ad1
|
||||
viaversion_version=4.6.0-23w04a-SNAPSHOT
|
||||
viabackwards_version=4.6.0-23w03a-SNAPSHOT
|
||||
viarewind_version=2.0.3-SNAPSHOT
|
||||
|
@ -92,7 +92,7 @@ def viaLibs = [
|
||||
"com.viaversion:viarewind-core:${project.viarewind_version}",
|
||||
"org.yaml:snakeyaml:1.29",
|
||||
|
||||
"com.github.RejectedVia:ViaProtocolHack:${project.viaprotocolhack_version}"
|
||||
"com.github.FlorianMichael:ViaLoadingBase:${project.vialoadingbase_version}"
|
||||
]
|
||||
|
||||
dependencies {
|
||||
|
@ -2,7 +2,8 @@ package de.florianmichael.viaforge;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaprotocolhack.util.VersionList;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.api.version.InternalProtocolList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@ -13,9 +14,8 @@ import java.io.IOException;
|
||||
|
||||
public class GuiProtocolSelector extends GuiScreen {
|
||||
|
||||
public SlotList list;
|
||||
|
||||
private GuiScreen parent;
|
||||
private final GuiScreen parent;
|
||||
private SlotList list;
|
||||
|
||||
public GuiProtocolSelector(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
@ -24,9 +24,7 @@ public class GuiProtocolSelector extends GuiScreen {
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
buttonList.add(new GuiButton(1, width / 2 - 100, height - 27, 200,
|
||||
20, "Back"));
|
||||
|
||||
buttonList.add(new GuiButton(1, width / 2 - 100, height - 27, 200, 20, "Back"));
|
||||
list = new SlotList(mc, width, height, 32, height - 32, 10);
|
||||
}
|
||||
|
||||
@ -34,8 +32,7 @@ public class GuiProtocolSelector extends GuiScreen {
|
||||
protected void actionPerformed(GuiButton p_actionPerformed_1_) throws IOException {
|
||||
list.actionPerformed(p_actionPerformed_1_);
|
||||
|
||||
if (p_actionPerformed_1_.id == 1)
|
||||
mc.displayGuiScreen(parent);
|
||||
if (p_actionPerformed_1_.id == 1) mc.displayGuiScreen(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,19 +58,18 @@ public class GuiProtocolSelector extends GuiScreen {
|
||||
|
||||
class SlotList extends GuiSlot {
|
||||
|
||||
|
||||
public SlotList(Minecraft p_i1052_1_, int p_i1052_2_, int p_i1052_3_, int p_i1052_4_, int p_i1052_5_, int p_i1052_6_) {
|
||||
super(p_i1052_1_, p_i1052_2_, p_i1052_3_, p_i1052_4_, p_i1052_5_, p_i1052_6_);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return VersionList.getProtocols().size();
|
||||
return InternalProtocolList.getProtocols().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementClicked(int i, boolean b, int i1, int i2) {
|
||||
ViaForge.targetVersion = VersionList.getProtocols().get(i).getVersion();
|
||||
ViaLoadingBase.getClassWrapper().reload(InternalProtocolList.getProtocols().get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,9 +84,9 @@ public class GuiProtocolSelector extends GuiScreen {
|
||||
|
||||
@Override
|
||||
protected void drawSlot(int i, int i1, int i2, int i3, int i4, int i5, float v) {
|
||||
final ProtocolVersion version = VersionList.getProtocols().get(i);
|
||||
final ProtocolVersion version = InternalProtocolList.getProtocols().get(i);
|
||||
|
||||
drawCenteredString(mc.fontRenderer,(ViaForge.targetVersion == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1);
|
||||
drawCenteredString(mc.fontRenderer,(ViaLoadingBase.getTargetVersion().getVersion() == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +1,23 @@
|
||||
package de.florianmichael.viaforge;
|
||||
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import de.florianmichael.viaprotocolhack.INativeProvider;
|
||||
import de.florianmichael.viaprotocolhack.ViaProtocolHack;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import io.netty.channel.DefaultEventLoop;
|
||||
import io.netty.channel.EventLoop;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.realms.RealmsSharedConstants;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
@Mod(modid = "viaforge", name = "ViaForge", version = "1.0.0")
|
||||
public class ViaForge implements INativeProvider {
|
||||
|
||||
public static int targetVersion = RealmsSharedConstants.NETWORK_PROTOCOL_VERSION;
|
||||
@Mod(modid = "viaforge", name = "ViaForge", version = "3.0.0")
|
||||
public class ViaForge {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLPreInitializationEvent event) throws Exception {
|
||||
ViaProtocolHack.instance().init(this, () -> System.out.println("ViaProtocolHack loaded successfully"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSinglePlayer() {
|
||||
return Minecraft.getMinecraft().isSingleplayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nativeVersion() {
|
||||
return RealmsSharedConstants.NETWORK_PROTOCOL_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int targetVersion() {
|
||||
return targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] nettyOrder() {
|
||||
return new String[] {
|
||||
"decompress",
|
||||
"compress"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public File run() {
|
||||
return Minecraft.getMinecraft().gameDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject createDump() {
|
||||
return new JsonObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventLoop eventLoop(ThreadFactory threadFactory, ExecutorService executorService) {
|
||||
return new DefaultEventLoop(executorService);
|
||||
ViaLoadingBase.ViaLoadingBaseBuilder.
|
||||
create().
|
||||
runDirectory(Minecraft.getMinecraft().gameDir).
|
||||
nativeVersion(RealmsSharedConstants.NETWORK_PROTOCOL_VERSION).
|
||||
singlePlayerProvider(() -> Minecraft.getMinecraft().isSingleplayer()).
|
||||
eventLoop(new DefaultEventLoop(ViaLoadingBase.EXECUTOR_SERVICE)).
|
||||
build();
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,8 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = {
|
||||
GuiMainMenu.class, GuiMultiplayer.class, GuiScreenServerList.class
|
||||
})
|
||||
public class MixinGuiMainMenuGuiMultiplayerGuiServerList extends GuiScreen {
|
||||
@Mixin(GuiMainMenu.class)
|
||||
public class MixinGuiMainMenu extends GuiScreen {
|
||||
|
||||
@Inject(method = "initGui", at = @At("RETURN"))
|
||||
public void hookCustomButton(CallbackInfo ci) {
|
@ -0,0 +1,26 @@
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import de.florianmichael.viaforge.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMultiplayer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(GuiMultiplayer.class)
|
||||
public class MixinGuiMultiplayer extends GuiScreen {
|
||||
|
||||
@Inject(method = "initGui", at = @At("RETURN"))
|
||||
public void hookCustomButton(CallbackInfo ci) {
|
||||
buttonList.add(new GuiButton(1337, 5, 6, 98, 20, "ViaForge"));
|
||||
}
|
||||
|
||||
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
||||
public void handleCustomButtonAction(GuiButton p_actionPerformed_1_, CallbackInfo ci) {
|
||||
if (p_actionPerformed_1_.id == 1337) {
|
||||
mc.displayGuiScreen(new GuiProtocolSelector(this));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import de.florianmichael.viaforge.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiScreenServerList;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(GuiScreenServerList.class)
|
||||
public class MixinGuiScreenServerList extends GuiScreen {
|
||||
|
||||
@Inject(method = "initGui", at = @At("RETURN"))
|
||||
public void hookCustomButton(CallbackInfo ci) {
|
||||
buttonList.add(new GuiButton(1337, 5, 6, 98, 20, "ViaForge"));
|
||||
}
|
||||
|
||||
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
||||
public void handleCustomButtonAction(GuiButton p_actionPerformed_1_, CallbackInfo ci) {
|
||||
if (p_actionPerformed_1_.id == 1337) {
|
||||
mc.displayGuiScreen(new GuiProtocolSelector(this));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import de.florianmichael.viaprotocolhack.event.PipelineReorderEvent;
|
||||
import de.florianmichael.vialoadingbase.event.PipelineReorderEvent;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -3,10 +3,10 @@ package de.florianmichael.viaforge.mixin.impl;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||
import de.florianmichael.viaforge.ViaForge;
|
||||
import de.florianmichael.viaprotocolhack.netty.CustomViaDecodeHandler;
|
||||
import de.florianmichael.viaprotocolhack.netty.CustomViaEncodeHandler;
|
||||
import de.florianmichael.viaprotocolhack.netty.NettyConstants;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.netty.CustomViaDecodeHandler;
|
||||
import de.florianmichael.vialoadingbase.netty.CustomViaEncodeHandler;
|
||||
import de.florianmichael.vialoadingbase.netty.NettyConstants;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import net.minecraft.realms.RealmsSharedConstants;
|
||||
@ -20,7 +20,7 @@ public class MixinNetworkManagerSub5 {
|
||||
|
||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||
if (channel instanceof SocketChannel && ViaForge.targetVersion != RealmsSharedConstants.NETWORK_PROTOCOL_VERSION) {
|
||||
if (channel instanceof SocketChannel && ViaLoadingBase.getTargetVersion().getVersion() != RealmsSharedConstants.NETWORK_PROTOCOL_VERSION) {
|
||||
|
||||
UserConnection user = new UserConnectionImpl(channel, true);
|
||||
new ProtocolPipelineImpl(user);
|
||||
|
@ -6,10 +6,10 @@
|
||||
"refmap": "mixins.viaforge.refmap.json",
|
||||
"mixins": [
|
||||
"MixinNetworkManager",
|
||||
"MixinNetworkManagerSub5"
|
||||
"MixinNetworkManagerSub5",
|
||||
"MixinGuiMainMenu",
|
||||
"MixinGuiMultiplayer",
|
||||
"MixinGuiScreenServerList"
|
||||
],
|
||||
"verbose": true,
|
||||
"client": [
|
||||
"MixinGuiMainMenuGuiMultiplayerGuiServerList"
|
||||
]
|
||||
"verbose": true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user