Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Support Bedrock 1.20.30 (#4115)
Dieser Commit ist enthalten in:
Ursprung
f78e6dd7e7
Commit
9a8015e8b6
@ -14,7 +14,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!
|
||||
|
||||
### Currently supporting Minecraft Bedrock 1.20.0 - 1.20.10 and Minecraft Java 1.20/1.20.1.
|
||||
### Currently supporting Minecraft Bedrock 1.20.0 - 1.20.30 and Minecraft Java 1.20/1.20.1.
|
||||
|
||||
## Setting Up
|
||||
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.
|
||||
|
@ -21,6 +21,7 @@ dependencies {
|
||||
implementation(libs.websocket)
|
||||
|
||||
api(libs.bundles.protocol)
|
||||
implementation(libs.blockstateupdater)
|
||||
|
||||
api(libs.mcauthlib)
|
||||
api(libs.mcprotocollib) {
|
||||
|
@ -28,9 +28,9 @@ package org.geysermc.geyser.network;
|
||||
import com.github.steveice10.mc.protocol.codec.MinecraftCodec;
|
||||
import com.github.steveice10.mc.protocol.codec.PacketCodec;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618;
|
||||
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
@ -46,7 +46,7 @@ public final class GameProtocol {
|
||||
* Default Bedrock codec that should act as a fallback. Should represent the latest available
|
||||
* release of the game that Geyser supports.
|
||||
*/
|
||||
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v594.CODEC;
|
||||
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v618.CODEC;
|
||||
|
||||
/**
|
||||
* A list of all supported Bedrock versions that can join Geyser
|
||||
@ -60,7 +60,12 @@ public final class GameProtocol {
|
||||
private static final PacketCodec DEFAULT_JAVA_CODEC = MinecraftCodec.CODEC;
|
||||
|
||||
static {
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v589.CODEC);
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v589.CODEC.toBuilder()
|
||||
.minecraftVersion("1.20.0/1.20.1")
|
||||
.build());
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v594.CODEC.toBuilder()
|
||||
.minecraftVersion("1.20.10/1.20.15")
|
||||
.build());
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,15 @@ import com.google.common.collect.Interners;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import org.cloudburstmc.blockstateupdater.BlockStateUpdater;
|
||||
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_10;
|
||||
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_30;
|
||||
import org.cloudburstmc.blockstateupdater.util.tagupdater.CompoundTagUpdaterContext;
|
||||
import org.cloudburstmc.nbt.*;
|
||||
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618;
|
||||
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.block.custom.CustomBlockData;
|
||||
@ -54,7 +59,6 @@ import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
@ -71,6 +75,25 @@ public final class BlockRegistryPopulator {
|
||||
POST_INIT;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface Remapper {
|
||||
|
||||
NbtMap remap(NbtMap tag);
|
||||
|
||||
static Remapper of(BlockStateUpdater... updaters) {
|
||||
CompoundTagUpdaterContext context = new CompoundTagUpdaterContext();
|
||||
for (BlockStateUpdater updater : updaters) {
|
||||
updater.registerUpdaters(context);
|
||||
}
|
||||
|
||||
return tag -> {
|
||||
NbtMapBuilder updated = context.update(tag, 0).toBuilder();
|
||||
updated.remove("version"); // we already removed this, but the context adds it. remove it again.
|
||||
return updated.build();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static void populate(Stage stage) {
|
||||
switch (stage) {
|
||||
case PRE_INIT, POST_INIT -> { nullifyBlocksNode(); }
|
||||
@ -92,52 +115,24 @@ public final class BlockRegistryPopulator {
|
||||
}
|
||||
|
||||
private static void registerBedrockBlocks() {
|
||||
BiFunction<String, NbtMapBuilder, String> emptyMapper = (bedrockIdentifier, statesBuilder) -> null;
|
||||
Remapper mapper594 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE);
|
||||
Remapper mapper618 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE);
|
||||
|
||||
// adapt 1.20 mappings to 1.20.10+
|
||||
BiFunction<String, NbtMapBuilder, String> concreteAndShulkerBoxMapper = (bedrockIdentifier, statesBuilder) -> {
|
||||
if (bedrockIdentifier.equals("minecraft:concrete")) {
|
||||
String color = (String) statesBuilder.remove("color");
|
||||
if (color.equals("silver")) {
|
||||
color = "light_gray";
|
||||
}
|
||||
return "minecraft:" + color + "_concrete";
|
||||
}
|
||||
if (bedrockIdentifier.equals("minecraft:shulker_box")) {
|
||||
String color = (String) statesBuilder.remove("color");
|
||||
if (color.equals("silver")) {
|
||||
color = "light_gray";
|
||||
}
|
||||
return "minecraft:" + color + "_shulker_box";
|
||||
}
|
||||
if (bedrockIdentifier.equals("minecraft:observer")) {
|
||||
int direction = (int) statesBuilder.remove("facing_direction");
|
||||
statesBuilder.putString("minecraft:facing_direction", switch (direction) {
|
||||
case 0 -> "down";
|
||||
case 1 -> "up";
|
||||
case 2 -> "north";
|
||||
case 3 -> "south";
|
||||
case 4 -> "west";
|
||||
default -> "east";
|
||||
});
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
ImmutableMap<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> blockMappers = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
|
||||
.put(ObjectIntPair.of("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()), emptyMapper)
|
||||
.put(ObjectIntPair.of("1_20_10", Bedrock_v594.CODEC.getProtocolVersion()), concreteAndShulkerBoxMapper)
|
||||
var blockMappers = ImmutableMap.<ObjectIntPair<String>, Remapper>builder()
|
||||
.put(ObjectIntPair.of("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()), tag -> tag)
|
||||
.put(ObjectIntPair.of("1_20_10", Bedrock_v594.CODEC.getProtocolVersion()), mapper594)
|
||||
.put(ObjectIntPair.of("1_20_30", Bedrock_v618.CODEC.getProtocolVersion()), mapper618)
|
||||
.build();
|
||||
|
||||
// We can keep this strong as nothing should be garbage collected
|
||||
// Safe to intern since Cloudburst NBT is immutable
|
||||
Interner<NbtMap> statesInterner = Interners.newStrongInterner();
|
||||
|
||||
for (Map.Entry<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> palette : blockMappers.entrySet()) {
|
||||
int protocolVersion = palette.getKey().valueInt();
|
||||
for (ObjectIntPair<String> palette : blockMappers.keySet()) {
|
||||
int protocolVersion = palette.valueInt();
|
||||
List<NbtMap> vanillaBlockStates;
|
||||
List<NbtMap> blockStates;
|
||||
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.key()));
|
||||
NBTInputStream nbtInputStream = new NBTInputStream(new DataInputStream(new GZIPInputStream(stream)), true, true)) {
|
||||
NbtMap blockPalette = (NbtMap) nbtInputStream.readTag();
|
||||
|
||||
@ -219,7 +214,7 @@ public final class BlockRegistryPopulator {
|
||||
BlockDefinition movingBlockDefinition = null;
|
||||
Iterator<Map.Entry<String, JsonNode>> blocksIterator = BLOCKS_JSON.fields();
|
||||
|
||||
BiFunction<String, NbtMapBuilder, String> stateMapper = blockMappers.getOrDefault(palette.getKey(), emptyMapper);
|
||||
Remapper stateMapper = blockMappers.get(palette);
|
||||
|
||||
GeyserBedrockBlock[] javaToBedrockBlocks = new GeyserBedrockBlock[JAVA_BLOCKS_SIZE];
|
||||
GeyserBedrockBlock[] javaToVanillaBedrockBlocks = new GeyserBedrockBlock[JAVA_BLOCKS_SIZE];
|
||||
@ -234,15 +229,22 @@ public final class BlockRegistryPopulator {
|
||||
javaRuntimeId++;
|
||||
Map.Entry<String, JsonNode> entry = blocksIterator.next();
|
||||
String javaId = entry.getKey();
|
||||
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.get(buildBedrockState(entry.getValue(), stateMapper));
|
||||
|
||||
NbtMap originalBedrockTag = buildBedrockState(entry.getValue());
|
||||
NbtMap bedrockTag = stateMapper.remap(originalBedrockTag);
|
||||
|
||||
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.get(bedrockTag);
|
||||
|
||||
GeyserBedrockBlock bedrockDefinition;
|
||||
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);
|
||||
if (blockStateOverride == null) {
|
||||
bedrockDefinition = vanillaBedrockDefinition;
|
||||
if (bedrockDefinition == null) {
|
||||
throw new RuntimeException("Unable to find " + javaId + " Bedrock runtime ID! Built NBT tag: \n" +
|
||||
palette.getKey().key() + buildBedrockState(entry.getValue(), stateMapper));
|
||||
throw new RuntimeException("""
|
||||
Unable to find %s Bedrock runtime ID for %s! Original block tag:
|
||||
%s
|
||||
Updated block tag:
|
||||
%s""".formatted(javaId, palette.key(), originalBedrockTag, bedrockTag));
|
||||
}
|
||||
} else {
|
||||
bedrockDefinition = customBlockStateDefinitions.get(blockStateOverride);
|
||||
@ -338,7 +340,7 @@ public final class BlockRegistryPopulator {
|
||||
}
|
||||
});
|
||||
|
||||
BlockRegistries.BLOCKS.register(palette.getKey().valueInt(), builder.bedrockRuntimeMap(bedrockRuntimeMap)
|
||||
BlockRegistries.BLOCKS.register(palette.valueInt(), builder.bedrockRuntimeMap(bedrockRuntimeMap)
|
||||
.javaToBedrockBlocks(javaToBedrockBlocks)
|
||||
.javaToVanillaBedrockBlocks(javaToVanillaBedrockBlocks)
|
||||
.stateDefinitionMap(blockStateOrderedMap)
|
||||
@ -575,7 +577,7 @@ public final class BlockRegistryPopulator {
|
||||
return blockStateSet;
|
||||
}
|
||||
|
||||
private static NbtMap buildBedrockState(JsonNode node, BiFunction<String, NbtMapBuilder, String> statesMapper) {
|
||||
private static NbtMap buildBedrockState(JsonNode node) {
|
||||
NbtMapBuilder tagBuilder = NbtMap.builder();
|
||||
String bedrockIdentifier = node.get("bedrock_identifier").textValue();
|
||||
tagBuilder.putString("name", bedrockIdentifier);
|
||||
@ -597,10 +599,6 @@ public final class BlockRegistryPopulator {
|
||||
}
|
||||
}
|
||||
}
|
||||
String newIdentifier = statesMapper.apply(bedrockIdentifier, statesBuilder);
|
||||
if (newIdentifier != null) {
|
||||
tagBuilder.putString("name", newIdentifier);
|
||||
}
|
||||
tagBuilder.put("states", statesBuilder.build());
|
||||
return tagBuilder.build();
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
import org.cloudburstmc.nbt.NbtType;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618;
|
||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
||||
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
|
||||
@ -86,10 +87,8 @@ public class ItemRegistryPopulator {
|
||||
}
|
||||
|
||||
public static void populate() {
|
||||
List<PaletteVersion> paletteVersions = new ArrayList<>(2);
|
||||
paletteVersions.add(new PaletteVersion("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()));
|
||||
paletteVersions.add(new PaletteVersion("1_20_10", Bedrock_v594.CODEC.getProtocolVersion(), Collections.emptyMap(), (item, mapping) -> {
|
||||
// Forward-map 1.20 mappings to 1.20.10
|
||||
Remapper remapper594 = (item, mapping) -> {
|
||||
// 1.20.10+ received parity for concrete and shulker boxes
|
||||
String id = item.javaIdentifier();
|
||||
if (id.endsWith("_concrete") || id.endsWith("_shulker_box")) {
|
||||
@ -98,7 +97,25 @@ public class ItemRegistryPopulator {
|
||||
return mapping.withBedrockIdentifier(id);
|
||||
}
|
||||
return mapping;
|
||||
}));
|
||||
};
|
||||
// 1.20 to 1.20.30
|
||||
Remapper remapper618 = (item, mapping) -> {
|
||||
mapping = remapper594.remap(item, mapping); // apply 1.20.10 remapper first
|
||||
|
||||
String id = item.javaIdentifier();
|
||||
if (id.endsWith("concrete_powder") || id.contains("stained_glass") || (id.endsWith("_terracotta") && !id.contains("glazed"))) {
|
||||
// parity: concrete powder, stained-glass blocks and panes, and coloured terracotta
|
||||
// 1. 'minecraft:terracotta' is still 'minecraft:hardened_clay'
|
||||
// 2. there were no changes for glazed, but it doesn't have full parity, so ignore it.
|
||||
return mapping.withBedrockIdentifier(id);
|
||||
}
|
||||
return mapping;
|
||||
};
|
||||
|
||||
List<PaletteVersion> paletteVersions = new ArrayList<>(3);
|
||||
paletteVersions.add(new PaletteVersion("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()));
|
||||
paletteVersions.add(new PaletteVersion("1_20_10", Bedrock_v594.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper594));
|
||||
paletteVersions.add(new PaletteVersion("1_20_30", Bedrock_v618.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper618));
|
||||
|
||||
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
|
||||
|
||||
|
BIN
core/src/main/resources/bedrock/block_palette.1_20_30.nbt
Normale Datei
BIN
core/src/main/resources/bedrock/block_palette.1_20_30.nbt
Normale Datei
Binäre Datei nicht angezeigt.
5787
core/src/main/resources/bedrock/creative_items.1_20_30.json
Normale Datei
5787
core/src/main/resources/bedrock/creative_items.1_20_30.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
5570
core/src/main/resources/bedrock/runtime_item_states.1_20_30.json
Normale Datei
5570
core/src/main/resources/bedrock/runtime_item_states.1_20_30.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1 +1 @@
|
||||
Subproject commit d44a1e36059aba666b66e6c545b054c86c1fadac
|
||||
Subproject commit 587220aafb55e80f2a70d6eac2d4b89dc0a005bd
|
@ -9,9 +9,10 @@ netty = "4.1.80.Final"
|
||||
guava = "29.0-jre"
|
||||
gson = "2.3.1" # Provided by Spigot 1.8.8
|
||||
websocket = "1.5.1"
|
||||
protocol = "3.0.0.Beta1-20230718.000033-102"
|
||||
protocol-connection = "3.0.0.Beta1-20230718.000033-101"
|
||||
protocol = "3.0.0.Beta1-20230908.171156-106"
|
||||
protocol-connection = "3.0.0.Beta1-20230908.171156-105"
|
||||
raknet = "1.0.0.CR1-20230703.195238-9"
|
||||
blockstateupdater="1.20.30-20230911.121922-2"
|
||||
mcauthlib = "d9d773e"
|
||||
mcprotocollib = "1.20-2-20230827.192136-1"
|
||||
adventure = "4.14.0"
|
||||
@ -97,6 +98,8 @@ protocol-common = { group = "org.cloudburstmc.protocol", name = "common", versio
|
||||
protocol-codec = { group = "org.cloudburstmc.protocol", name = "bedrock-codec", version.ref = "protocol" }
|
||||
protocol-connection = { group = "org.cloudburstmc.protocol", name = "bedrock-connection", version.ref = "protocol-connection" }
|
||||
|
||||
blockstateupdater = { group = "org.cloudburstmc", name = "block-state-updater", version.ref = "blockstateupdater"}
|
||||
|
||||
[bundles]
|
||||
jackson = [ "jackson-annotations", "jackson-core", "jackson-dataformat-yaml" ]
|
||||
fastutil = [ "fastutil-int-int-maps", "fastutil-int-long-maps", "fastutil-int-byte-maps", "fastutil-int-boolean-maps", "fastutil-object-int-maps", "fastutil-object-object-maps" ]
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren