3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Initial support for 1.19.20 Bedrock

Dieser Commit ist enthalten in:
Camotoy 2022-08-07 12:09:54 -04:00
Ursprung 3c27273eac
Commit f74713c0ed
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
6 geänderte Dateien mit 24 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -128,8 +128,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId> <groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-v534</artifactId> <artifactId>bedrock-v544</artifactId>
<version>a78a64b</version> <version>92d9854</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

Datei anzeigen

@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.codec.PacketCodec;
import com.nukkitx.protocol.bedrock.BedrockPacketCodec; import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import com.nukkitx.protocol.bedrock.v527.Bedrock_v527; import com.nukkitx.protocol.bedrock.v527.Bedrock_v527;
import com.nukkitx.protocol.bedrock.v534.Bedrock_v534; import com.nukkitx.protocol.bedrock.v534.Bedrock_v534;
import com.nukkitx.protocol.bedrock.v544.Bedrock_v544;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import java.util.ArrayList; import java.util.ArrayList;
@ -63,6 +64,7 @@ public final class MinecraftProtocol {
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder() SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
.minecraftVersion("1.19.10/1.19.11") .minecraftVersion("1.19.10/1.19.11")
.build()); .build());
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v544.V544_CODEC);
} }
/** /**

Datei anzeigen

@ -30,6 +30,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.nukkitx.nbt.*; import com.nukkitx.nbt.*;
import com.nukkitx.protocol.bedrock.v527.Bedrock_v527; import com.nukkitx.protocol.bedrock.v527.Bedrock_v527;
import com.nukkitx.protocol.bedrock.v544.Bedrock_v544;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
@ -56,17 +57,7 @@ import java.util.zip.GZIPInputStream;
/** /**
* Populates the block registries. * Populates the block registries.
*/ */
public class BlockRegistryPopulator { public final class BlockRegistryPopulator {
private static final ImmutableMap<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> BLOCK_MAPPERS;
private static final BiFunction<String, NbtMapBuilder, String> EMPTY_MAPPER = (bedrockIdentifier, statesBuilder) -> null;
static {
ImmutableMap.Builder<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> stateMapperBuilder = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
.put(ObjectIntPair.of("1_19_0", Bedrock_v527.V527_CODEC.getProtocolVersion()), EMPTY_MAPPER);
BLOCK_MAPPERS = stateMapperBuilder.build();
}
/** /**
* Stores the raw blocks JSON until it is no longer needed. * Stores the raw blocks JSON until it is no longer needed.
*/ */
@ -80,7 +71,17 @@ public class BlockRegistryPopulator {
} }
private static void registerBedrockBlocks() { private static void registerBedrockBlocks() {
for (Map.Entry<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> palette : BLOCK_MAPPERS.entrySet()) { BiFunction<String, NbtMapBuilder, String> emptyMapper = (bedrockIdentifier, statesBuilder) -> null;
ImmutableMap<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> blockMappers = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
.put(ObjectIntPair.of("1_19_0", Bedrock_v527.V527_CODEC.getProtocolVersion()), (bedrockIdentifier, statesBuilder) -> {
if (bedrockIdentifier.equals("minecraft:muddy_mangrove_roots")) {
statesBuilder.remove("pillar_axis");
}
return null;
})
.put(ObjectIntPair.of("1_19_20", Bedrock_v544.V544_CODEC.getProtocolVersion()), emptyMapper).build();
for (Map.Entry<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> palette : blockMappers.entrySet()) {
NbtList<NbtMap> blocksTag; NbtList<NbtMap> blocksTag;
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResource(String.format("bedrock/block_palette.%s.nbt", palette.getKey().key())); try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResource(String.format("bedrock/block_palette.%s.nbt", palette.getKey().key()));
NBTInputStream nbtInputStream = new NBTInputStream(new DataInputStream(new GZIPInputStream(stream)), true, true)) { NBTInputStream nbtInputStream = new NBTInputStream(new DataInputStream(new GZIPInputStream(stream)), true, true)) {
@ -95,7 +96,9 @@ public class BlockRegistryPopulator {
int stateVersion = -1; int stateVersion = -1;
for (int i = 0; i < blocksTag.size(); i++) { for (int i = 0; i < blocksTag.size(); i++) {
NbtMap tag = blocksTag.get(i); NbtMapBuilder builder = blocksTag.get(i).toBuilder();
builder.remove("name_hash"); // Quick workaround - was added in 1.19.20
NbtMap tag = builder.build();
if (blockStateOrderedMap.containsKey(tag)) { if (blockStateOrderedMap.containsKey(tag)) {
throw new AssertionError("Duplicate block states in Bedrock palette: " + tag); throw new AssertionError("Duplicate block states in Bedrock palette: " + tag);
} }
@ -111,7 +114,7 @@ public class BlockRegistryPopulator {
int movingBlockRuntimeId = -1; int movingBlockRuntimeId = -1;
Iterator<Map.Entry<String, JsonNode>> blocksIterator = BLOCKS_JSON.fields(); Iterator<Map.Entry<String, JsonNode>> blocksIterator = BLOCKS_JSON.fields();
BiFunction<String, NbtMapBuilder, String> stateMapper = BLOCK_MAPPERS.getOrDefault(palette.getKey(), EMPTY_MAPPER); BiFunction<String, NbtMapBuilder, String> stateMapper = blockMappers.getOrDefault(palette.getKey(), emptyMapper);
int[] javaToBedrockBlocks = new int[BLOCKS_JSON.size()]; int[] javaToBedrockBlocks = new int[BLOCKS_JSON.size()];

Datei anzeigen

@ -1491,6 +1491,8 @@ public class GeyserSession implements GeyserConnection, CommandSender {
startGamePacket.setPlayerPropertyData(NbtMap.EMPTY); startGamePacket.setPlayerPropertyData(NbtMap.EMPTY);
startGamePacket.setWorldTemplateId(UUID.randomUUID()); startGamePacket.setWorldTemplateId(UUID.randomUUID());
startGamePacket.setChatRestrictionLevel(ChatRestrictionLevel.NONE);
SyncedPlayerMovementSettings settings = new SyncedPlayerMovementSettings(); SyncedPlayerMovementSettings settings = new SyncedPlayerMovementSettings();
settings.setMovementMode(AuthoritativeMovementMode.CLIENT); settings.setMovementMode(AuthoritativeMovementMode.CLIENT);
settings.setRewindHistorySize(0); settings.setRewindHistorySize(0);

Binäre Datei nicht angezeigt.

@ -1 +1 @@
Subproject commit 0127891232742209b8470298dfd997249c506320 Subproject commit 2c68dab9d751f78b2f5b0298da5e338ad6bc07ca