Skip to content

Commit 9e276c1

Browse files
Feature: 1.21.50 support (#5180)
* Drop pre-1.21.40 support, start adapting to 1.21.50 changes * fix camera definitions * remove more old workarounds, make it compile * Add 1.21.50 data files * Add item tags, update block registry populator * finishing touches * Don't add items to the creative inventory that we don't have a Java mapping for * fix readme typo
1 parent d956354 commit 9e276c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2139
-42708
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
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

1717
## Supported Versions
18-
Geyser is currently supporting Minecraft Bedrock 1.20.80 - 1.21.44 and Minecraft Java 1.21.2/1.21.3. For more information, please see [here](https://geysermc.org/wiki/geyser/supported-versions/).
18+
Geyser is currently supporting Minecraft Bedrock 1.21.40 - 1.21.50 and Minecraft Java 1.21.2/1.21.3. For more information, please see [here](https://geysermc.org/wiki/geyser/supported-versions/).
1919

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

core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
4040
import org.geysermc.geyser.item.Items;
4141
import org.geysermc.geyser.level.BedrockDimension;
42-
import org.geysermc.geyser.network.GameProtocol;
4342
import org.geysermc.geyser.session.GeyserSession;
4443
import org.geysermc.geyser.util.AttributeUtils;
4544
import org.geysermc.geyser.util.DimensionUtils;
@@ -235,12 +234,7 @@ protected void setAirSupply(int amount) {
235234
// the bubbles visually pop
236235
setFlag(EntityFlag.BREATHING, amount >= this.lastAirSupply);
237236
this.lastAirSupply = amount;
238-
239-
if (amount == getMaxAir() && GameProtocol.isPre1_21_0(session)) {
240-
super.setAirSupply(0); // Hide the bubble counter from the UI for the player
241-
} else {
242-
super.setAirSupply(amount);
243-
}
237+
super.setAirSupply(amount);
244238
}
245239

246240
@Override

core/src/main/java/org/geysermc/geyser/event/type/SessionLoadResourcePacksEventImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636

3737
public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksEvent {
3838

39-
private final Map<String, ResourcePack> packs;
39+
private final Map<UUID, ResourcePack> packs;
4040

41-
public SessionLoadResourcePacksEventImpl(GeyserSession session, Map<String, ResourcePack> packMap) {
41+
public SessionLoadResourcePacksEventImpl(GeyserSession session, Map<UUID, ResourcePack> packMap) {
4242
super(session);
4343
this.packs = packMap;
4444
}
4545

46-
public @NonNull Map<String, ResourcePack> getPacks() {
46+
public @NonNull Map<UUID, ResourcePack> getPacks() {
4747
return packs;
4848
}
4949

@@ -54,16 +54,16 @@ public SessionLoadResourcePacksEventImpl(GeyserSession session, Map<String, Reso
5454

5555
@Override
5656
public boolean register(@NonNull ResourcePack resourcePack) {
57-
String packID = resourcePack.manifest().header().uuid().toString();
57+
UUID packID = resourcePack.manifest().header().uuid();
5858
if (packs.containsValue(resourcePack) || packs.containsKey(packID)) {
5959
return false;
6060
}
61-
packs.put(resourcePack.manifest().header().uuid().toString(), resourcePack);
61+
packs.put(resourcePack.manifest().header().uuid(), resourcePack);
6262
return true;
6363
}
6464

6565
@Override
6666
public boolean unregister(@NonNull UUID uuid) {
67-
return packs.remove(uuid.toString()) != null;
67+
return packs.remove(uuid) != null;
6868
}
6969
}

core/src/main/java/org/geysermc/geyser/impl/camera/CameraDefinitions.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ public class CameraDefinitions {
4343

4444
static {
4545
CAMERA_PRESETS = List.of(
46-
new CameraPreset(CameraPerspective.FIRST_PERSON.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null, null, null, OptionalBoolean.empty(), OptionalBoolean.empty()),
47-
new CameraPreset(CameraPerspective.FREE.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null, null, null, OptionalBoolean.empty(), OptionalBoolean.empty()),
48-
new CameraPreset(CameraPerspective.THIRD_PERSON.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null, null, null, OptionalBoolean.empty(), OptionalBoolean.empty()),
49-
new CameraPreset(CameraPerspective.THIRD_PERSON_FRONT.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null, null, null, OptionalBoolean.empty(), OptionalBoolean.empty()),
50-
new CameraPreset("geyser:free_audio", "minecraft:free", null, null, null, null, null, CameraAudioListener.PLAYER, OptionalBoolean.empty(), null, OptionalBoolean.of(false), null, null, null, OptionalBoolean.empty(), OptionalBoolean.empty()),
51-
new CameraPreset("geyser:free_effects", "minecraft:free", null, null, null, null, null, CameraAudioListener.CAMERA, OptionalBoolean.empty(), null, OptionalBoolean.of(true), null, null, null, OptionalBoolean.empty(), OptionalBoolean.empty()),
52-
new CameraPreset("geyser:free_audio_effects", "minecraft:free", null, null, null, null, null, CameraAudioListener.PLAYER, OptionalBoolean.empty(), null, OptionalBoolean.of(true), null, null, null, OptionalBoolean.empty(), OptionalBoolean.empty()));
46+
CameraPreset.builder().identifier(CameraPerspective.FIRST_PERSON.id()).build(),
47+
CameraPreset.builder().identifier(CameraPerspective.FREE.id()).build(),
48+
CameraPreset.builder().identifier(CameraPerspective.THIRD_PERSON.id()).build(),
49+
CameraPreset.builder().identifier(CameraPerspective.THIRD_PERSON_FRONT.id()).build(),
50+
CameraPreset.builder().identifier("geyser:free_audio").parentPreset(CameraPerspective.FREE.id()).listener(CameraAudioListener.PLAYER).playEffect(OptionalBoolean.of(false)).build(),
51+
CameraPreset.builder().identifier("geyser:free_effects").parentPreset(CameraPerspective.FREE.id()).listener(CameraAudioListener.CAMERA).playEffect(OptionalBoolean.of(true)).build(),
52+
CameraPreset.builder().identifier("geyser:free_audio_effects").parentPreset(CameraPerspective.FREE.id()).listener(CameraAudioListener.PLAYER).playEffect(OptionalBoolean.of(true)).build()
53+
);
5354

5455
SimpleDefinitionRegistry.Builder<NamedDefinition> builder = SimpleDefinitionRegistry.builder();
5556
for (int i = 0; i < CAMERA_PRESETS.size(); i++) {

core/src/main/java/org/geysermc/geyser/level/physics/CollisionManager.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -416,40 +416,6 @@ public BlockCollision getCollisionLavaWalking(int blockId, int blockY, BoundingB
416416
return BlockUtils.getCollision(blockId);
417417
}
418418

419-
public boolean isOnGround() {
420-
// Temporary until pre-1.21.30 support is dropped.
421-
Vector3d bottomCenter = playerBoundingBox.getBottomCenter();
422-
Vector3i groundPos = Vector3i.from(bottomCenter.getX(), bottomCenter.getY() - 1, bottomCenter.getZ());
423-
BlockCollision collision = BlockUtils.getCollisionAt(session, groundPos);
424-
if (collision == null) {
425-
return false; // Probably air.
426-
}
427-
428-
// Hack to not check below the player
429-
playerBoundingBox.setSizeY(playerBoundingBox.getSizeY() - 0.001);
430-
playerBoundingBox.setMiddleY(playerBoundingBox.getMiddleY() + 0.002);
431-
432-
boolean intersected = collision.checkIntersection(groundPos.getX(), groundPos.getY(), groundPos.getZ(), playerBoundingBox);
433-
434-
playerBoundingBox.setSizeY(playerBoundingBox.getSizeY() + 0.001);
435-
playerBoundingBox.setMiddleY(playerBoundingBox.getMiddleY() - 0.002);
436-
437-
boolean result;
438-
if (intersected) {
439-
result = true;
440-
} else {
441-
// Hack to check slightly below the player
442-
playerBoundingBox.setSizeY(playerBoundingBox.getSizeY() + 0.001);
443-
playerBoundingBox.setMiddleY(playerBoundingBox.getMiddleY() - 0.002);
444-
445-
result = collision.checkIntersection(groundPos.getX(), groundPos.getY(), groundPos.getZ(), playerBoundingBox);
446-
447-
playerBoundingBox.setSizeY(playerBoundingBox.getSizeY() - 0.001);
448-
playerBoundingBox.setMiddleY(playerBoundingBox.getMiddleY() + 0.002);
449-
}
450-
return result;
451-
}
452-
453419
/**
454420
* @return if the player is currently in a water block
455421
*/

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

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@
2727

2828
import org.checkerframework.checker.nullness.qual.Nullable;
2929
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
30-
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
31-
import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685;
32-
import org.cloudburstmc.protocol.bedrock.codec.v686.Bedrock_v686;
33-
import org.cloudburstmc.protocol.bedrock.codec.v712.Bedrock_v712;
34-
import org.cloudburstmc.protocol.bedrock.codec.v729.Bedrock_v729;
3530
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
31+
import org.cloudburstmc.protocol.bedrock.codec.v765.Bedrock_v765;
3632
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
37-
import org.geysermc.geyser.session.GeyserSession;
3833
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodec;
3934
import org.geysermc.mcprotocollib.protocol.codec.PacketCodec;
4035

@@ -51,8 +46,9 @@ public final class GameProtocol {
5146
* Default Bedrock codec that should act as a fallback. Should represent the latest available
5247
* release of the game that Geyser supports.
5348
*/
54-
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = CodecProcessor.processCodec(Bedrock_v748.CODEC.toBuilder()
55-
.minecraftVersion("1.21.44")
49+
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = CodecProcessor.processCodec(Bedrock_v765.CODEC.toBuilder()
50+
.minecraftVersion("1.21.50")
51+
.protocolVersion(766)
5652
.build());
5753

5854
/**
@@ -67,24 +63,10 @@ public final class GameProtocol {
6763
private static final PacketCodec DEFAULT_JAVA_CODEC = MinecraftCodec.CODEC;
6864

6965
static {
70-
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v671.CODEC.toBuilder()
71-
.minecraftVersion("1.20.80/1.20.81")
72-
.build()));
73-
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v685.CODEC.toBuilder()
74-
.minecraftVersion("1.21.0/1.21.1")
75-
.build()));
76-
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v686.CODEC.toBuilder()
77-
.minecraftVersion("1.21.2/1.21.3")
78-
.build()));
79-
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v712.CODEC.toBuilder()
80-
.minecraftVersion("1.21.20 - 1.21.23")
81-
.build()));
82-
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v729.CODEC.toBuilder()
83-
.minecraftVersion("1.21.30/1.21.31")
84-
.build()));
85-
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
66+
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v748.CODEC.toBuilder()
8667
.minecraftVersion("1.21.40 - 1.21.44")
87-
.build());
68+
.build()));
69+
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
8870
}
8971

9072
/**
@@ -103,22 +85,6 @@ public final class GameProtocol {
10385

10486
/* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */
10587

106-
public static boolean isPre1_21_0(GeyserSession session) {
107-
return session.getUpstream().getProtocolVersion() < Bedrock_v685.CODEC.getProtocolVersion();
108-
}
109-
110-
public static boolean isPre1_21_2(GeyserSession session) {
111-
return session.getUpstream().getProtocolVersion() < Bedrock_v686.CODEC.getProtocolVersion();
112-
}
113-
114-
public static boolean isPre1_21_30(GeyserSession session) {
115-
return session.getUpstream().getProtocolVersion() < Bedrock_v729.CODEC.getProtocolVersion();
116-
}
117-
118-
public static boolean isPre1_21_40(GeyserSession session) {
119-
return session.getUpstream().getProtocolVersion() < Bedrock_v748.CODEC.getProtocolVersion();
120-
}
121-
12288
/**
12389
* Gets the {@link PacketCodec} for Minecraft: Java Edition.
12490
*

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@
7777
import java.util.Deque;
7878
import java.util.HashMap;
7979
import java.util.OptionalInt;
80+
import java.util.UUID;
8081

8182
public class UpstreamPacketHandler extends LoggingPacketHandler {
8283

8384
private boolean networkSettingsRequested = false;
84-
private final Deque<String> packsToSent = new ArrayDeque<>();
85+
private final Deque<String> packsToSend = new ArrayDeque<>();
8586
private final CompressionStrategy compressionStrategy;
8687

8788
private SessionLoadResourcePacksEventImpl resourcePackLoadEvent;
@@ -133,8 +134,6 @@ private boolean setCorrectCodec(int protocolVersion) {
133134
}
134135

135136
session.getUpstream().getSession().setCodec(packetCodec);
136-
// FIXME temporary until 1.20.80 is dropped
137-
session.getPlayerEntity().resetAir();
138137
return true;
139138
}
140139

@@ -209,10 +208,12 @@ public PacketSignal handle(LoginPacket loginPacket) {
209208
PackCodec codec = pack.codec();
210209
ResourcePackManifest.Header header = pack.manifest().header();
211210
resourcePacksInfo.getResourcePackInfos().add(new ResourcePacksInfoPacket.Entry(
212-
header.uuid().toString(), header.version().toString(), codec.size(), pack.contentKey(),
211+
header.uuid(), header.version().toString(), codec.size(), pack.contentKey(),
213212
"", header.uuid().toString(), false, false, false, ""));
214213
}
215214
resourcePacksInfo.setForcedToAccept(GeyserImpl.getInstance().getConfig().isForceResourcePacks());
215+
resourcePacksInfo.setWorldTemplateId(UUID.randomUUID());
216+
resourcePacksInfo.setWorldTemplateVersion("*");
216217
session.sendUpstreamPacket(resourcePacksInfo);
217218

218219
GeyserLocale.loadGeyserLocale(session.locale());
@@ -233,8 +234,8 @@ public PacketSignal handle(ResourcePackClientResponsePacket packet) {
233234
break;
234235

235236
case SEND_PACKS:
236-
packsToSent.addAll(packet.getPackIds());
237-
sendPackDataInfo(packsToSent.pop());
237+
packsToSend.addAll(packet.getPackIds());
238+
sendPackDataInfo(packsToSend.pop());
238239
break;
239240

240241
case HAVE_ALL_PACKS:
@@ -311,7 +312,7 @@ public PacketSignal handle(PlayerAuthInputPacket packet) {
311312
@Override
312313
public PacketSignal handle(ResourcePackChunkRequestPacket packet) {
313314
ResourcePackChunkDataPacket data = new ResourcePackChunkDataPacket();
314-
ResourcePack pack = this.resourcePackLoadEvent.getPacks().get(packet.getPackId().toString());
315+
ResourcePack pack = this.resourcePackLoadEvent.getPacks().get(packet.getPackId());
315316
PackCodec codec = pack.codec();
316317

317318
data.setChunkIndex(packet.getChunkIndex());
@@ -335,8 +336,8 @@ public PacketSignal handle(ResourcePackChunkRequestPacket packet) {
335336
session.sendUpstreamPacket(data);
336337

337338
// Check if it is the last chunk and send next pack in queue when available.
338-
if (remainingSize <= GeyserResourcePack.CHUNK_SIZE && !packsToSent.isEmpty()) {
339-
sendPackDataInfo(packsToSent.pop());
339+
if (remainingSize <= GeyserResourcePack.CHUNK_SIZE && !packsToSend.isEmpty()) {
340+
sendPackDataInfo(packsToSend.pop());
340341
}
341342

342343
return PacketSignal.HANDLED;
@@ -345,7 +346,8 @@ public PacketSignal handle(ResourcePackChunkRequestPacket packet) {
345346
private void sendPackDataInfo(String id) {
346347
ResourcePackDataInfoPacket data = new ResourcePackDataInfoPacket();
347348
String[] packID = id.split("_");
348-
ResourcePack pack = this.resourcePackLoadEvent.getPacks().get(packID[0]);
349+
UUID uuid = UUID.fromString(packID[0]);
350+
ResourcePack pack = this.resourcePackLoadEvent.getPacks().get(uuid);
349351
PackCodec codec = pack.codec();
350352
ResourcePackManifest.Header header = pack.manifest().header();
351353

core/src/main/java/org/geysermc/geyser/registry/Registries.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import java.util.IdentityHashMap;
7171
import java.util.Map;
7272
import java.util.Set;
73+
import java.util.UUID;
7374

7475
/**
7576
* Holds all the common registries in Geyser.
@@ -163,7 +164,7 @@ public final class Registries {
163164
/**
164165
* A mapped registry holding {@link ResourcePack}'s with the pack uuid as keys.
165166
*/
166-
public static final SimpleMappedDeferredRegistry<String, ResourcePack> RESOURCE_PACKS = SimpleMappedDeferredRegistry.create(GeyserImpl.getInstance().packDirectory(), RegistryLoaders.RESOURCE_PACKS);
167+
public static final SimpleMappedDeferredRegistry<UUID, ResourcePack> RESOURCE_PACKS = SimpleMappedDeferredRegistry.create(GeyserImpl.getInstance().packDirectory(), RegistryLoaders.RESOURCE_PACKS);
167168

168169
/**
169170
* A versioned registry holding most Bedrock tags, with the Java item list (sorted) being the key, and the tag name as the value.

core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.HashMap;
4646
import java.util.List;
4747
import java.util.Map;
48+
import java.util.UUID;
4849
import java.util.concurrent.atomic.AtomicReference;
4950
import java.util.stream.Collectors;
5051
import java.util.stream.Stream;
@@ -54,7 +55,7 @@
5455
/**
5556
* Loads {@link ResourcePack}s within a {@link Path} directory, firing the {@link GeyserLoadResourcePacksEvent}.
5657
*/
57-
public class ResourcePackLoader implements RegistryLoader<Path, Map<String, ResourcePack>> {
58+
public class ResourcePackLoader implements RegistryLoader<Path, Map<UUID, ResourcePack>> {
5859

5960
static final PathMatcher PACK_MATCHER = FileSystems.getDefault().getPathMatcher("glob:**.{zip,mcpack}");
6061

@@ -64,8 +65,8 @@ public class ResourcePackLoader implements RegistryLoader<Path, Map<String, Reso
6465
* Loop through the packs directory and locate valid resource pack files
6566
*/
6667
@Override
67-
public Map<String, ResourcePack> load(Path directory) {
68-
Map<String, ResourcePack> packMap = new HashMap<>();
68+
public Map<UUID, ResourcePack> load(Path directory) {
69+
Map<UUID, ResourcePack> packMap = new HashMap<>();
6970

7071
if (!Files.exists(directory)) {
7172
try {
@@ -100,7 +101,7 @@ public Map<String, ResourcePack> load(Path directory) {
100101
for (Path path : event.resourcePacks()) {
101102
try {
102103
GeyserResourcePack pack = readPack(path);
103-
packMap.put(pack.manifest().header().uuid().toString(), pack);
104+
packMap.put(pack.manifest().header().uuid(), pack);
104105
} catch (Exception e) {
105106
e.printStackTrace();
106107
}

0 commit comments

Comments
 (0)