3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-03 16:31:14 +02:00

Merge remote-tracking branch 'origin/new-mcpl' into new-mcpl

Dieser Commit ist enthalten in:
AlexProgrammerDE 2024-08-25 09:47:11 +02:00
Commit c6f4c7a9ee
6 geänderte Dateien mit 45 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -15,7 +15,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
## Supported Versions
Geyser is currently supporting Minecraft Bedrock 1.20.80 - 1.21.20 and Minecraft Java Server 1.21/1.21.1. For more info please see [here](https://geysermc.org/wiki/geyser/supported-versions/).
Geyser is currently supporting Minecraft Bedrock 1.20.80 - 1.21.21 and Minecraft Java 1.21/1.21.1. For more information, please see [here](https://geysermc.org/wiki/geyser/supported-versions/).
## Setting Up
Take a look [here](https://geysermc.org/wiki/geyser/setup/) for how to set up Geyser.

Datei anzeigen

@ -50,7 +50,7 @@ public final class GameProtocol {
* release of the game that Geyser supports.
*/
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = CodecProcessor.processCodec(Bedrock_v712.CODEC.toBuilder()
.minecraftVersion("1.21.20")
.minecraftVersion("1.21.20/1.21.21")
.build());
/**

Datei anzeigen

@ -84,10 +84,11 @@ public final class GeyserServer {
/*
The following constants are all used to ensure the ping does not reach a length where it is unparsable by the Bedrock client
*/
private static final int MINECRAFT_VERSION_BYTES_LENGTH = GameProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion().getBytes(StandardCharsets.UTF_8).length;
private static final String PING_VERSION = pingVersion();
private static final int PING_VERSION_BYTES_LENGTH = PING_VERSION.getBytes(StandardCharsets.UTF_8).length;
private static final int BRAND_BYTES_LENGTH = GeyserImpl.NAME.getBytes(StandardCharsets.UTF_8).length;
/**
* The MOTD, sub-MOTD and Minecraft version ({@link #MINECRAFT_VERSION_BYTES_LENGTH}) combined cannot reach this length.
* The MOTD, sub-MOTD and Minecraft version ({@link #PING_VERSION_BYTES_LENGTH}) combined cannot reach this length.
*/
private static final int MAGIC_RAKNET_LENGTH = 338;
@ -316,7 +317,7 @@ public final class GeyserServer {
.gameType("Survival") // Can only be Survival or Creative as of 1.16.210.59
.nintendoLimited(false)
.protocolVersion(GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion())
.version(GameProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()) // Required to not be empty as of 1.16.210.59. Can only contain . and numbers.
.version(PING_VERSION)
.ipv4Port(this.broadcastPort)
.ipv6Port(this.broadcastPort)
.serverId(channel.config().getOption(RakChannelOption.RAK_GUID));
@ -367,15 +368,15 @@ public final class GeyserServer {
// We don't know why, though
byte[] motdArray = pong.motd().getBytes(StandardCharsets.UTF_8);
int subMotdLength = pong.subMotd().getBytes(StandardCharsets.UTF_8).length;
if (motdArray.length + subMotdLength > (MAGIC_RAKNET_LENGTH - MINECRAFT_VERSION_BYTES_LENGTH)) {
if (motdArray.length + subMotdLength > (MAGIC_RAKNET_LENGTH - PING_VERSION_BYTES_LENGTH)) {
// Shorten the sub-MOTD first since that only appears locally
if (subMotdLength > BRAND_BYTES_LENGTH) {
pong.subMotd(GeyserImpl.NAME);
subMotdLength = BRAND_BYTES_LENGTH;
}
if (motdArray.length > (MAGIC_RAKNET_LENGTH - MINECRAFT_VERSION_BYTES_LENGTH - subMotdLength)) {
if (motdArray.length > (MAGIC_RAKNET_LENGTH - PING_VERSION_BYTES_LENGTH - subMotdLength)) {
// If the top MOTD is still too long, we chop it down
byte[] newMotdArray = new byte[MAGIC_RAKNET_LENGTH - MINECRAFT_VERSION_BYTES_LENGTH - subMotdLength];
byte[] newMotdArray = new byte[MAGIC_RAKNET_LENGTH - PING_VERSION_BYTES_LENGTH - subMotdLength];
System.arraycopy(motdArray, 0, newMotdArray, 0, newMotdArray.length);
pong.motd(new String(newMotdArray, StandardCharsets.UTF_8));
}
@ -390,6 +391,17 @@ public final class GeyserServer {
return pong;
}
private static String pingVersion() {
// BedrockPong version is required to not be empty as of 1.16.210.59.
// Can only contain . and numbers, so use the latest version instead of sending all
var version = GameProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion();
var versionSplit = version.split("/");
if (versionSplit.length > 1) {
version = versionSplit[versionSplit.length - 1];
}
return version;
}
/**
* @return the throwable from the given supplier, or the throwable caught while calling the supplier.
*/

Datei anzeigen

@ -91,7 +91,6 @@ public final class LocalSession extends TcpSession {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast("sizer", new TcpPacketSizer(LocalSession.this, protocol.getPacketHeader().getLengthSize()));
pipeline.addLast("flow-control", new TcpFlowControlHandler());
pipeline.addLast("codec", new TcpPacketCodec(LocalSession.this, true));
pipeline.addLast("manager", LocalSession.this);

Datei anzeigen

@ -88,6 +88,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
if (a == null || b == null) return false;
if ("help".equals(a.name()) && !"help".equals(b.name())) {
// Merging this causes Bedrock to fallback to its own help command
// Tested on Paper 1.20.4 with Essentials and Bedrock 1.21
// https://github.com/GeyserMC/Geyser/issues/2573
return false;
}
@ -124,8 +125,9 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
if (!session.getGeyser().getConfig().isCommandSuggestions()) {
session.getGeyser().getLogger().debug("Not sending translated command suggestions as they are disabled.");
// Send an empty packet so Bedrock doesn't override /help with its own, built-in help command.
// Send a mostly empty packet so Bedrock doesn't override /help with its own, built-in help command.
AvailableCommandsPacket emptyPacket = new AvailableCommandsPacket();
emptyPacket.getCommands().add(createFakeHelpCommand());
session.sendUpstreamPacket(emptyPacket);
return;
}
@ -182,6 +184,8 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
// The command flags, set to NOT_CHEAT so known commands can be used while achievements are enabled.
Set<CommandData.Flag> flags = Set.of(CommandData.Flag.NOT_CHEAT);
boolean helpAdded = false;
// Loop through all the found commands
for (Map.Entry<BedrockCommandInfo, Set<String>> entry : commands.entrySet()) {
String commandName = entry.getValue().iterator().next(); // We know this has a value
@ -198,6 +202,15 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
// Build the completed command and add it to the final list
CommandData data = new CommandData(commandName, entry.getKey().description(), flags, CommandPermission.ANY, aliases, Collections.emptyList(), entry.getKey().paramData());
commandData.add(data);
if (commandName.equals("help")) {
helpAdded = true;
}
}
if (!helpAdded) {
// https://github.com/GeyserMC/Geyser/issues/2573 if Brigadier does not send the help command.
commandData.add(createFakeHelpCommand());
}
// Add our commands to the AvailableCommandsPacket for the bedrock client
@ -286,6 +299,11 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
};
}
private CommandData createFakeHelpCommand() {
CommandEnumData aliases = new CommandEnumData("helpAliases", Map.of("help", EnumSet.of(CommandEnumConstraint.ALLOW_ALIASES)), false);
return new CommandData("help", "", Set.of(CommandData.Flag.NOT_CHEAT), CommandPermission.ANY, aliases, Collections.emptyList(), new CommandOverloadData[0]);
}
/**
* Stores the command description and parameter data for best optimizing the Bedrock commands packet.
*/

Datei anzeigen

@ -10,7 +10,9 @@ netty-io-uring = "0.0.25.Final-SNAPSHOT"
guava = "29.0-jre"
gson = "2.3.1" # Provided by Spigot 1.8.8
websocket = "1.5.1"
protocol = "3.0.0.Beta3-20240814.133201-7"
protocol-connection = "3.0.0.Beta3-20240819.124045-12"
protocol-common = "3.0.0.Beta3-20240819.124045-10"
protocol-codec = "3.0.0.Beta3-20240819.124045-13"
raknet = "1.0.0.CR3-20240416.144209-1"
minecraftauth = "4.1.1-20240806.235051-7"
mcprotocollib = "324f066"
@ -125,9 +127,9 @@ viaproxy = { group = "net.raphimc", name = "ViaProxy", version.ref = "viaproxy"
viaversion = { group = "com.viaversion", name = "viaversion", version.ref = "viaversion" }
websocket = { group = "org.java-websocket", name = "Java-WebSocket", version.ref = "websocket" }
protocol-common = { group = "org.cloudburstmc.protocol", name = "common", version.ref = "protocol" }
protocol-codec = { group = "org.cloudburstmc.protocol", name = "bedrock-codec", version.ref = "protocol" }
protocol-connection = { group = "org.cloudburstmc.protocol", name = "bedrock-connection", version.ref = "protocol" }
protocol-common = { group = "org.cloudburstmc.protocol", name = "common", version.ref = "protocol-common" }
protocol-codec = { group = "org.cloudburstmc.protocol", name = "bedrock-codec", version.ref = "protocol-codec" }
protocol-connection = { group = "org.cloudburstmc.protocol", name = "bedrock-connection", version.ref = "protocol-connection" }
math = { group = "org.cloudburstmc.math", name = "immutable", version = "2.0" }