mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Allow 1.19.0 to join and use new block mappings
This commit is contained in:
parent
1a7b57018e
commit
c5de293373
9 changed files with 10066 additions and 47 deletions
|
@ -28,6 +28,7 @@ package org.geysermc.geyser.network;
|
|||
import com.github.steveice10.mc.protocol.codec.MinecraftCodec;
|
||||
import com.github.steveice10.mc.protocol.codec.PacketCodec;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||
import com.nukkitx.protocol.bedrock.beta.BedrockBeta;
|
||||
import com.nukkitx.protocol.bedrock.v503.Bedrock_v503;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -43,7 +44,7 @@ public final class MinecraftProtocol {
|
|||
* Default Bedrock codec that should act as a fallback. Should represent the latest available
|
||||
* release of the game that Geyser supports.
|
||||
*/
|
||||
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v503.V503_CODEC;
|
||||
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = BedrockBeta.BETA_CODEC;
|
||||
/**
|
||||
* A list of all supported Bedrock versions that can join Geyser
|
||||
*/
|
||||
|
@ -56,9 +57,13 @@ public final class MinecraftProtocol {
|
|||
private static final PacketCodec DEFAULT_JAVA_CODEC = MinecraftCodec.CODEC;
|
||||
|
||||
static {
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v503.V503_CODEC.toBuilder()
|
||||
.minecraftVersion("1.18.30/1.18.31")
|
||||
.build());
|
||||
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
|
||||
.minecraftVersion("1.19.0")
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -164,6 +164,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||
// Allow custom items to work
|
||||
stackPacket.getExperiments().add(new ExperimentData("data_driven_items", true));
|
||||
}
|
||||
stackPacket.getExperiments().add(new ExperimentData("wild_update", true));
|
||||
|
||||
session.sendUpstreamPacket(stackPacket);
|
||||
break;
|
||||
|
|
|
@ -28,8 +28,7 @@ package org.geysermc.geyser.registry.populator;
|
|||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.nukkitx.nbt.*;
|
||||
import com.nukkitx.protocol.bedrock.v475.Bedrock_v475;
|
||||
import com.nukkitx.protocol.bedrock.v486.Bedrock_v486;
|
||||
import com.nukkitx.protocol.bedrock.beta.BedrockBeta;
|
||||
import com.nukkitx.protocol.bedrock.v503.Bedrock_v503;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
@ -61,51 +60,94 @@ public 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;
|
||||
|
||||
private static final BiFunction<String, NbtMapBuilder, String> V486_MAPPER = (bedrockIdentifier, statesBuilder) -> {
|
||||
statesBuilder.remove("no_drop_bit"); // Used in skulls
|
||||
if (bedrockIdentifier.equals("minecraft:glow_lichen")) {
|
||||
// Moved around north, south, west
|
||||
int bits = (int) statesBuilder.get("multi_face_direction_bits");
|
||||
boolean north = (bits & (1 << 2)) != 0;
|
||||
boolean south = (bits & (1 << 3)) != 0;
|
||||
boolean west = (bits & (1 << 4)) != 0;
|
||||
if (north) {
|
||||
bits |= 1 << 4;
|
||||
} else {
|
||||
bits &= ~(1 << 4);
|
||||
private static final BiFunction<String, NbtMapBuilder, String> V503_MAPPER = (bedrockIdentifier, statesBuilder) -> {
|
||||
// TODO some new blocks exist in the block palette, but don't properly work in game (mangrove leaves + mud stuff)
|
||||
if (bedrockIdentifier.contains("stone_block_slab")) {
|
||||
return bedrockIdentifier.replace("stone_block_slab", "stone_slab");
|
||||
}
|
||||
switch (bedrockIdentifier) {
|
||||
case "minecraft:mangrove_planks" -> {
|
||||
statesBuilder.putString("wood_type", "jungle");
|
||||
return "minecraft:planks";
|
||||
}
|
||||
if (south) {
|
||||
bits |= 1 << 2;
|
||||
} else {
|
||||
bits &= ~(1 << 2);
|
||||
case "minecraft:mangrove_log" -> {
|
||||
statesBuilder.putString("old_log_type", "jungle");
|
||||
return "minecraft:log";
|
||||
}
|
||||
if (west) {
|
||||
bits |= 1 << 3;
|
||||
} else {
|
||||
bits &= ~(1 << 3);
|
||||
case "minecraft:stripped_mangrove_log" -> {
|
||||
return "minecraft:stripped_jungle_log";
|
||||
}
|
||||
case "minecraft:mangrove_roots", "minecraft:muddy_mangrove_roots", "minecraft:mangrove_wood" -> {
|
||||
statesBuilder.putString("wood_type", "jungle");
|
||||
statesBuilder.putBoolean("stripped_bit", false);
|
||||
statesBuilder.putString("pillar_axis", "x");
|
||||
return "minecraft:wood";
|
||||
}
|
||||
case "minecraft:stripped_mangrove_wood" -> {
|
||||
statesBuilder.putString("wood_type", "jungle");
|
||||
statesBuilder.putBoolean("stripped_bit", true);
|
||||
return "minecraft:wood";
|
||||
}
|
||||
case "minecraft:mangrove_standing_sign" -> {
|
||||
return "minecraft:jungle_standing_sign";
|
||||
}
|
||||
case "minecraft:mangrove_wall_sign" -> {
|
||||
return "minecraft:jungle_wall_sign";
|
||||
}
|
||||
case "minecraft:mangrove_pressure_plate" -> {
|
||||
return "minecraft:jungle_pressure_plate";
|
||||
}
|
||||
case "minecraft:mangrove_trapdoor" -> {
|
||||
return "minecraft:jungle_trapdoor";
|
||||
}
|
||||
case "minecraft:mangrove_button" -> {
|
||||
return "minecraft:jungle_button";
|
||||
}
|
||||
case "minecraft:mangrove_stairs" -> {
|
||||
return "minecraft:jungle_stairs";
|
||||
}
|
||||
case "minecraft:mangrove_slab" -> {
|
||||
statesBuilder.putString("wood_type", "jungle");
|
||||
return "minecraft:wooden_slab";
|
||||
}
|
||||
case "minecraft:mangrove_double_slab" -> {
|
||||
statesBuilder.putString("wood_type", "jungle");
|
||||
return "minecraft:double_wooden_slab";
|
||||
}
|
||||
case "minecraft:mangrove_fence_gate" -> {
|
||||
return "minecraft:jungle_fence_gate";
|
||||
}
|
||||
case "minecraft:mangrove_fence" -> {
|
||||
statesBuilder.putString("wood_type", "jungle");
|
||||
return "minecraft:fence";
|
||||
}
|
||||
case "minecraft:mangrove_door" -> {
|
||||
return "minecraft:jungle_door";
|
||||
}
|
||||
case "minecraft:mangrove_propagule" -> {
|
||||
statesBuilder.put("growth", statesBuilder.get("propagule_stage"));
|
||||
statesBuilder.remove("propagule_stage");
|
||||
|
||||
statesBuilder.putInt("facing_direction", 0);
|
||||
|
||||
if ((Byte) statesBuilder.remove("hanging") == 1) {
|
||||
return "minecraft:mangrove_propagule_hanging";
|
||||
} else {
|
||||
return "minecraft:mangrove_propagule";
|
||||
}
|
||||
}
|
||||
case "minecraft:sculk_shrieker" -> {
|
||||
statesBuilder.remove("can_summon");
|
||||
return bedrockIdentifier;
|
||||
}
|
||||
statesBuilder.put("multi_face_direction_bits", bits);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
static {
|
||||
ImmutableMap.Builder<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> stateMapperBuilder = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
|
||||
.put(ObjectIntPair.of("1_18_0", Bedrock_v475.V475_CODEC.getProtocolVersion()), EMPTY_MAPPER)
|
||||
.put(ObjectIntPair.of("1_18_10", Bedrock_v486.V486_CODEC.getProtocolVersion()), V486_MAPPER)
|
||||
.put(ObjectIntPair.of("1_18_30", Bedrock_v503.V503_CODEC.getProtocolVersion()), (bedrockIdentifier, statesBuilder) -> {
|
||||
// Apply these fixes too
|
||||
V486_MAPPER.apply(bedrockIdentifier, statesBuilder);
|
||||
return switch (bedrockIdentifier) {
|
||||
case "minecraft:pistonArmCollision" -> "minecraft:piston_arm_collision";
|
||||
case "minecraft:stickyPistonArmCollision" -> "minecraft:sticky_piston_arm_collision";
|
||||
case "minecraft:movingBlock" -> "minecraft:moving_block";
|
||||
case "minecraft:tripWire" -> "minecraft:trip_wire";
|
||||
case "minecraft:seaLantern" -> "minecraft:sea_lantern";
|
||||
case "minecraft:concretePowder" -> "minecraft:concrete_powder";
|
||||
default -> null;
|
||||
};
|
||||
});
|
||||
.put(ObjectIntPair.of("1_18_30", Bedrock_v503.V503_CODEC.getProtocolVersion()), V503_MAPPER)
|
||||
.put(ObjectIntPair.of("1_19_0", BedrockBeta.BETA_CODEC.getProtocolVersion()), EMPTY_MAPPER);
|
||||
|
||||
BLOCK_MAPPERS = stateMapperBuilder.build();
|
||||
}
|
||||
|
@ -171,10 +213,8 @@ public class BlockRegistryPopulator {
|
|||
|
||||
int bedrockRuntimeId = blockStateOrderedMap.getOrDefault(buildBedrockState(entry.getValue(), stateVersion, stateMapper), -1);
|
||||
if (bedrockRuntimeId == -1) {
|
||||
bedrockRuntimeId = 0;
|
||||
//TODO remove
|
||||
//throw new RuntimeException("Unable to find " + javaId + " Bedrock runtime ID! Built NBT tag: \n" +
|
||||
// buildBedrockState(entry.getValue(), stateVersion, stateMapper));
|
||||
throw new RuntimeException("Unable to find " + javaId + " Bedrock runtime ID! Built NBT tag: \n" +
|
||||
buildBedrockState(entry.getValue(), stateVersion, stateMapper));
|
||||
}
|
||||
|
||||
switch (javaId) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.nukkitx.nbt.NbtMap;
|
|||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import com.nukkitx.nbt.NbtType;
|
||||
import com.nukkitx.nbt.NbtUtils;
|
||||
import com.nukkitx.protocol.bedrock.beta.BedrockBeta;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ComponentItemData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||
|
@ -66,9 +67,8 @@ public class ItemRegistryPopulator {
|
|||
|
||||
public static void populate() {
|
||||
Map<String, PaletteVersion> paletteVersions = new Object2ObjectOpenHashMap<>();
|
||||
paletteVersions.put("1_18_0", new PaletteVersion(Bedrock_v475.V475_CODEC.getProtocolVersion(), Collections.emptyMap()));
|
||||
paletteVersions.put("1_18_10", new PaletteVersion(Bedrock_v486.V486_CODEC.getProtocolVersion(), Collections.emptyMap()));
|
||||
paletteVersions.put("1_18_30", new PaletteVersion(Bedrock_v503.V503_CODEC.getProtocolVersion(), Collections.emptyMap()));
|
||||
paletteVersions.put("1_19_0", new PaletteVersion(BedrockBeta.BETA_CODEC.getProtocolVersion(), Collections.emptyMap()));
|
||||
|
||||
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
|||
import com.github.steveice10.packetlib.tcp.TcpSession;
|
||||
import com.nukkitx.math.GenericMath;
|
||||
import com.nukkitx.math.vector.*;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||
import com.nukkitx.protocol.bedrock.data.*;
|
||||
|
@ -1461,6 +1462,11 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||
startGamePacket.setInventoriesServerAuthoritative(true);
|
||||
startGamePacket.setServerEngine(""); // Do we want to fill this in?
|
||||
|
||||
startGamePacket.setPlayerPropertyData(NbtMap.EMPTY);
|
||||
startGamePacket.setWorldTemplateId(UUID.randomUUID());
|
||||
|
||||
startGamePacket.getExperiments().add(new ExperimentData("wild_update", true));
|
||||
|
||||
SyncedPlayerMovementSettings settings = new SyncedPlayerMovementSettings();
|
||||
settings.setMovementMode(AuthoritativeMovementMode.CLIENT);
|
||||
settings.setRewindHistorySize(0);
|
||||
|
|
BIN
core/src/main/resources/bedrock/block_palette.1_19_0.nbt
Normal file
BIN
core/src/main/resources/bedrock/block_palette.1_19_0.nbt
Normal file
Binary file not shown.
5437
core/src/main/resources/bedrock/creative_items.1_19_0.json
Normal file
5437
core/src/main/resources/bedrock/creative_items.1_19_0.json
Normal file
File diff suppressed because it is too large
Load diff
4530
core/src/main/resources/bedrock/runtime_item_states.1_19_0.json
Normal file
4530
core/src/main/resources/bedrock/runtime_item_states.1_19_0.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1 +1 @@
|
|||
Subproject commit f73b45844f1185c3898db3052ce4ea0d18246168
|
||||
Subproject commit dbd6e29245843f8a2469a282c01b4de6157ba4e4
|
Loading…
Reference in a new issue