FML3 support

This commit is contained in:
Adrian Bergqvist 2023-05-07 16:25:28 +02:00
parent e754f58623
commit b8c905e619
No known key found for this signature in database
GPG Key ID: 3B3DA43224B79417
4 changed files with 19 additions and 8 deletions

View File

@ -5,7 +5,7 @@ plugins {
}
group = "org.adde0109"
version = "1.4.0-beta"
version = "1.4.0-beta-rc1"
repositories {
mavenCentral()

View File

@ -40,7 +40,7 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3;
import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet;
@Plugin(id = "ambassador", name = "Ambassador", version = "1.4.0-beta", authors = {"adde0109"})
@Plugin(id = "ambassador", name = "Ambassador", version = "1.4.0-beta-rc1", authors = {"adde0109"})
public class Ambassador {
public ProxyServer server;

View File

@ -71,13 +71,23 @@ public class ForgeHandshakeUtils {
return dataAndPacketIdStream.toByteArray();
}
public static final byte[] emptyModlist = generateEmptyModlist();
private static byte[] generateEmptyModlist() {
public static final byte[] emptyModlistFML2 = generateEmptyModlist(2);
public static final byte[] emptyModlistFML3 = generateEmptyModlist(3);
private static byte[] generateEmptyModlist(int fmlVersion) {
ByteArrayDataOutput dataAndPacketIdStream = ByteStreams.newDataOutput();
writeVarInt(dataAndPacketIdStream,1);
writeVarInt(dataAndPacketIdStream,0);
writeVarInt(dataAndPacketIdStream,0);
writeVarInt(dataAndPacketIdStream,0);
writeVarInt(dataAndPacketIdStream,0); //Mods
if (fmlVersion == 3) {
writeVarInt(dataAndPacketIdStream,1); //Channels
writeUtf(dataAndPacketIdStream, "forge:tier_sorting");
writeUtf(dataAndPacketIdStream,"1.0");
writeVarInt(dataAndPacketIdStream,0); //Registries
writeVarInt(dataAndPacketIdStream,0); //Data-packs
} else {
writeVarInt(dataAndPacketIdStream,0); //Channels
writeVarInt(dataAndPacketIdStream,0); //Registries
}
ByteArrayDataOutput stream = ByteStreams.newDataOutput();
byte[] dataAndPacketId = dataAndPacketIdStream.toByteArray();

View File

@ -152,7 +152,8 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
public void sendVanillaModlist(ConnectedPlayer player) {
player.getConnection().write(new LoginPluginMessage(0, "fml:loginwrapper",
Unpooled.wrappedBuffer(ForgeHandshakeUtils.emptyModlist)));
Unpooled.wrappedBuffer(player.getConnection().getType() == ForgeConstants.ForgeFML3 ?
ForgeHandshakeUtils.emptyModlistFML3 : ForgeHandshakeUtils.emptyModlistFML2)));
ForgeLoginWrapperDecoder decoder = (ForgeLoginWrapperDecoder) player.getConnection()
.getChannel().pipeline().get(ForgeConstants.FORGE_HANDSHAKE_DECODER);