geforkt von Mirrors/Velocity
Modded clients can connect to vanilla servers again. Modded to modded seems to need some work still...
Dieser Commit ist enthalten in:
Ursprung
10da7daf1d
Commit
7a5857a0b2
@ -47,6 +47,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
private MinecraftConnectionAssociation association;
|
||||
private boolean isLegacyForge;
|
||||
private final VelocityServer server;
|
||||
private boolean canSendLegacyFMLResetPacket = false;
|
||||
|
||||
public MinecraftConnection(Channel channel, VelocityServer server) {
|
||||
this.channel = channel;
|
||||
@ -231,4 +232,12 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
public void setLegacyForge(boolean isForge) {
|
||||
this.isLegacyForge = isForge;
|
||||
}
|
||||
|
||||
public boolean canSendLegacyFMLResetPacket() {
|
||||
return canSendLegacyFMLResetPacket;
|
||||
}
|
||||
|
||||
public void setCanSendLegacyFMLResetPacket(boolean canSendLegacyFMLResetPacket) {
|
||||
this.canSendLegacyFMLResetPacket = isLegacyForge && canSendLegacyFMLResetPacket;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
connection.getPlayer().handleConnectionException(connection.getServerInfo(), original);
|
||||
} else if (packet instanceof JoinGame) {
|
||||
playerHandler.handleBackendJoinGame((JoinGame) packet);
|
||||
connection.setHasCompletedJoin(true);
|
||||
} else if (packet instanceof BossBar) {
|
||||
BossBar bossBar = (BossBar) packet;
|
||||
switch (bossBar.getAction()) {
|
||||
@ -74,7 +73,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
if (!connection.isModded()) {
|
||||
connection.setModded(true);
|
||||
|
||||
// We must always reset the handshake before a modded connection is established.
|
||||
// We must always reset the handshake before a modded connection is established if
|
||||
// we haven't done so already.
|
||||
connection.getPlayer().sendLegacyForgeHandshakeResetPacket();
|
||||
}
|
||||
|
||||
@ -113,13 +113,14 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
private boolean canForwardPluginMessage(PluginMessage message) {
|
||||
ClientPlaySessionHandler playerHandler =
|
||||
(ClientPlaySessionHandler) connection.getPlayer().getConnection().getSessionHandler();
|
||||
boolean isMCMessage;
|
||||
boolean isMCOrFMLMessage;
|
||||
if (connection.getMinecraftConnection().getProtocolVersion() <= ProtocolConstants.MINECRAFT_1_12_2) {
|
||||
isMCMessage = message.getChannel().startsWith("MC|");
|
||||
String channel = message.getChannel();
|
||||
isMCOrFMLMessage = channel.startsWith("MC|") || channel.startsWith(VelocityConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
||||
} else {
|
||||
isMCMessage = message.getChannel().startsWith("minecraft:");
|
||||
isMCOrFMLMessage = message.getChannel().startsWith("minecraft:");
|
||||
}
|
||||
return isMCMessage || playerHandler.getClientPluginMsgChannels().contains(message.getChannel()) ||
|
||||
return isMCOrFMLMessage || playerHandler.getClientPluginMsgChannels().contains(message.getChannel()) ||
|
||||
server.getChannelRegistrar().registered(message.getChannel());
|
||||
}
|
||||
}
|
||||
|
@ -197,6 +197,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
// Flush everything
|
||||
player.getConnection().flush();
|
||||
player.getConnectedServer().getMinecraftConnection().flush();
|
||||
player.getConnectedServer().setHasCompletedJoin(true);
|
||||
player.getConnection().setCanSendLegacyFMLResetPacket(true);
|
||||
}
|
||||
|
||||
public List<UUID> getServerBossBars() {
|
||||
|
@ -296,10 +296,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
}
|
||||
|
||||
public void sendLegacyForgeHandshakeResetPacket() {
|
||||
PluginMessage resetPacket = new PluginMessage();
|
||||
resetPacket.setChannel(VelocityConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
||||
resetPacket.setData(VelocityConstants.FORGE_LEGACY_HANDSHAKE_RESET_DATA);
|
||||
connection.write(resetPacket);
|
||||
if (connection.canSendLegacyFMLResetPacket()) {
|
||||
PluginMessage resetPacket = new PluginMessage();
|
||||
resetPacket.setChannel(VelocityConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
||||
resetPacket.setData(VelocityConstants.FORGE_LEGACY_HANDSHAKE_RESET_DATA);
|
||||
connection.write(resetPacket);
|
||||
connection.setCanSendLegacyFMLResetPacket(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void close(TextComponent reason) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren