Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
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 MinecraftConnectionAssociation association;
|
||||||
private boolean isLegacyForge;
|
private boolean isLegacyForge;
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
|
private boolean canSendLegacyFMLResetPacket = false;
|
||||||
|
|
||||||
public MinecraftConnection(Channel channel, VelocityServer server) {
|
public MinecraftConnection(Channel channel, VelocityServer server) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
@ -231,4 +232,12 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
|||||||
public void setLegacyForge(boolean isForge) {
|
public void setLegacyForge(boolean isForge) {
|
||||||
this.isLegacyForge = 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);
|
connection.getPlayer().handleConnectionException(connection.getServerInfo(), original);
|
||||||
} else if (packet instanceof JoinGame) {
|
} else if (packet instanceof JoinGame) {
|
||||||
playerHandler.handleBackendJoinGame((JoinGame) packet);
|
playerHandler.handleBackendJoinGame((JoinGame) packet);
|
||||||
connection.setHasCompletedJoin(true);
|
|
||||||
} else if (packet instanceof BossBar) {
|
} else if (packet instanceof BossBar) {
|
||||||
BossBar bossBar = (BossBar) packet;
|
BossBar bossBar = (BossBar) packet;
|
||||||
switch (bossBar.getAction()) {
|
switch (bossBar.getAction()) {
|
||||||
@ -74,7 +73,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
if (!connection.isModded()) {
|
if (!connection.isModded()) {
|
||||||
connection.setModded(true);
|
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();
|
connection.getPlayer().sendLegacyForgeHandshakeResetPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,13 +113,14 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
private boolean canForwardPluginMessage(PluginMessage message) {
|
private boolean canForwardPluginMessage(PluginMessage message) {
|
||||||
ClientPlaySessionHandler playerHandler =
|
ClientPlaySessionHandler playerHandler =
|
||||||
(ClientPlaySessionHandler) connection.getPlayer().getConnection().getSessionHandler();
|
(ClientPlaySessionHandler) connection.getPlayer().getConnection().getSessionHandler();
|
||||||
boolean isMCMessage;
|
boolean isMCOrFMLMessage;
|
||||||
if (connection.getMinecraftConnection().getProtocolVersion() <= ProtocolConstants.MINECRAFT_1_12_2) {
|
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 {
|
} 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());
|
server.getChannelRegistrar().registered(message.getChannel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,6 +197,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
// Flush everything
|
// Flush everything
|
||||||
player.getConnection().flush();
|
player.getConnection().flush();
|
||||||
player.getConnectedServer().getMinecraftConnection().flush();
|
player.getConnectedServer().getMinecraftConnection().flush();
|
||||||
|
player.getConnectedServer().setHasCompletedJoin(true);
|
||||||
|
player.getConnection().setCanSendLegacyFMLResetPacket(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UUID> getServerBossBars() {
|
public List<UUID> getServerBossBars() {
|
||||||
|
@ -296,10 +296,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendLegacyForgeHandshakeResetPacket() {
|
public void sendLegacyForgeHandshakeResetPacket() {
|
||||||
PluginMessage resetPacket = new PluginMessage();
|
if (connection.canSendLegacyFMLResetPacket()) {
|
||||||
resetPacket.setChannel(VelocityConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
PluginMessage resetPacket = new PluginMessage();
|
||||||
resetPacket.setData(VelocityConstants.FORGE_LEGACY_HANDSHAKE_RESET_DATA);
|
resetPacket.setChannel(VelocityConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
||||||
connection.write(resetPacket);
|
resetPacket.setData(VelocityConstants.FORGE_LEGACY_HANDSHAKE_RESET_DATA);
|
||||||
|
connection.write(resetPacket);
|
||||||
|
connection.setCanSendLegacyFMLResetPacket(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close(TextComponent reason) {
|
public void close(TextComponent reason) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren