Skip to content

Commit 828d680

Browse files
Kas-tleonebeastchris
authored andcommitted
1.20.80 Support and Protocol Changes (GeyserMC#4561)
* Make evil more harder Signed-off-by: Joshua Castle <[email protected]> * Deregister more unused packets Signed-off-by: Joshua Castle <[email protected]> * Add more unused packets Signed-off-by: Joshua Castle <[email protected]> * Pin protocol to 68dc192 * Correction * Update Protocol * More kicking Signed-off-by: Joshua Castle <[email protected]> * stop reading when there is no item to read (#9) * Bump protocol Signed-off-by: Joshua Castle <[email protected]> * 1.20.80 Signed-off-by: Joshua Castle <[email protected]> * Remove unused postinitchannel GeyserServerInitializer * Pull protocol jitpack from cloudburst again * Actually builds Signed-off-by: Joshua Castle <[email protected]> * Bump protocol to fix BossEventPacket & EmotePacket Signed-off-by: Joshua Castle <[email protected]> * Add remove before merge comment Signed-off-by: Joshua Castle <[email protected]> * Bump protocol to fix BlockEntityDataPacket and ignore serverbound BossEventPacket Signed-off-by: Joshua Castle <[email protected]> * Bump protocol & add more illegal/ignored packets Signed-off-by: Joshua Castle <[email protected]> * Remove deprecated packet Signed-off-by: Joshua Castle <[email protected]> * Ignore ClientCacheStatusPacket instead of disallow Signed-off-by: Joshua Castle <[email protected]> * Define static serializers Signed-off-by: Joshua Castle <[email protected]> * Less static class nonsense more correct order Signed-off-by: Joshua Castle <[email protected]> * Remove unused import Signed-off-by: Joshua Castle <[email protected]> * Bump protocol Signed-off-by: Joshua Castle <[email protected]> * Move codec processing to CodecProcessor Signed-off-by: Joshua Castle <[email protected]> * Falsify recipe symetry assumption Signed-off-by: Joshua Castle <[email protected]> * Update Protocol for 2 wrong packet IDs & 5 wrong directions * Jitpack protocol from Geyser repo --------- Signed-off-by: Joshua Castle <[email protected]> Co-authored-by: chris <[email protected]>
1 parent 9e5635c commit 828d680

17 files changed

+12660
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
1414

1515
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
1616

17-
### Currently supporting Minecraft Bedrock 1.20.40 - 1.20.73 and Minecraft Java 1.20.4
17+
### Currently supporting Minecraft Bedrock 1.20.40 - 1.20.80 and Minecraft Java 1.20.4
1818

1919
## Setting Up
2020
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.

core/src/main/java/org/geysermc/geyser/network/CodecProcessor.java

Lines changed: 292 additions & 0 deletions
Large diffs are not rendered by default.

core/src/main/java/org/geysermc/geyser/network/GameProtocol.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,14 @@
2727

2828
import com.github.steveice10.mc.protocol.codec.MinecraftCodec;
2929
import com.github.steveice10.mc.protocol.codec.PacketCodec;
30-
import io.netty.buffer.ByteBuf;
3130
import org.checkerframework.checker.nullness.qual.Nullable;
3231
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
33-
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
34-
import org.cloudburstmc.protocol.bedrock.codec.v582.serializer.TrimDataSerializer_v582;
3532
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
3633
import org.cloudburstmc.protocol.bedrock.codec.v630.Bedrock_v630;
3734
import org.cloudburstmc.protocol.bedrock.codec.v649.Bedrock_v649;
3835
import org.cloudburstmc.protocol.bedrock.codec.v662.Bedrock_v662;
36+
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
3937
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
40-
import org.cloudburstmc.protocol.bedrock.packet.TrimDataPacket;
4138
import org.geysermc.geyser.session.GeyserSession;
4239

4340
import java.util.ArrayList;
@@ -48,11 +45,12 @@
4845
* Contains information about the supported protocols in Geyser.
4946
*/
5047
public final class GameProtocol {
48+
5149
/**
5250
* Default Bedrock codec that should act as a fallback. Should represent the latest available
5351
* release of the game that Geyser supports.
5452
*/
55-
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = processCodec(Bedrock_v662.CODEC);
53+
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = CodecProcessor.processCodec(Bedrock_v671.CODEC);
5654

5755
/**
5856
* A list of all supported Bedrock versions that can join Geyser
@@ -66,18 +64,21 @@ public final class GameProtocol {
6664
private static final PacketCodec DEFAULT_JAVA_CODEC = MinecraftCodec.CODEC;
6765

6866
static {
69-
SUPPORTED_BEDROCK_CODECS.add(processCodec(Bedrock_v622.CODEC.toBuilder()
67+
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v622.CODEC.toBuilder()
7068
.minecraftVersion("1.20.40/1.20.41")
7169
.build()));
72-
SUPPORTED_BEDROCK_CODECS.add(processCodec(Bedrock_v630.CODEC.toBuilder()
70+
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v630.CODEC.toBuilder()
7371
.minecraftVersion("1.20.50/1.20.51")
7472
.build()));
75-
SUPPORTED_BEDROCK_CODECS.add(processCodec(Bedrock_v649.CODEC.toBuilder()
73+
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v649.CODEC.toBuilder()
7674
.minecraftVersion("1.20.60/1.20.62")
7775
.build()));
78-
SUPPORTED_BEDROCK_CODECS.add(processCodec(DEFAULT_BEDROCK_CODEC.toBuilder()
76+
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v662.CODEC.toBuilder()
7977
.minecraftVersion("1.20.70/1.20.73")
8078
.build()));
79+
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(DEFAULT_BEDROCK_CODEC.toBuilder()
80+
.minecraftVersion("1.20.80")
81+
.build()));
8182
}
8283

8384
/**
@@ -168,16 +169,6 @@ public static String getAllSupportedJavaVersions() {
168169
return joiner.toString();
169170
}
170171

171-
private static BedrockCodec processCodec(BedrockCodec codec) {
172-
return codec.toBuilder()
173-
.updateSerializer(TrimDataPacket.class, new TrimDataSerializer_v582() {
174-
@Override
175-
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, TrimDataPacket packet) {
176-
}
177-
})
178-
.build();
179-
}
180-
181172
private GameProtocol() {
182173
}
183174
}

core/src/main/java/org/geysermc/geyser/network/GeyserServerInitializer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525

2626
package org.geysermc.geyser.network;
2727

28+
import io.netty.buffer.ByteBuf;
2829
import io.netty.channel.Channel;
30+
import io.netty.channel.ChannelHandlerContext;
2931
import io.netty.channel.DefaultEventLoopGroup;
32+
import io.netty.channel.SimpleChannelInboundHandler;
3033
import io.netty.util.concurrent.DefaultThreadFactory;
3134
import org.checkerframework.checker.nullness.qual.NonNull;
3235
import org.cloudburstmc.protocol.bedrock.BedrockPeer;
3336
import org.cloudburstmc.protocol.bedrock.BedrockServerSession;
37+
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
3438
import org.cloudburstmc.protocol.bedrock.netty.initializer.BedrockServerInitializer;
3539
import org.geysermc.geyser.GeyserImpl;
3640
import org.geysermc.geyser.api.event.bedrock.SessionInitializeEvent;
@@ -63,6 +67,10 @@ public void initSession(@NonNull BedrockServerSession bedrockServerSession) {
6367

6468
bedrockServerSession.setLogging(true);
6569
GeyserSession session = new GeyserSession(this.geyser, bedrockServerSession, this.eventLoopGroup.next());
70+
71+
Channel channel = bedrockServerSession.getPeer().getChannel();
72+
channel.pipeline().addAfter(BedrockPacketCodec.NAME, InvalidPacketHandler.NAME, new InvalidPacketHandler(session));
73+
6674
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(this.geyser, session));
6775
this.geyser.eventBus().fire(new SessionInitializeEvent(session));
6876
} catch (Throwable e) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*
22+
* @author GeyserMC
23+
* @link https://github.com/GeyserMC/Geyser
24+
*/
25+
26+
package org.geysermc.geyser.network;
27+
28+
import io.netty.channel.ChannelHandlerContext;
29+
import io.netty.channel.ChannelInboundHandlerAdapter;
30+
import lombok.RequiredArgsConstructor;
31+
import org.geysermc.geyser.session.GeyserSession;
32+
33+
import java.util.stream.Stream;
34+
35+
@RequiredArgsConstructor
36+
public class InvalidPacketHandler extends ChannelInboundHandlerAdapter {
37+
public static final String NAME = "rak-error-handler";
38+
39+
private final GeyserSession session;
40+
41+
@Override
42+
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
43+
Throwable rootCause = Stream.iterate(cause, Throwable::getCause)
44+
.filter(element -> element.getCause() == null)
45+
.findFirst()
46+
.orElse(cause);
47+
48+
49+
if (!(rootCause instanceof IllegalArgumentException)) {
50+
super.exceptionCaught(ctx, cause);
51+
return;
52+
}
53+
54+
// Kick users that try to send illegal packets
55+
session.getGeyser().getLogger().warning(rootCause.getMessage());
56+
session.disconnect("Invalid packet received!");
57+
}
58+
}

core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.cloudburstmc.protocol.bedrock.codec.v630.Bedrock_v630;
4444
import org.cloudburstmc.protocol.bedrock.codec.v649.Bedrock_v649;
4545
import org.cloudburstmc.protocol.bedrock.codec.v662.Bedrock_v662;
46+
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
4647
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
4748
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
4849
import org.geysermc.geyser.GeyserImpl;
@@ -122,7 +123,8 @@ private static void registerBedrockBlocks() {
122123
.put(ObjectIntPair.of("1_20_50", Bedrock_v630.CODEC.getProtocolVersion()), Conversion649_630::remapBlock)
123124
// Only changes in 1.20.60 are hard_stained_glass (an EDU only block)
124125
.put(ObjectIntPair.of("1_20_60", Bedrock_v649.CODEC.getProtocolVersion()), Conversion662_649::remapBlock)
125-
.put(ObjectIntPair.of("1_20_70", Bedrock_v662.CODEC.getProtocolVersion()), tag -> tag)
126+
.put(ObjectIntPair.of("1_20_70", Bedrock_v662.CODEC.getProtocolVersion()), Conversion671_662::remapBlock)
127+
.put(ObjectIntPair.of("1_20_80", Bedrock_v671.CODEC.getProtocolVersion()), tag -> tag)
126128
.build();
127129

128130
// We can keep this strong as nothing should be garbage collected

core/src/main/java/org/geysermc/geyser/registry/populator/Conversion662_649.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class Conversion662_649 {
4444

4545

4646
static GeyserMappingItem remapItem(@SuppressWarnings("unused") Item item, GeyserMappingItem mapping) {
47+
mapping = Conversion671_662.remapItem(item, mapping);
48+
4749
String identifer = mapping.getBedrockIdentifier();
4850

4951
if (identifer.equals("minecraft:grass_block")) {
@@ -93,6 +95,8 @@ static GeyserMappingItem remapItem(@SuppressWarnings("unused") Item item, Geyser
9395
}
9496

9597
static NbtMap remapBlock(NbtMap tag) {
98+
tag = Conversion671_662.remapBlock(tag);
99+
96100
final String name = tag.getString("name");
97101

98102
if (!NEW_BLOCKS.contains(name)) {

0 commit comments

Comments
 (0)