Add 1.20.50 Bedrock support (#4296)

* Start on 1.20.50

* Add 1.20.50 block_palette.1_20_50.nbt, creative_items.1_20_50.json and runtime_item_states.1_20_50.json

* fix stone and planks mappings

* add and do something with the new SetPlayerInventoryOptionsPacket

* Add readme version bump

* Cleanup/Explain the new BedrockSetPlayerInventoryOptionsTranslator
This commit is contained in:
chris 2023-11-21 23:31:56 +01:00 committed by GitHub
parent dec0d13d8e
commit 44174fdc04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 11734 additions and 22 deletions

View file

@ -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.40 and Minecraft Java 1.20.2
### Currently supporting Minecraft Bedrock 1.20.0 - 1.20.50 and Minecraft Java 1.20.2
## Setting Up
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.

View file

@ -32,6 +32,7 @@ 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.codec.v622.Bedrock_v622;
import org.cloudburstmc.protocol.bedrock.codec.v630.Bedrock_v630;
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
import org.geysermc.geyser.session.GeyserSession;
@ -47,7 +48,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_v622.CODEC;
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v630.CODEC;
/**
* A list of all supported Bedrock versions that can join Geyser
@ -70,6 +71,9 @@ public final class GameProtocol {
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v618.CODEC.toBuilder()
.minecraftVersion("1.20.30/1.20.32")
.build());
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v622.CODEC.toBuilder()
.minecraftVersion("1.20.40/1.20.41")
.build());
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
}

View file

@ -32,7 +32,7 @@ import org.geysermc.geyser.session.GeyserSession;
/**
* Bare bones implementation of BedrockPacketHandler suitable for extension.
*
* <p>
* Logs and ignores all packets presented. Allows subclasses to override/implement only
* packets of interest and limit boilerplate code.
*/
@ -60,11 +60,6 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(AdventureSettingsPacket packet) {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(AnimatePacket packet) {
return defaultHandler(packet);
@ -120,11 +115,6 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(CraftingEventPacket packet) {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(EntityEventPacket packet) {
return defaultHandler(packet);
@ -505,11 +495,6 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(ScriptCustomEventPacket packet) {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(ServerSettingsResponsePacket packet) {
return defaultHandler(packet);
@ -560,6 +545,11 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(SetPlayerInventoryOptionsPacket packet) {
return defaultHandler(packet);
}
@Override
public PacketSignal handle(SetScoreboardIdentityPacket packet) {
return defaultHandler(packet);

View file

@ -37,12 +37,17 @@ 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.BlockStateUpdater_1_20_40;
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_50;
import org.cloudburstmc.blockstateupdater.util.tagupdater.CompoundTagUpdaterContext;
import org.cloudburstmc.nbt.*;
import org.cloudburstmc.nbt.NBTInputStream;
import org.cloudburstmc.nbt.NbtMap;
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.codec.v622.Bedrock_v622;
import org.cloudburstmc.protocol.bedrock.codec.v630.Bedrock_v630;
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.geysermc.geyser.GeyserImpl;
@ -120,12 +125,14 @@ public final class BlockRegistryPopulator {
Remapper mapper594 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE);
Remapper mapper618 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE);
Remapper mapper622 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE, BlockStateUpdater_1_20_40.INSTANCE);
Remapper mapper630 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE, BlockStateUpdater_1_20_40.INSTANCE, BlockStateUpdater_1_20_50.INSTANCE);
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)
.put(ObjectIntPair.of("1_20_40", Bedrock_v622.CODEC.getProtocolVersion()), mapper622)
.put(ObjectIntPair.of("1_20_50", Bedrock_v630.CODEC.getProtocolVersion()), mapper630)
.build();
// We can keep this strong as nothing should be garbage collected

View file

@ -42,6 +42,7 @@ 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.codec.v622.Bedrock_v622;
import org.cloudburstmc.protocol.bedrock.codec.v630.Bedrock_v630;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
@ -113,11 +114,25 @@ public class ItemRegistryPopulator {
return mapping;
};
Remapper remapper630 = (item, mapping) -> {
mapping = remapper618.remap(item, mapping); // apply 1.20.30 remapper first
String id = item.javaIdentifier();
// 1.20.50 replaced stone & planks to individual stone types
// E.g.: granite, diorite, andesite, polished variants, dark_oak_planks etc
if (mapping.getBedrockIdentifier().equals("minecraft:stone") || mapping.getBedrockIdentifier().equals("minecraft:planks")) {
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));
paletteVersions.add(new PaletteVersion("1_20_40", Bedrock_v622.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper618)); // NO item changes between 1.20.30 and 1.20.40
paletteVersions.add(new PaletteVersion("1_20_50", Bedrock_v630.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper630));
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();

View file

@ -0,0 +1,63 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.protocol.bedrock.entity.player;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.inventory.CraftingBookStateType;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundRecipeBookChangeSettingsPacket;
import org.cloudburstmc.protocol.bedrock.data.inventory.InventoryTabLeft;
import org.cloudburstmc.protocol.bedrock.data.inventory.InventoryTabRight;
import org.cloudburstmc.protocol.bedrock.packet.SetPlayerInventoryOptionsPacket;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@Translator(packet = SetPlayerInventoryOptionsPacket.class)
public class BedrockSetPlayerInventoryOptionsTranslator extends PacketTranslator<SetPlayerInventoryOptionsPacket> {
@Override
public void translate(GeyserSession session, SetPlayerInventoryOptionsPacket packet) {
// Sent by 1.20.50+ - we can pass it through to the java server
// This should ensure that we never send these packets when the player inventory is opened while in creative
// Java edition can't craft in the 2x2 grid in creative, and subsequently doesn't have a recipe book
if (session.getGameMode() == GameMode.CREATIVE && session.getPlayerInventory() == session.getOpenInventory()) {
return;
}
boolean filtered = packet.isFiltering();
boolean bookOpen = isBookOpen(packet.getLeftTab(), packet.getRightTab());
// Hardcoded to crafting; bedrock does not have any furnace recipe books
session.sendDownstreamPacket(new ServerboundRecipeBookChangeSettingsPacket(CraftingBookStateType.CRAFTING, bookOpen, filtered));
}
private boolean isBookOpen(InventoryTabLeft leftTab, InventoryTabRight rightTab) {
boolean leftOpen = (leftTab != InventoryTabLeft.NONE && leftTab != InventoryTabLeft.SURVIVAL);
boolean rightOpen = rightTab == InventoryTabRight.CRAFTING;
return leftOpen || rightOpen;
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -9,10 +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-20231016.115644-107"
protocol-connection = "3.0.0.Beta1-20231016.115644-106"
protocol = "3.0.0.Beta1-20231107.190703-113"
protocol-connection = "3.0.0.Beta1-20231107.190703-112"
raknet = "1.0.0.CR1-20230703.195238-9"
blockstateupdater="1.20.40-20231016.111746-1"
blockstateupdater="1.20.50-20231106.161340-1"
mcauthlib = "d9d773e"
mcprotocollib = "1.20.2-1-20231101.141901-7"
adventure = "4.14.0"