From 43b1c8727206eb3cf8ba62d0d7650662ff67a1f9 Mon Sep 17 00:00:00 2001 From: Alemiz Date: Sun, 20 Oct 2024 18:35:41 +0200 Subject: [PATCH] Add support for MCBE 1.21.40 (#263) Co-Authored-By: Kaooot <37877491+Kaooot@users.noreply.github.com> --- README.md | 2 + .../ResourcePacksInfoSerializer_v291.java | 2 +- .../ResourcePacksInfoSerializer_v332.java | 2 +- ...ctPlayerMovePredictionSerializer_v419.java | 2 +- .../ResourcePacksInfoSerializer_v422.java | 2 +- .../CameraInstructionSerializer_618.java | 2 +- .../CameraPresetsSerializer_v618.java | 2 +- .../ResourcePacksInfoSerializer_v618.java | 57 +++++++++-- ...ctPlayerMovePredictionSerializer_v671.java | 2 +- .../UpdatePlayerGameTypeSerializer_v671.java | 4 +- .../CameraInstructionSerializer_v712.java | 3 +- .../CameraPresetsSerializer_v712.java | 2 +- .../ResourcePacksInfoSerializer_v712.java | 2 +- .../CameraPresetsSerializer_v729.java | 3 +- .../bedrock/codec/v748/Bedrock_v748.java | 28 ++++++ .../CameraInstructionSerializer_v748.java | 51 ++++++++++ .../CameraPresetsSerializer_v748.java | 70 +++++++++++++ .../CraftingDataSerializer_v748.java | 60 ++++++++++++ .../InventoryContentSerializer_v748.java | 30 ++++++ .../InventorySlotSerializer_v748.java | 32 ++++++ .../serializer/MobEffectSerializer_v748.java | 26 +++++ .../MovementEffectSerializer_v748.java | 31 ++++++ .../PlayerAuthInputSerializer_v748.java | 98 +++++++++++++++++++ .../ResourcePacksInfoSerializer_v748.java | 51 ++++++++++ .../SetMovementAuthoritySerializer_v748.java | 24 +++++ .../bedrock/data/MovementEffectType.java | 25 +++++ .../bedrock/data/PlayerActionType.java | 9 +- .../bedrock/data/PlayerAuthInputData.java | 20 ++++ .../bedrock/data/camera/CameraPreset.java | 16 +++ .../data/camera/CameraSetInstruction.java | 4 + .../bedrock/data/inventory/ContainerId.java | 1 + .../inventory/crafting/CraftingDataType.java | 2 +- .../bedrock/packet/BedrockPacketHandler.java | 8 ++ .../bedrock/packet/BedrockPacketType.java | 2 + .../packet/InventoryContentPacket.java | 5 + .../bedrock/packet/InventorySlotPacket.java | 5 + .../bedrock/packet/MovementEffectPacket.java | 36 +++++++ .../bedrock/packet/PlayerAuthInputPacket.java | 11 +++ .../packet/ResourcePacksInfoPacket.java | 40 +++----- .../packet/SetMovementAuthorityPacket.java | 33 +++++++ .../packet/UpdatePlayerGameTypePacket.java | 2 +- 41 files changed, 756 insertions(+), 51 deletions(-) create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/Bedrock_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraInstructionSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraPresetsSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CraftingDataSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventoryContentSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventorySlotSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MobEffectSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MovementEffectSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/PlayerAuthInputSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/ResourcePacksInfoSerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/SetMovementAuthoritySerializer_v748.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/MovementEffectType.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/MovementEffectPacket.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/SetMovementAuthorityPacket.java diff --git a/README.md b/README.md index 25e200e1a..6f55c0f40 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ Check out [EXAMPLES.md](EXAMPLES.md) for examples on how to use this library. | Bedrock_v685 | 1.21.0 | | Bedrock_v686 | 1.21.2 | | Bedrock_v712 | 1.21.20 | +| Bedrock_v729 | 1.21.30 | +| Bedrock_v748 | 1.21.40 | ##### Repository: diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/ResourcePacksInfoSerializer_v291.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/ResourcePacksInfoSerializer_v291.java index 39df795f0..129317471 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/ResourcePacksInfoSerializer_v291.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/ResourcePacksInfoSerializer_v291.java @@ -36,7 +36,7 @@ protected ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHe String contentKey = helper.readString(buffer); String subPackName = helper.readString(buffer); String contentId = helper.readString(buffer); - return new ResourcePacksInfoPacket.Entry(packId, packVersion, packSize, contentKey, subPackName, contentId, false, false, false); + return new ResourcePacksInfoPacket.Entry(packId, packVersion, packSize, contentKey, subPackName, contentId, false, false, false, null); } protected void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksInfoPacket.Entry entry, boolean resource) { diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v332/serializer/ResourcePacksInfoSerializer_v332.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v332/serializer/ResourcePacksInfoSerializer_v332.java index 2e97c34ec..3a1834daf 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v332/serializer/ResourcePacksInfoSerializer_v332.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v332/serializer/ResourcePacksInfoSerializer_v332.java @@ -45,6 +45,6 @@ public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelpe String contentId = helper.readString(buffer); boolean isScripting = buffer.readBoolean(); return new ResourcePacksInfoPacket.Entry(packId, packVersion, packSize, contentKey, subPackName, contentId, - isScripting, false, false); + isScripting, false, false, null); } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v419/serializer/CorrectPlayerMovePredictionSerializer_v419.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v419/serializer/CorrectPlayerMovePredictionSerializer_v419.java index f26fea479..845b7dd26 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v419/serializer/CorrectPlayerMovePredictionSerializer_v419.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v419/serializer/CorrectPlayerMovePredictionSerializer_v419.java @@ -26,6 +26,6 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayer packet.setPosition(helper.readVector3f(buffer)); packet.setDelta(helper.readVector3f(buffer)); packet.setOnGround(buffer.readBoolean()); - packet.setTick(VarInts.readUnsignedInt(buffer)); + packet.setTick(VarInts.readUnsignedLong(buffer)); } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v422/serializer/ResourcePacksInfoSerializer_v422.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v422/serializer/ResourcePacksInfoSerializer_v422.java index 44ed72de6..dcdecadd3 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v422/serializer/ResourcePacksInfoSerializer_v422.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v422/serializer/ResourcePacksInfoSerializer_v422.java @@ -46,6 +46,6 @@ public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelpe boolean isScripting = buffer.readBoolean(); boolean raytracingCapable = resource && buffer.readBoolean(); return new ResourcePacksInfoPacket.Entry(packId, packVersion, packSize, contentKey, subPackName, contentId, - isScripting, raytracingCapable, false); + isScripting, raytracingCapable, false, null); } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraInstructionSerializer_618.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraInstructionSerializer_618.java index 134108cdc..975fd9235 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraInstructionSerializer_618.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraInstructionSerializer_618.java @@ -107,6 +107,6 @@ protected CameraSetInstruction readSetInstruction(ByteBuf buf, BedrockCodecHelpe Vector2f rot = helper.readOptional(buf, null, helper::readVector2f); Vector3f facing = helper.readOptional(buf, null, helper::readVector3f); OptionalBoolean defaultPreset = helper.readOptional(buf, OptionalBoolean.empty(), b -> OptionalBoolean.of(b.readBoolean())); - return new CameraSetInstruction(definition, ease, pos, rot, facing, null, defaultPreset); + return new CameraSetInstruction(definition, ease, pos, rot, facing, null, null, defaultPreset); } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraPresetsSerializer_v618.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraPresetsSerializer_v618.java index 85c0e4c1a..0467cd547 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraPresetsSerializer_v618.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/CameraPresetsSerializer_v618.java @@ -52,6 +52,6 @@ public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) { CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]); OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean())); - return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, null, null, listener, effects, null, null, null); + return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, null, null, listener, effects, null, null, null, null, null, null, null); } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/ResourcePacksInfoSerializer_v618.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/ResourcePacksInfoSerializer_v618.java index d10e753e0..9ca065954 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/ResourcePacksInfoSerializer_v618.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v618/serializer/ResourcePacksInfoSerializer_v618.java @@ -1,14 +1,21 @@ package org.cloudburstmc.protocol.bedrock.codec.v618.serializer; import io.netty.buffer.ByteBuf; +import io.netty.util.internal.logging.InternalLogger; +import io.netty.util.internal.logging.InternalLoggerFactory; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; import org.cloudburstmc.protocol.bedrock.codec.v448.serializer.ResourcePacksInfoSerializer_v448; import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket; +import org.cloudburstmc.protocol.common.util.VarInts; + +import java.util.HashMap; +import java.util.Map; @RequiredArgsConstructor(access = AccessLevel.PROTECTED) public class ResourcePacksInfoSerializer_v618 extends ResourcePacksInfoSerializer_v448 { + private static final InternalLogger log = InternalLoggerFactory.getInstance(ResourcePacksInfoSerializer_v618.class); public static final ResourcePacksInfoSerializer_v618 INSTANCE = new ResourcePacksInfoSerializer_v618(); @@ -25,14 +32,52 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacks } protected void writeCDNEntries(ByteBuf buffer, ResourcePacksInfoPacket packet, BedrockCodecHelper helper) { - helper.writeArray(buffer, packet.getCDNEntries(), (buf, entry) -> { - helper.writeString(buf, entry.getPackId()); - helper.writeString(buf, entry.getRemoteUrl()); - }); + ByteBuf byteBuf = buffer.alloc().ioBuffer(); + try { + int size = 0; + for (ResourcePacksInfoPacket.Entry info : packet.getResourcePackInfos()) { + if (info.getCdnUrl() != null) { + helper.writeString(byteBuf, info.getPackId() + "_" + info.getPackVersion()); + helper.writeString(byteBuf, info.getCdnUrl()); + size++; + } + } + + VarInts.writeUnsignedInt(buffer, size); + if (size > 0) { + buffer.writeBytes(byteBuf); + } + } finally { + byteBuf.release(); + } } protected void readCDNEntries(ByteBuf buffer, ResourcePacksInfoPacket packet, BedrockCodecHelper helper) { - helper.readArray(buffer, packet.getCDNEntries(), buf -> - new ResourcePacksInfoPacket.CDNEntry(helper.readString(buf), helper.readString(buf))); + int size = VarInts.readUnsignedInt(buffer); + if (size > helper.getEncodingSettings().maxListSize()) { + throw new IllegalArgumentException("CDN entries size exceeds maximum size " + size); + } + + if (size == 0 || packet.getResourcePackInfos().isEmpty()) { + return; + } + + Map cdnUrls = new HashMap<>(); + for (int i = 0; i < size; i++) { + String idVersion = helper.readString(buffer); + String url = helper.readString(buffer); + cdnUrls.put(idVersion, url); + } + + for (ResourcePacksInfoPacket.Entry info : packet.getResourcePackInfos()) { + String url = cdnUrls.remove(info.getPackId() + "_" + info.getPackVersion()); + if (url != null) { + info.setCdnUrl(url); + } + } + + if (log.isDebugEnabled() && !cdnUrls.isEmpty()) { + log.debug("Found {} CDN URLs that do not match any resource pack", cdnUrls.size()); + } } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java index 62c41e8dd..3876bcc22 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java @@ -33,7 +33,7 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayer this.readVehiclePrediction(buffer, helper, packet); } packet.setOnGround(buffer.readBoolean()); - packet.setTick(VarInts.readUnsignedInt(buffer)); + packet.setTick(VarInts.readUnsignedLong(buffer)); } protected void writeVehiclePrediction(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayerMovePredictionPacket packet) { diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/UpdatePlayerGameTypeSerializer_v671.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/UpdatePlayerGameTypeSerializer_v671.java index 4e8c7e858..1e4b3c3c1 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/UpdatePlayerGameTypeSerializer_v671.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/UpdatePlayerGameTypeSerializer_v671.java @@ -12,12 +12,12 @@ public class UpdatePlayerGameTypeSerializer_v671 extends UpdatePlayerGameTypeSer @Override public void serialize(ByteBuf buffer, BedrockCodecHelper helper, UpdatePlayerGameTypePacket packet) { super.serialize(buffer, helper, packet); - VarInts.writeUnsignedInt(buffer, packet.getTick()); + VarInts.writeUnsignedLong(buffer, packet.getTick()); } @Override public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, UpdatePlayerGameTypePacket packet) { super.deserialize(buffer, helper, packet); - packet.setTick(VarInts.readUnsignedInt(buffer)); + packet.setTick(VarInts.readUnsignedLong(buffer)); } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraInstructionSerializer_v712.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraInstructionSerializer_v712.java index 3170177cc..f4c92541d 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraInstructionSerializer_v712.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraInstructionSerializer_v712.java @@ -12,7 +12,6 @@ import org.cloudburstmc.protocol.common.util.DefinitionUtils; import org.cloudburstmc.protocol.common.util.OptionalBoolean; import org.cloudburstmc.protocol.common.util.Preconditions; -import org.cloudburstmc.protocol.common.util.VarInts; public class CameraInstructionSerializer_v712 extends CameraInstructionSerializer_618 { public static final CameraInstructionSerializer_v712 INSTANCE = new CameraInstructionSerializer_v712(); @@ -66,6 +65,6 @@ protected CameraSetInstruction readSetInstruction(ByteBuf buf, BedrockCodecHelpe Vector3f facing = helper.readOptional(buf, null, helper::readVector3f); Vector2f viewOffset = helper.readOptional(buf, null, helper::readVector2f); OptionalBoolean defaultPreset = helper.readOptional(buf, OptionalBoolean.empty(), b -> OptionalBoolean.of(b.readBoolean())); - return new CameraSetInstruction(definition, ease, pos, rot, facing, viewOffset, defaultPreset); + return new CameraSetInstruction(definition, ease, pos, rot, facing, viewOffset, null, defaultPreset); } } \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraPresetsSerializer_v712.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraPresetsSerializer_v712.java index 65fccf3b9..30575609b 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraPresetsSerializer_v712.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CameraPresetsSerializer_v712.java @@ -48,6 +48,6 @@ public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) { CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]); OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean())); - return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, null, null, null); + return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, null, null, null, null, null, null, null); } } \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/ResourcePacksInfoSerializer_v712.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/ResourcePacksInfoSerializer_v712.java index ef2eea551..295f54cd7 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/ResourcePacksInfoSerializer_v712.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/ResourcePacksInfoSerializer_v712.java @@ -39,6 +39,6 @@ public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelpe boolean isAddonPack = buffer.readBoolean(); boolean raytracingCapable = resource && buffer.readBoolean(); return new ResourcePacksInfoPacket.Entry(packId, packVersion, packSize, contentKey, subPackName, contentId, - isScripting, raytracingCapable, isAddonPack); + isScripting, raytracingCapable, isAddonPack, null); } } \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v729/serializer/CameraPresetsSerializer_v729.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v729/serializer/CameraPresetsSerializer_v729.java index c6e648d2a..550ddc7ce 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v729/serializer/CameraPresetsSerializer_v729.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v729/serializer/CameraPresetsSerializer_v729.java @@ -6,7 +6,6 @@ import org.cloudburstmc.math.vector.Vector2f; import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; -import org.cloudburstmc.protocol.bedrock.codec.v618.serializer.CameraPresetsSerializer_v618; import org.cloudburstmc.protocol.bedrock.codec.v712.serializer.CameraPresetsSerializer_v712; import org.cloudburstmc.protocol.bedrock.data.camera.CameraAudioListener; import org.cloudburstmc.protocol.bedrock.data.camera.CameraPreset; @@ -57,6 +56,6 @@ public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) { CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]); OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean())); - return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, rotationSpeed, snapToTarget, entityOffset); + return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, rotationSpeed, snapToTarget, entityOffset, null, null, null, null); } } \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/Bedrock_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/Bedrock_v748.java new file mode 100644 index 000000000..be903012c --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/Bedrock_v748.java @@ -0,0 +1,28 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748; + +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; +import org.cloudburstmc.protocol.bedrock.codec.v729.BedrockCodecHelper_v729; +import org.cloudburstmc.protocol.bedrock.codec.v729.Bedrock_v729; +import org.cloudburstmc.protocol.bedrock.codec.v748.serializer.*; +import org.cloudburstmc.protocol.bedrock.data.PacketRecipient; +import org.cloudburstmc.protocol.bedrock.packet.*; + +public class Bedrock_v748 extends Bedrock_v729 { + + public static final BedrockCodec CODEC = Bedrock_v729.CODEC.toBuilder() + .raknetProtocolVersion(11) + .protocolVersion(748) + .minecraftVersion("1.21.40") + .helper(() -> new BedrockCodecHelper_v729(ENTITY_DATA, GAME_RULE_TYPES, ITEM_STACK_REQUEST_TYPES, CONTAINER_SLOT_TYPES, PLAYER_ABILITIES, TEXT_PROCESSING_ORIGINS)) + .updateSerializer(CameraInstructionPacket.class, CameraInstructionSerializer_v748.INSTANCE) + .updateSerializer(CameraPresetsPacket.class, CameraPresetsSerializer_v748.INSTANCE) + .updateSerializer(CraftingDataPacket.class, CraftingDataSerializer_v748.INSTANCE) + .updateSerializer(InventoryContentPacket.class, InventoryContentSerializer_v748.INSTANCE) + .updateSerializer(InventorySlotPacket.class, InventorySlotSerializer_v748.INSTANCE) + .updateSerializer(MobEffectPacket.class, MobEffectSerializer_v748.INSTANCE) + .updateSerializer(PlayerAuthInputPacket.class, PlayerAuthInputSerializer_v748.INSTANCE) + .updateSerializer(ResourcePacksInfoPacket.class, ResourcePacksInfoSerializer_v748.INSTANCE) + .registerPacket(MovementEffectPacket::new, MovementEffectSerializer_v748.INSTANCE, 318, PacketRecipient.CLIENT) + .registerPacket(SetMovementAuthorityPacket::new, SetMovementAuthoritySerializer_v748.INSTANCE, 319, PacketRecipient.CLIENT) + .build(); +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraInstructionSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraInstructionSerializer_v748.java new file mode 100644 index 000000000..73f733d45 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraInstructionSerializer_v748.java @@ -0,0 +1,51 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.math.vector.Vector2f; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.v712.serializer.CameraInstructionSerializer_v712; +import org.cloudburstmc.protocol.bedrock.data.camera.CameraSetInstruction; +import org.cloudburstmc.protocol.common.NamedDefinition; +import org.cloudburstmc.protocol.common.util.DefinitionUtils; +import org.cloudburstmc.protocol.common.util.OptionalBoolean; +import org.cloudburstmc.protocol.common.util.Preconditions; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class CameraInstructionSerializer_v748 extends CameraInstructionSerializer_v712 { + public static final CameraInstructionSerializer_v748 INSTANCE = new CameraInstructionSerializer_v748(); + + @Override + protected void writeSetInstruction(BedrockCodecHelper helper, ByteBuf buf, CameraSetInstruction set) { + DefinitionUtils.checkDefinition(helper.getCameraPresetDefinitions(), set.getPreset()); + buf.writeIntLE(set.getPreset().getRuntimeId()); + + helper.writeOptionalNull(buf, set.getEase(), this::writeEase); + helper.writeOptionalNull(buf, set.getPos(), helper::writeVector3f); + helper.writeOptionalNull(buf, set.getRot(), helper::writeVector2f); + helper.writeOptionalNull(buf, set.getFacing(), helper::writeVector3f); + helper.writeOptionalNull(buf, set.getViewOffset(), helper::writeVector2f); + helper.writeOptionalNull(buf, set.getEntityOffset(), helper::writeVector3f); + + helper.writeOptional(buf, OptionalBoolean::isPresent, set.getDefaultPreset(), + (b, optional) -> b.writeBoolean(optional.getAsBoolean())); + } + + @Override + protected CameraSetInstruction readSetInstruction(ByteBuf buf, BedrockCodecHelper helper) { + int runtimeId = buf.readIntLE(); + NamedDefinition definition = helper.getCameraPresetDefinitions().getDefinition(runtimeId); + Preconditions.checkNotNull(definition, "Unknown camera preset " + runtimeId); + + CameraSetInstruction.EaseData ease = helper.readOptional(buf, null, this::readEase); + Vector3f pos = helper.readOptional(buf, null, helper::readVector3f); + Vector2f rot = helper.readOptional(buf, null, helper::readVector2f); + Vector3f facing = helper.readOptional(buf, null, helper::readVector3f); + Vector2f viewOffset = helper.readOptional(buf, null, helper::readVector2f); + Vector3f entityOffset = helper.readOptional(buf, null, helper::readVector3f); + OptionalBoolean defaultPreset = helper.readOptional(buf, OptionalBoolean.empty(), b -> OptionalBoolean.of(b.readBoolean())); + return new CameraSetInstruction(definition, ease, pos, rot, facing, viewOffset, entityOffset, defaultPreset); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraPresetsSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraPresetsSerializer_v748.java new file mode 100644 index 000000000..d87583a4a --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CameraPresetsSerializer_v748.java @@ -0,0 +1,70 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.math.vector.Vector2f; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.v729.serializer.CameraPresetsSerializer_v729; +import org.cloudburstmc.protocol.bedrock.data.camera.CameraAudioListener; +import org.cloudburstmc.protocol.bedrock.data.camera.CameraPreset; +import org.cloudburstmc.protocol.common.util.OptionalBoolean; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class CameraPresetsSerializer_v748 extends CameraPresetsSerializer_v729 { + public static final CameraPresetsSerializer_v748 INSTANCE = new CameraPresetsSerializer_v748(); + + @Override + public void writePreset(ByteBuf buffer, BedrockCodecHelper helper, CameraPreset preset) { + helper.writeString(buffer, preset.getIdentifier()); + helper.writeString(buffer, preset.getParentPreset()); + helper.writeOptionalNull(buffer, preset.getPos(), (buf, pos) -> buf.writeFloatLE(pos.getX())); + helper.writeOptionalNull(buffer, preset.getPos(), (buf, pos) -> buf.writeFloatLE(pos.getY())); + helper.writeOptionalNull(buffer, preset.getPos(), (buf, pos) -> buf.writeFloatLE(pos.getZ())); + helper.writeOptionalNull(buffer, preset.getPitch(), ByteBuf::writeFloatLE); + helper.writeOptionalNull(buffer, preset.getYaw(), ByteBuf::writeFloatLE); + helper.writeOptionalNull(buffer, preset.getRotationSpeed(), ByteBuf::writeFloatLE); + helper.writeOptional(buffer, OptionalBoolean::isPresent, preset.getSnapToTarget(), + (buf, optional) -> buf.writeBoolean(optional.getAsBoolean())); + helper.writeOptionalNull(buffer, preset.getHorizontalRotationLimit(), helper::writeVector2f); + helper.writeOptionalNull(buffer, preset.getVerticalRotationLimit(), helper::writeVector2f); + helper.writeOptional(buffer, OptionalBoolean::isPresent, preset.getContinueTargeting(), + (buf, optional) -> buf.writeBoolean(optional.getAsBoolean())); + helper.writeOptionalNull(buffer, preset.getViewOffset(), helper::writeVector2f); + helper.writeOptionalNull(buffer, preset.getEntityOffset(), helper::writeVector3f); + helper.writeOptionalNull(buffer, preset.getRadius(), ByteBuf::writeFloatLE); + helper.writeOptionalNull(buffer, preset.getListener(), (buf, listener) -> buf.writeByte(listener.ordinal())); + helper.writeOptional(buffer, OptionalBoolean::isPresent, preset.getPlayEffect(), + (buf, optional) -> buf.writeBoolean(optional.getAsBoolean())); + helper.writeOptionalNull(buffer, preset.getAlignTargetAndCameraForward(), + (buf, optional) -> buf.writeBoolean(optional.getAsBoolean())); + } + + @Override + public CameraPreset readPreset(ByteBuf buffer, BedrockCodecHelper helper) { + String identifier = helper.readString(buffer); + String parentPreset = helper.readString(buffer); + + Float x = helper.readOptional(buffer, null, ByteBuf::readFloatLE); + Float y = helper.readOptional(buffer, null, ByteBuf::readFloatLE); + Float z = helper.readOptional(buffer, null, ByteBuf::readFloatLE); + Vector3f pos = x == null || y == null || z == null ? null : Vector3f.from(x, y, z); + + Float pitch = helper.readOptional(buffer, null, ByteBuf::readFloatLE); + Float yaw = helper.readOptional(buffer, null, ByteBuf::readFloatLE); + Float rotationSpeed = helper.readOptional(buffer, null, ByteBuf::readFloatLE); + OptionalBoolean snapToTarget = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean())); + Vector2f horizontalRotationLimit = helper.readOptional(buffer, null, helper::readVector2f); + Vector2f verticalRotationLimit = helper.readOptional(buffer, null, helper::readVector2f); + OptionalBoolean continueTargeting = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean())); + Vector2f viewOffset = helper.readOptional(buffer, null, helper::readVector2f); + Vector3f entityOffset = helper.readOptional(buffer, null, helper::readVector3f); + Float radius = helper.readOptional(buffer, null, ByteBuf::readFloatLE); + + CameraAudioListener listener = helper.readOptional(buffer, null, buf -> CameraAudioListener.values()[buf.readUnsignedByte()]); + OptionalBoolean effects = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean())); + OptionalBoolean alignTargetAndCameraForward = helper.readOptional(buffer, OptionalBoolean.empty(), buf -> OptionalBoolean.of(buf.readBoolean())); + return new CameraPreset(identifier, parentPreset, pos, yaw, pitch, viewOffset, radius, listener, effects, rotationSpeed, snapToTarget, entityOffset, horizontalRotationLimit, verticalRotationLimit, continueTargeting, alignTargetAndCameraForward); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CraftingDataSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CraftingDataSerializer_v748.java new file mode 100644 index 000000000..a75e1df10 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/CraftingDataSerializer_v748.java @@ -0,0 +1,60 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.v685.serializer.CraftingDataSerializer_v685; +import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; +import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.CraftingDataType; +import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.RecipeUnlockingRequirement; +import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.ShapelessRecipeData; +import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemDescriptorWithCount; +import org.cloudburstmc.protocol.common.util.VarInts; + +import java.util.List; +import java.util.UUID; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class CraftingDataSerializer_v748 extends CraftingDataSerializer_v685 { + public static final CraftingDataSerializer_v748 INSTANCE = new CraftingDataSerializer_v748(); + + @Override + protected ShapelessRecipeData readShapelessRecipe(ByteBuf buffer, BedrockCodecHelper helper, CraftingDataType type) { + String recipeId = helper.readString(buffer); + List inputs = new ObjectArrayList<>(); + helper.readArray(buffer, inputs, helper::readIngredient); + + List outputs = new ObjectArrayList<>(); + helper.readArray(buffer, outputs, helper::readItemInstance); + + UUID uuid = helper.readUuid(buffer); + String craftingTag = helper.readString(buffer); + int priority = VarInts.readInt(buffer); + + RecipeUnlockingRequirement requirement = RecipeUnlockingRequirement.INVALID; + if (type == CraftingDataType.SHAPELESS || type == CraftingDataType.SHULKER_BOX) { + requirement = this.readRequirement(buffer, helper, type); + } + + int networkId = VarInts.readUnsignedInt(buffer); + return ShapelessRecipeData.of(type, recipeId, inputs, outputs, uuid, craftingTag, priority, networkId, requirement); + } + + @Override + protected void writeShapelessRecipe(ByteBuf buffer, BedrockCodecHelper helper, ShapelessRecipeData data) { + helper.writeString(buffer, data.getId()); + helper.writeArray(buffer, data.getIngredients(), helper::writeIngredient); + helper.writeArray(buffer, data.getResults(), helper::writeItemInstance); + + helper.writeUuid(buffer, data.getUuid()); + helper.writeString(buffer, data.getTag()); + VarInts.writeInt(buffer, data.getPriority()); + + if (data.getType() == CraftingDataType.SHAPELESS || data.getType() == CraftingDataType.SHULKER_BOX) { + this.writeRequirement(buffer, helper, data); + } + VarInts.writeUnsignedInt(buffer, data.getNetId()); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventoryContentSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventoryContentSerializer_v748.java new file mode 100644 index 000000000..d482362e4 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventoryContentSerializer_v748.java @@ -0,0 +1,30 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.BedrockPacketSerializer; +import org.cloudburstmc.protocol.bedrock.packet.InventoryContentPacket; +import org.cloudburstmc.protocol.common.util.VarInts; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class InventoryContentSerializer_v748 implements BedrockPacketSerializer { + public static final InventoryContentSerializer_v748 INSTANCE = new InventoryContentSerializer_v748(); + + @Override + public void serialize(ByteBuf buffer, BedrockCodecHelper helper, InventoryContentPacket packet) { + VarInts.writeUnsignedInt(buffer, packet.getContainerId()); + helper.writeArray(buffer, packet.getContents(), helper::writeNetItem); + helper.writeFullContainerName(buffer, packet.getContainerNameData()); + helper.writeNetItem(buffer, packet.getStorageItem()); + } + + @Override + public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, InventoryContentPacket packet) { + packet.setContainerId(VarInts.readUnsignedInt(buffer)); + helper.readArray(buffer, packet.getContents(), helper::readNetItem); + packet.setContainerNameData(helper.readFullContainerName(buffer)); + packet.setStorageItem(helper.readNetItem(buffer)); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventorySlotSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventorySlotSerializer_v748.java new file mode 100644 index 000000000..115018258 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/InventorySlotSerializer_v748.java @@ -0,0 +1,32 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.BedrockPacketSerializer; +import org.cloudburstmc.protocol.bedrock.packet.InventorySlotPacket; +import org.cloudburstmc.protocol.common.util.VarInts; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class InventorySlotSerializer_v748 implements BedrockPacketSerializer { + public static final InventorySlotSerializer_v748 INSTANCE = new InventorySlotSerializer_v748(); + + @Override + public void serialize(ByteBuf buffer, BedrockCodecHelper helper, InventorySlotPacket packet) { + VarInts.writeUnsignedInt(buffer, packet.getContainerId()); + VarInts.writeUnsignedInt(buffer, packet.getSlot()); + helper.writeFullContainerName(buffer, packet.getContainerNameData()); + helper.writeNetItem(buffer, packet.getStorageItem()); + helper.writeNetItem(buffer, packet.getItem()); + } + + @Override + public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, InventorySlotPacket packet) { + packet.setContainerId(VarInts.readUnsignedInt(buffer)); + packet.setSlot(VarInts.readUnsignedInt(buffer)); + packet.setContainerNameData(helper.readFullContainerName(buffer)); + packet.setStorageItem(helper.readNetItem(buffer)); + packet.setItem(helper.readNetItem(buffer)); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MobEffectSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MobEffectSerializer_v748.java new file mode 100644 index 000000000..69194c243 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MobEffectSerializer_v748.java @@ -0,0 +1,26 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.v291.serializer.MobEffectSerializer_v291; +import org.cloudburstmc.protocol.bedrock.packet.MobEffectPacket; +import org.cloudburstmc.protocol.common.util.VarInts; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class MobEffectSerializer_v748 extends MobEffectSerializer_v291 { + public static final MobEffectSerializer_v748 INSTANCE = new MobEffectSerializer_v748(); + + @Override + public void serialize(ByteBuf buffer, BedrockCodecHelper helper, MobEffectPacket packet) { + super.serialize(buffer, helper, packet); + VarInts.writeUnsignedLong(buffer, packet.getTick()); + } + + @Override + public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, MobEffectPacket packet) { + super.deserialize(buffer, helper, packet); + packet.setTick(VarInts.readUnsignedLong(buffer)); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MovementEffectSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MovementEffectSerializer_v748.java new file mode 100644 index 000000000..2c3d7b56a --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/MovementEffectSerializer_v748.java @@ -0,0 +1,31 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.BedrockPacketSerializer; +import org.cloudburstmc.protocol.bedrock.data.MovementEffectType; +import org.cloudburstmc.protocol.bedrock.packet.MovementEffectPacket; +import org.cloudburstmc.protocol.common.util.VarInts; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class MovementEffectSerializer_v748 implements BedrockPacketSerializer { + public static final MovementEffectSerializer_v748 INSTANCE = new MovementEffectSerializer_v748(); + + @Override + public void serialize(ByteBuf buffer, BedrockCodecHelper helper, MovementEffectPacket packet) { + VarInts.writeUnsignedLong(buffer, packet.getEntityRuntimeId()); + VarInts.writeUnsignedInt(buffer, packet.getEffectType().getId()); + VarInts.writeUnsignedInt(buffer, packet.getDuration()); + VarInts.writeUnsignedLong(buffer, packet.getTick()); + } + + @Override + public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, MovementEffectPacket packet) { + packet.setEntityRuntimeId(VarInts.readUnsignedLong(buffer)); + packet.setEffectType(MovementEffectType.byId(VarInts.readUnsignedInt(buffer))); + packet.setDuration(VarInts.readUnsignedInt(buffer)); + packet.setTick(VarInts.readUnsignedLong(buffer)); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/PlayerAuthInputSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/PlayerAuthInputSerializer_v748.java new file mode 100644 index 000000000..088ab041d --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/PlayerAuthInputSerializer_v748.java @@ -0,0 +1,98 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.math.vector.Vector2f; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.v712.serializer.PlayerAuthInputSerializer_v712; +import org.cloudburstmc.protocol.bedrock.data.PlayerAuthInputData; +import org.cloudburstmc.protocol.bedrock.data.PlayerBlockActionData; +import org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket; +import org.cloudburstmc.protocol.common.util.VarInts; + +import java.util.Set; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class PlayerAuthInputSerializer_v748 extends PlayerAuthInputSerializer_v712 { + public static final PlayerAuthInputSerializer_v748 INSTANCE = new PlayerAuthInputSerializer_v748(); + + @Override + public void serialize(ByteBuf buffer, BedrockCodecHelper helper, PlayerAuthInputPacket packet) { + Vector3f rotation = packet.getRotation(); + buffer.writeFloatLE(rotation.getX()); + buffer.writeFloatLE(rotation.getY()); + helper.writeVector3f(buffer, packet.getPosition()); + buffer.writeFloatLE(packet.getMotion().getX()); + buffer.writeFloatLE(packet.getMotion().getY()); + buffer.writeFloatLE(rotation.getZ()); + long flagValue = 0; + for (PlayerAuthInputData data : packet.getInputData()) { + flagValue |= (1L << data.ordinal()); + } + VarInts.writeUnsignedLong(buffer, flagValue); + VarInts.writeUnsignedInt(buffer, packet.getInputMode().ordinal()); + VarInts.writeUnsignedInt(buffer, packet.getPlayMode().ordinal()); + writeInteractionModel(buffer, helper, packet); + helper.writeVector2f(buffer, packet.getInteractRotation()); + VarInts.writeUnsignedLong(buffer, packet.getTick()); + helper.writeVector3f(buffer, packet.getDelta()); + if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_INTERACTION)) { + this.writeItemUseTransaction(buffer, helper, packet.getItemUseTransaction()); + } + if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_STACK_REQUEST)) { + helper.writeItemStackRequest(buffer, packet.getItemStackRequest()); + } + if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_BLOCK_ACTIONS)) { + VarInts.writeInt(buffer, packet.getPlayerActions().size()); + for (PlayerBlockActionData actionData : packet.getPlayerActions()) { + writePlayerBlockActionData(buffer, helper, actionData); + } + } + if (packet.getInputData().contains(PlayerAuthInputData.IN_CLIENT_PREDICTED_IN_VEHICLE)) { + helper.writeVector2f(buffer, packet.getVehicleRotation()); + VarInts.writeLong(buffer, packet.getPredictedVehicle()); + } + helper.writeVector2f(buffer, packet.getAnalogMoveVector()); + helper.writeVector3f(buffer, packet.getCameraOrientation()); + } + + @Override + public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, PlayerAuthInputPacket packet) { + float x = buffer.readFloatLE(); + float y = buffer.readFloatLE(); + packet.setPosition(helper.readVector3f(buffer)); + packet.setMotion(Vector2f.from(buffer.readFloatLE(), buffer.readFloatLE())); + float z = buffer.readFloatLE(); + packet.setRotation(Vector3f.from(x, y, z)); + long flagValue = VarInts.readUnsignedLong(buffer); + Set flags = packet.getInputData(); + for (PlayerAuthInputData flag : PlayerAuthInputData.values()) { + if ((flagValue & (1L << flag.ordinal())) != 0) { + flags.add(flag); + } + } + packet.setInputMode(INPUT_MODES[VarInts.readUnsignedInt(buffer)]); + packet.setPlayMode(CLIENT_PLAY_MODES[VarInts.readUnsignedInt(buffer)]); + readInteractionModel(buffer, helper, packet); + packet.setInteractRotation(helper.readVector2f(buffer)); + packet.setTick(VarInts.readUnsignedLong(buffer)); + packet.setDelta(helper.readVector3f(buffer)); + if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_INTERACTION)) { + packet.setItemUseTransaction(this.readItemUseTransaction(buffer, helper)); + } + if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_ITEM_STACK_REQUEST)) { + packet.setItemStackRequest(helper.readItemStackRequest(buffer)); + } + if (packet.getInputData().contains(PlayerAuthInputData.PERFORM_BLOCK_ACTIONS)) { + helper.readArray(buffer, packet.getPlayerActions(), VarInts::readInt, this::readPlayerBlockActionData, 32); // 32 is more than enough + } + if (packet.getInputData().contains(PlayerAuthInputData.IN_CLIENT_PREDICTED_IN_VEHICLE)) { + packet.setVehicleRotation(helper.readVector2f(buffer)); + packet.setPredictedVehicle(VarInts.readLong(buffer)); + } + packet.setAnalogMoveVector(helper.readVector2f(buffer)); + packet.setCameraOrientation(helper.readVector3f(buffer)); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/ResourcePacksInfoSerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/ResourcePacksInfoSerializer_v748.java new file mode 100644 index 000000000..6417f00a5 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/ResourcePacksInfoSerializer_v748.java @@ -0,0 +1,51 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.v729.serializer.ResourcePacksInfoSerializer_v729; +import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class ResourcePacksInfoSerializer_v748 extends ResourcePacksInfoSerializer_v729 { + public static final ResourcePacksInfoSerializer_v748 INSTANCE = new ResourcePacksInfoSerializer_v748(); + + @Override + public void serialize(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksInfoPacket packet) { + buffer.writeBoolean(packet.isForcedToAccept()); + buffer.writeBoolean(packet.isHasAddonPacks()); + buffer.writeBoolean(packet.isScriptingEnabled()); + writePacks(buffer, packet.getResourcePackInfos(), helper, true); + } + + @Override + public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksInfoPacket packet) { + packet.setForcedToAccept(buffer.readBoolean()); + packet.setHasAddonPacks(buffer.readBoolean()); + packet.setScriptingEnabled(buffer.readBoolean()); + readPacks(buffer, packet.getResourcePackInfos(), helper, true); + } + + @Override + public void writeEntry(ByteBuf buffer, BedrockCodecHelper helper, ResourcePacksInfoPacket.Entry entry, boolean resource) { + super.writeEntry(buffer, helper, entry, resource); + helper.writeString(buffer, entry.getCdnUrl()); + } + + @Override + public ResourcePacksInfoPacket.Entry readEntry(ByteBuf buffer, BedrockCodecHelper helper, boolean resource) { + String packId = helper.readString(buffer); + String packVersion = helper.readString(buffer); + long packSize = buffer.readLongLE(); + String contentKey = helper.readString(buffer); + String subPackName = helper.readString(buffer); + String contentId = helper.readString(buffer); + boolean isScripting = buffer.readBoolean(); + boolean isAddonPack = buffer.readBoolean(); + boolean raytracingCapable = resource && buffer.readBoolean(); + String cdnUrl = helper.readString(buffer); + return new ResourcePacksInfoPacket.Entry(packId, packVersion, packSize, contentKey, subPackName, contentId, + isScripting, raytracingCapable, isAddonPack, cdnUrl); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/SetMovementAuthoritySerializer_v748.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/SetMovementAuthoritySerializer_v748.java new file mode 100644 index 000000000..aba98d5e8 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v748/serializer/SetMovementAuthoritySerializer_v748.java @@ -0,0 +1,24 @@ +package org.cloudburstmc.protocol.bedrock.codec.v748.serializer; + +import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.BedrockPacketSerializer; +import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode; +import org.cloudburstmc.protocol.bedrock.packet.SetMovementAuthorityPacket; + +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class SetMovementAuthoritySerializer_v748 implements BedrockPacketSerializer { + public static final SetMovementAuthoritySerializer_v748 INSTANCE = new SetMovementAuthoritySerializer_v748(); + + @Override + public void serialize(ByteBuf buffer, BedrockCodecHelper helper, SetMovementAuthorityPacket packet) { + buffer.writeByte(packet.getMovementMode().ordinal()); + } + + @Override + public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, SetMovementAuthorityPacket packet) { + packet.setMovementMode(AuthoritativeMovementMode.values()[buffer.readUnsignedByte()]); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/MovementEffectType.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/MovementEffectType.java new file mode 100644 index 000000000..8b979b93e --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/MovementEffectType.java @@ -0,0 +1,25 @@ +package org.cloudburstmc.protocol.bedrock.data; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum MovementEffectType { + + INVALID(-1), + GLIDE_BOOST(0); + + private final int id; + + private static final MovementEffectType[] VALUES = values(); + + public static MovementEffectType byId(int id) { + for (MovementEffectType type : VALUES) { + if (type.getId() == id) { + return type; + } + } + return null; + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerActionType.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerActionType.java index 846694c41..badcb3eef 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerActionType.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerActionType.java @@ -24,9 +24,6 @@ public enum PlayerActionType { SET_ENCHANTMENT_SEED, START_SWIMMING, STOP_SWIMMING, - /** - * @deprecated since v729 - */ START_SPIN_ATTACK, STOP_SPIN_ATTACK, BLOCK_INTERACT, @@ -73,5 +70,9 @@ public enum PlayerActionType { /** * @since v622 */ - RECEIVED_SERVER_DATA + RECEIVED_SERVER_DATA, + /** + * @since v748 + */ + START_USING_ITEM } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerAuthInputData.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerAuthInputData.java index c4e71939c..9680b9041 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerAuthInputData.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PlayerAuthInputData.java @@ -105,4 +105,24 @@ public enum PlayerAuthInputData { * @since v729 */ DOWN_RIGHT, + /** + * @since v748 + */ + START_USING_ITEM, + /** + * @since v748 + */ + CAMERA_RELATIVE_MOVEMENT_ENABLED, + /** + * @since v748 + */ + ROT_CONTROLLED_BY_MOVE_DIRECTION, + /** + * @since v748 + */ + START_SPIN_ATTACK, + /** + * @since v748 + */ + STOP_SPIN_ATTACK } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraPreset.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraPreset.java index 7e60ad56f..4d637e772 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraPreset.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraPreset.java @@ -41,4 +41,20 @@ public class CameraPreset { * @since v729 */ private Vector3f entityOffset; + /** + * @since v748 + */ + private Vector2f horizontalRotationLimit; + /** + * @since v748 + */ + private Vector2f verticalRotationLimit; + /** + * @since v748 + */ + private OptionalBoolean continueTargeting; + /** + * @since v748 + */ + private OptionalBoolean alignTargetAndCameraForward; } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraSetInstruction.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraSetInstruction.java index e78c2611a..2d86d4bb1 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraSetInstruction.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/camera/CameraSetInstruction.java @@ -21,6 +21,10 @@ public class CameraSetInstruction { * @since v712 */ private Vector2f viewOffset; + /** + * @since v748 + */ + private Vector3f entityOffset; private OptionalBoolean defaultPreset = OptionalBoolean.empty(); @Data diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/ContainerId.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/ContainerId.java index d806876e8..ce604bcc8 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/ContainerId.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/ContainerId.java @@ -47,6 +47,7 @@ public class ContainerId { public static final int CONTAINER_ID_REGISTRY = 125; /** * @since v729 + * @deprecated since v748 */ public static final int CONTAINER_ID_REGISTRY_INVENTORY = 126; } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/crafting/CraftingDataType.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/crafting/CraftingDataType.java index 0351c84ec..78875e5a3 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/crafting/CraftingDataType.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/inventory/crafting/CraftingDataType.java @@ -6,7 +6,7 @@ public enum CraftingDataType { FURNACE, FURNACE_DATA, MULTI, - SHULKER_BOX, + SHULKER_BOX, // USER_DATA_SHAPELESS SHAPELESS_CHEMISTRY, SHAPED_CHEMISTRY, /** diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketHandler.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketHandler.java index 445a0d1ee..536fa7074 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketHandler.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketHandler.java @@ -867,4 +867,12 @@ default PacketSignal handle(CameraAimAssistPacket packet) { default PacketSignal handle(ContainerRegistryCleanupPacket packet) { return PacketSignal.UNHANDLED; } + + default PacketSignal handle(MovementEffectPacket packet) { + return PacketSignal.UNHANDLED; + } + + default PacketSignal handle(SetMovementAuthorityPacket packet) { + return PacketSignal.UNHANDLED; + } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketType.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketType.java index 40715759d..d6360a15d 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketType.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/BedrockPacketType.java @@ -216,4 +216,6 @@ public enum BedrockPacketType { SERVERBOUND_DIAGNOSTICS, CAMERA_AIM_ASSIST, CONTAINER_REGISTRY_CLEANUP, + MOVEMENT_EFFECT, + SET_MOVEMENT_AUTHORITY } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryContentPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryContentPacket.java index 404ae4b24..45c09fe67 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryContentPacket.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryContentPacket.java @@ -22,8 +22,13 @@ public class InventoryContentPacket implements BedrockPacket { private FullContainerName containerNameData; /** * @since v729 + * @deprecated since v748. Use storageItem ItemData size instead. */ private int dynamicContainerSize; + /** + * @since v748 + */ + private ItemData storageItem; @Override public final PacketSignal handle(BedrockPacketHandler handler) { diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventorySlotPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventorySlotPacket.java index eda2960d5..ca4cff9fc 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventorySlotPacket.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventorySlotPacket.java @@ -20,8 +20,13 @@ public class InventorySlotPacket implements BedrockPacket { private FullContainerName containerNameData; /** * @since v729 + * @deprecated since v748. Use storageItem ItemData size instead. */ private int dynamicContainerSize; + /** + * @since v748 + */ + private ItemData storageItem; @Override public final PacketSignal handle(BedrockPacketHandler handler) { diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/MovementEffectPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/MovementEffectPacket.java new file mode 100644 index 000000000..20480a60e --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/MovementEffectPacket.java @@ -0,0 +1,36 @@ +package org.cloudburstmc.protocol.bedrock.packet; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.cloudburstmc.protocol.bedrock.data.MovementEffectType; +import org.cloudburstmc.protocol.common.PacketSignal; + +@Data +@EqualsAndHashCode(doNotUseGetters = true) +@ToString(doNotUseGetters = true) +public class MovementEffectPacket implements BedrockPacket { + private long entityRuntimeId; + private MovementEffectType effectType; + private int duration; + private long tick; + + @Override + public PacketSignal handle(BedrockPacketHandler handler) { + return handler.handle(this); + } + + @Override + public BedrockPacketType getPacketType() { + return BedrockPacketType.MOVEMENT_EFFECT; + } + + @Override + public MovementEffectPacket clone() { + try { + return (MovementEffectPacket) super.clone(); + } catch (CloneNotSupportedException e) { + throw new AssertionError(e); + } + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/PlayerAuthInputPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/PlayerAuthInputPacket.java index aa01acd71..0de94b0c9 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/PlayerAuthInputPacket.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/PlayerAuthInputPacket.java @@ -25,6 +25,9 @@ public class PlayerAuthInputPacket implements BedrockPacket { private final Set inputData = EnumSet.noneOf(PlayerAuthInputData.class); private InputMode inputMode; private ClientPlayMode playMode; + /** + * @deprecated since v748 + */ private Vector3f vrGazeDirection; private long tick; private Vector3f delta; @@ -50,6 +53,10 @@ public class PlayerAuthInputPacket implements BedrockPacket { * @since v527 */ private InputInteractionModel inputInteractionModel; + /** + * @since v748 + */ + private Vector2f interactRotation; /** * @since 575 */ @@ -62,6 +69,10 @@ public class PlayerAuthInputPacket implements BedrockPacket { * @since 662 */ private Vector2f vehicleRotation; + /** + * @since v748 + */ + private Vector3f cameraOrientation; @Override public PacketSignal handle(BedrockPacketHandler handler) { diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/ResourcePacksInfoPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/ResourcePacksInfoPacket.java index 0f87c1a59..7fb67d2a6 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/ResourcePacksInfoPacket.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/ResourcePacksInfoPacket.java @@ -1,10 +1,7 @@ package org.cloudburstmc.protocol.bedrock.packet; import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import lombok.Value; +import lombok.*; import org.cloudburstmc.protocol.common.PacketSignal; import java.util.List; @@ -29,10 +26,6 @@ public class ResourcePacksInfoPacket implements BedrockPacket { * @deprecated since v729 */ private boolean forcingServerPacksEnabled; - /** - * @since v618 - */ - private List CDNEntries = new ObjectArrayList<>(); @Override public final PacketSignal handle(BedrockPacketHandler handler) { @@ -43,26 +36,25 @@ public BedrockPacketType getPacketType() { return BedrockPacketType.RESOURCE_PACKS_INFO; } - @Value + @Data + @AllArgsConstructor public static class Entry { - private final String packId; - private final String packVersion; - private final long packSize; - private final String contentKey; - private final String subPackName; - private final String contentId; - private final boolean scripting; - private final boolean raytracingCapable; + private String packId; + private String packVersion; + private long packSize; + private String contentKey; + private String subPackName; + private String contentId; + private boolean scripting; + private boolean raytracingCapable; /** * @since v712 */ - private final boolean addonPack; - } - - @Value - public static class CDNEntry { - private final String packId; - private final String remoteUrl; + private boolean addonPack; + /** + * @since v748 + */ + private String cdnUrl; } @Override diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/SetMovementAuthorityPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/SetMovementAuthorityPacket.java new file mode 100644 index 000000000..2e8dd2511 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/SetMovementAuthorityPacket.java @@ -0,0 +1,33 @@ +package org.cloudburstmc.protocol.bedrock.packet; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode; +import org.cloudburstmc.protocol.common.PacketSignal; + +@Data +@EqualsAndHashCode(doNotUseGetters = true) +@ToString(doNotUseGetters = true) +public class SetMovementAuthorityPacket implements BedrockPacket { + private AuthoritativeMovementMode movementMode; + + @Override + public PacketSignal handle(BedrockPacketHandler handler) { + return handler.handle(this); + } + + @Override + public BedrockPacketType getPacketType() { + return BedrockPacketType.SET_MOVEMENT_AUTHORITY; + } + + @Override + public SetMovementAuthorityPacket clone() { + try { + return (SetMovementAuthorityPacket) super.clone(); + } catch (CloneNotSupportedException e) { + throw new AssertionError(e); + } + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/UpdatePlayerGameTypePacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/UpdatePlayerGameTypePacket.java index 2689ee80b..903e0bacf 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/UpdatePlayerGameTypePacket.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/UpdatePlayerGameTypePacket.java @@ -15,7 +15,7 @@ public class UpdatePlayerGameTypePacket implements BedrockPacket { /** * @since v671 */ - private int tick; + private long tick; @Override public PacketSignal handle(BedrockPacketHandler handler) {