Repository to keep up with ViaVersion on MCP (Originally from https://github.com/LaVache-FR/ViaMCP)
I have been requested (held at gun point) to also add credits to ViaForge in the README: https://github.com/FlorianMichael/ViaForge
Yes, i know they are not working right now, do not make a pull request to remove them, as i am not going to remove them.
If you are using 1.8.x as a client base, use viamcp src folder
If you are using 1.12.2 as a client base, use viamcp1_12 src folder and rename it to viamcp
You will need to add some lines of code before you can use ViaMCP
You also need to add libraries into dependencies before using this!
Add this to the main class of your client (aka injection function)
try
{
ViaMCP.getInstance().start();
// Only use one of the following
ViaMCP.getInstance().initAsyncSlider(); // For top left aligned slider
ViaMCP.getInstance().initAsyncSlider(x, y, width (min. 110), height (recommended 20)); // For custom position and size slider
}
catch (Exception e)
{
e.printStackTrace();
}
You will need to change 2 functions in NetworkManager.java
1: Name may vary, but should be func_181124_a
, createNetworkManagerAndConnect
or contain (Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group((EventLoopGroup)lazyloadbase.getValue())
After:
(1.8.x)
p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.CLIENTBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"packet_handler", (ChannelHandler)networkmanager);
(1.12.x)
p_initChannel_1_.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("splitter", new NettyVarint21FrameDecoder()).addLast("decoder", new NettyPacketDecoder(EnumPacketDirection.CLIENTBOUND)).addLast("prepender", new NettyVarint21FrameEncoder()).addLast("encoder", new NettyPacketEncoder(EnumPacketDirection.SERVERBOUND)).addLast("packet_handler", networkmanager);
Add:
if (p_initChannel_1_ instanceof SocketChannel && ViaMCP.getInstance().getVersion() != ViaMCP.PROTOCOL_VERSION)
{
UserConnection user = new UserConnectionImpl(p_initChannel_1_, true);
new ProtocolPipelineImpl(user);
p_initChannel_1_.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new MCPEncodeHandler(user)).addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new MCPDecodeHandler(user));
}
Which should look like this afterwards (1.8.x for example):
p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.CLIENTBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"packet_handler", (ChannelHandler)networkmanager);
if (p_initChannel_1_ instanceof SocketChannel && ViaMCP.getInstance().getVersion() != ViaMCP.PROTOCOL_VERSION)
{
UserConnection user = new UserConnectionImpl(p_initChannel_1_, true);
new ProtocolPipelineImpl(user);
p_initChannel_1_.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new MCPEncodeHandler(user)).addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new MCPDecodeHandler(user));
}
2: setCompressionTreshold (Yes, minecraft devs cannot spell 'Threshold')
Comment out: (Old Decoder)
this.channel.pipeline().addBefore("decoder", "decompress", new NettyCompressionDecoder(treshold));
Replace with: (New Decoder)
NettyUtil.decodeEncodePlacement(channel.pipeline(), "decoder", "decompress", new NettyCompressionDecoder(treshold));
Comment out: (Old Encoder)
this.channel.pipeline().addBefore("encoder", "compress", new NettyCompressionEncoder(treshold))
Replace with: (New Encoder)
NettyUtil.decodeEncodePlacement(channel.pipeline(), "encoder", "compress", new NettyCompressionEncoder(treshold));
You will need to add a button to access the protocol switcher (or alternatively use the version slider under this section)
In addSingleplayerMultiplayerButtons() function you will need to add the following code:
this.buttonList.add(new GuiButton(69, 5, 5, 90, 20, "Version"));
In actionPerformed(GuiButton button) function you will need to add the following code:
if (button.id == 69)
{
this.mc.displayGuiScreen(new GuiProtocolSelector(this));
}
You can also use a version slider to control ViaMCP versions
this.buttonList.add(ViaMCP.getInstance().asyncSlider);
- This should fix most peoples issues with dependencies (usually NoClassDefFoundError or ClassNotFoundException)
1: First export your client normally
2: Open your client .jar file with an archive program (winrar or 7zip for example)
3: Also open all libraries with the selected archive program (ViaBackwards, ViaRewind, ViaSnakeYml and ViaVersion)
4: From ViaBackwards drag and drop assets
and com
folders to your client .jar
5: From ViaRewind drag and drop assets
and de
folders to your client .jar
6: From ViaSnakeYaml drag and drop org
folder to your client .jar
7: From ViaVersion drag and drop assets
, com
and us
folders to your client .jar
8: Then save and close, now your client should be working correctly ;)
Credits: mordolpl (Discord)
You should now be able to use ViaMCP
If you have any problems, DM Hideri#9003 on discord!