Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.21.30 #5041

Merged
merged 10 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public enum GeyserAttributeType {
// Universal Attributes
FOLLOW_RANGE("minecraft:generic.follow_range", "minecraft:follow_range", 0f, 2048f, 32f),
KNOCKBACK_RESISTANCE("minecraft:generic.knockback_resistance", "minecraft:knockback_resistance", 0f, 1f, 0f),
MOVEMENT_SPEED("minecraft:generic.movement_speed", "minecraft:movement", 0f, 1024f, 0.1f),
MOVEMENT_SPEED("minecraft:generic.movement_speed", "minecraft:movement", 0f, Float.MAX_VALUE, 0.1f),
FLYING_SPEED("minecraft:generic.flying_speed", "minecraft:movement", 0.0f, 1024.0f, 0.4000000059604645f),
ATTACK_DAMAGE("minecraft:generic.attack_damage", "minecraft:attack_damage", 0f, 2048f, 1f),
HORSE_JUMP_STRENGTH("minecraft:horse.jump_strength", "minecraft:horse.jump_strength", 0.0f, 2.0f, 0.7f),
Expand All @@ -54,7 +54,7 @@ public enum GeyserAttributeType {

// Bedrock Attributes
ABSORPTION(null, "minecraft:absorption", 0f, 1024f, 0f),
EXHAUSTION(null, "minecraft:player.exhaustion", 0f, 5f, 0f),
EXHAUSTION(null, "minecraft:player.exhaustion", 0f, 20f, 0f),
EXPERIENCE(null, "minecraft:player.experience", 0f, 1f, 0f),
EXPERIENCE_LEVEL(null, "minecraft:player.level", 0f, 24791.00f, 0f),
HEALTH(null, "minecraft:health", 0f, 1024f, 20f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public class CameraDefinitions {

static {
CAMERA_PRESETS = List.of(
new CameraPreset(CameraPerspective.FIRST_PERSON.id(), "", null, null, null, null, null, null, OptionalBoolean.empty()),
new CameraPreset(CameraPerspective.FREE.id(), "", null, null, null, null, null, null, OptionalBoolean.empty()),
new CameraPreset(CameraPerspective.THIRD_PERSON.id(), "", null, null, null, null, null, null, OptionalBoolean.empty()),
new CameraPreset(CameraPerspective.THIRD_PERSON_FRONT.id(), "", null, null, null, null, null, null, OptionalBoolean.empty()),
new CameraPreset("geyser:free_audio", "minecraft:free", null, null, null, null, null, CameraAudioListener.PLAYER, OptionalBoolean.of(false)),
new CameraPreset("geyser:free_effects", "minecraft:free", null, null, null, null, null, CameraAudioListener.CAMERA, OptionalBoolean.of(true)),
new CameraPreset("geyser:free_audio_effects", "minecraft:free", null, null, null, null, null, CameraAudioListener.PLAYER, OptionalBoolean.of(true)));
new CameraPreset(CameraPerspective.FIRST_PERSON.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null),
new CameraPreset(CameraPerspective.FREE.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null),
new CameraPreset(CameraPerspective.THIRD_PERSON.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null),
new CameraPreset(CameraPerspective.THIRD_PERSON_FRONT.id(), "", null, null, null, null, null, null, OptionalBoolean.empty(), null, OptionalBoolean.empty(), null),
new CameraPreset("geyser:free_audio", "minecraft:free", null, null, null, null, null, CameraAudioListener.PLAYER, OptionalBoolean.empty(), null, OptionalBoolean.of(false), null),
new CameraPreset("geyser:free_effects", "minecraft:free", null, null, null, null, null, CameraAudioListener.CAMERA, OptionalBoolean.empty(), null, OptionalBoolean.of(true), null),
new CameraPreset("geyser:free_audio_effects", "minecraft:free", null, null, null, null, null, CameraAudioListener.PLAYER, OptionalBoolean.empty(), null, OptionalBoolean.of(true), null));

SimpleDefinitionRegistry.Builder<NamedDefinition> builder = SimpleDefinitionRegistry.builder();
for (int i = 0; i < CAMERA_PRESETS.size(); i++) {
Expand Down
55 changes: 52 additions & 3 deletions core/src/main/java/org/geysermc/geyser/network/CodecProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
import org.cloudburstmc.protocol.bedrock.codec.v712.serializer.InventoryContentSerializer_v712;
import org.cloudburstmc.protocol.bedrock.codec.v712.serializer.InventorySlotSerializer_v712;
import org.cloudburstmc.protocol.bedrock.codec.v712.serializer.MobArmorEquipmentSerializer_v712;
import org.cloudburstmc.protocol.bedrock.codec.v729.serializer.InventoryContentSerializer_v729;
import org.cloudburstmc.protocol.bedrock.codec.v729.serializer.InventorySlotSerializer_v729;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerSlotType;
import org.cloudburstmc.protocol.bedrock.data.inventory.FullContainerName;
import org.cloudburstmc.protocol.bedrock.packet.AnvilDamagePacket;
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.cloudburstmc.protocol.bedrock.packet.BossEventPacket;
Expand Down Expand Up @@ -139,6 +143,19 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, InventoryCont
}
};

private static final BedrockPacketSerializer<InventoryContentPacket> INVENTORY_CONTENT_SERIALIZER_V729 = new InventoryContentSerializer_v729() {
@Override
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, InventoryContentPacket packet) {
romanalexander marked this conversation as resolved.
Show resolved Hide resolved
packet.setContainerNameData(new FullContainerName(ContainerSlotType.ANVIL_INPUT, null));
super.serialize(buffer, helper, packet);
}

@Override
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, InventoryContentPacket packet) {
throw new IllegalArgumentException("Client cannot send InventoryContentPacket in server-auth inventory environment!");
}
};

/**
* Serializer that throws an exception when trying to deserialize InventorySlotPacket since server-auth inventory is used.
*/
Expand All @@ -159,6 +176,21 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, InventorySlot
}
};

private static final BedrockPacketSerializer<InventorySlotPacket> INVENTORY_SLOT_SERIALIZER_V729 = new InventorySlotSerializer_v729() {
@Override
public void serialize(ByteBuf buffer, BedrockCodecHelper helper, InventorySlotPacket packet) {
packet.setContainerNameData(new FullContainerName(ContainerSlotType.ANVIL_INPUT, null));
romanalexander marked this conversation as resolved.
Show resolved Hide resolved
super.serialize(buffer, helper, packet);
}

@Override
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, InventorySlotPacket packet) {
throw new IllegalArgumentException("Client cannot send InventorySlotPacket in server-auth inventory environment!");
}
};



/**
* Serializer that does nothing when trying to deserialize BossEventPacket since it is not used from the client.
*/
Expand Down Expand Up @@ -256,8 +288,25 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, MobEquipmentP

@SuppressWarnings("unchecked")
static BedrockCodec processCodec(BedrockCodec codec) {
boolean is729 = codec.getProtocolVersion() == 729;
romanalexander marked this conversation as resolved.
Show resolved Hide resolved
boolean isPre712 = codec.getProtocolVersion() < 712;


BedrockPacketSerializer<InventoryContentPacket> inventoryContentPacketBedrockPacketSerializer;
if (is729) {
inventoryContentPacketBedrockPacketSerializer = INVENTORY_CONTENT_SERIALIZER_V729;
} else if (isPre712) {
inventoryContentPacketBedrockPacketSerializer = INVENTORY_CONTENT_SERIALIZER_V407;
} else {
inventoryContentPacketBedrockPacketSerializer = INVENTORY_CONTENT_SERIALIZER_V712;
}
BedrockPacketSerializer<InventorySlotPacket> inventorySlotPacketBedrockPacketSerializer;
if (is729) {
inventorySlotPacketBedrockPacketSerializer = INVENTORY_SLOT_SERIALIZER_V729;
} else if (isPre712) {
inventorySlotPacketBedrockPacketSerializer = INVENTORY_SLOT_SERIALIZER_V407;
} else {
inventorySlotPacketBedrockPacketSerializer = INVENTORY_SLOT_SERIALIZER_V712;
}
BedrockCodec.Builder codecBuilder = codec.toBuilder()
// Illegal unused serverbound EDU packets
.updateSerializer(PhotoTransferPacket.class, ILLEGAL_SERIALIZER)
Expand Down Expand Up @@ -286,8 +335,8 @@ static BedrockCodec processCodec(BedrockCodec codec) {
.updateSerializer(AnvilDamagePacket.class, IGNORED_SERIALIZER)
.updateSerializer(RefreshEntitlementsPacket.class, IGNORED_SERIALIZER)
// Illegal when serverbound due to Geyser specific setup
.updateSerializer(InventoryContentPacket.class, isPre712 ? INVENTORY_CONTENT_SERIALIZER_V407 : INVENTORY_CONTENT_SERIALIZER_V712)
.updateSerializer(InventorySlotPacket.class, isPre712 ? INVENTORY_SLOT_SERIALIZER_V407 : INVENTORY_SLOT_SERIALIZER_V712)
.updateSerializer(InventoryContentPacket.class, inventoryContentPacketBedrockPacketSerializer)
.updateSerializer(InventorySlotPacket.class, inventorySlotPacketBedrockPacketSerializer)
// Ignored only when serverbound
.updateSerializer(BossEventPacket.class, BOSS_EVENT_SERIALIZER)
.updateSerializer(MobArmorEquipmentPacket.class, isPre712 ? MOB_ARMOR_EQUIPMENT_SERIALIZER_V291 : MOB_ARMOR_EQUIPMENT_SERIALIZER_V712)
Expand Down
10 changes: 7 additions & 3 deletions core/src/main/java/org/geysermc/geyser/network/GameProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685;
import org.cloudburstmc.protocol.bedrock.codec.v686.Bedrock_v686;
import org.cloudburstmc.protocol.bedrock.codec.v712.Bedrock_v712;
import org.cloudburstmc.protocol.bedrock.codec.v729.Bedrock_v729;
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodec;
Expand All @@ -49,9 +50,9 @@ 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 = CodecProcessor.processCodec(Bedrock_v712.CODEC.toBuilder()
.minecraftVersion("1.21.20/1.21.21")
.build());
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = CodecProcessor.processCodec(CodecProcessor.processCodec(Bedrock_v729.CODEC.toBuilder()
.minecraftVersion("1.21.30/1.21.31")
romanalexander marked this conversation as resolved.
Show resolved Hide resolved
.build()));

/**
* A list of all supported Bedrock versions that can join Geyser
Expand All @@ -65,6 +66,9 @@ public final class GameProtocol {
private static final PacketCodec DEFAULT_JAVA_CODEC = MinecraftCodec.CODEC;

static {
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v712.CODEC.toBuilder()
.minecraftVersion("1.21.20/1.21.21")
.build()));
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v671.CODEC.toBuilder()
.minecraftVersion("1.20.80/1.20.81")
.build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685;
import org.cloudburstmc.protocol.bedrock.codec.v712.Bedrock_v712;
import org.cloudburstmc.protocol.bedrock.codec.v729.Bedrock_v729;
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.geysermc.geyser.GeyserImpl;
Expand Down Expand Up @@ -110,7 +111,40 @@ private static void registerBedrockBlocks() {
var blockMappers = ImmutableMap.<ObjectIntPair<String>, Remapper>builder()
.put(ObjectIntPair.of("1_20_80", Bedrock_v671.CODEC.getProtocolVersion()), Conversion685_671::remapBlock)
.put(ObjectIntPair.of("1_21_0", Bedrock_v685.CODEC.getProtocolVersion()), Conversion712_685::remapBlock)
.put(ObjectIntPair.of("1_21_20", Bedrock_v712.CODEC.getProtocolVersion()), tag -> tag)
.put(ObjectIntPair.of("1_21_20", Bedrock_v712.CODEC.getProtocolVersion()), Conversion729_712::remapBlock)
.put(ObjectIntPair.of("1_21_30", Bedrock_v729.CODEC.getProtocolVersion()), tag -> { // TODO: Remove me when mappings is updated
if(Objects.equals(tag.getString("name"), "minecraft:sponge")) {
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
builder.remove("sponge_type");
NbtMap states = builder.build();
return tag.toBuilder().putString("name", "minecraft:sponge").putCompound("states", states).build();
}
Camotoy marked this conversation as resolved.
Show resolved Hide resolved
if(Objects.equals(tag.getString("name"), "minecraft:tnt")) {
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
builder.remove("allow_underwater_bit");
NbtMap states = builder.build();
return tag.toBuilder().putString("name", "minecraft:tnt").putCompound("states", states).build();
}
if(Objects.equals(tag.getString("name"), "minecraft:cobblestone_wall")) {
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
builder.remove("wall_block_type");
NbtMap states = builder.build();
return tag.toBuilder().putString("name", "minecraft:cobblestone_wall").putCompound("states", states).build();
}
if(Objects.equals(tag.getString("name"), "minecraft:purpur_block")) {
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
builder.remove("chisel_type");
NbtMap states = builder.build();
return tag.toBuilder().putString("name", "minecraft:purpur_block").putCompound("states", states).build();
}
if(Objects.equals(tag.getString("name"), "minecraft:structure_void")) {
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
builder.remove("structure_void_type");
NbtMap states = builder.build();
return tag.toBuilder().putString("name", "minecraft:structure_void").putCompound("states", states).build();
}
return tag;
})
.build();

// We can keep this strong as nothing should be garbage collected
Expand Down
Loading