From af5eb5d6ac875eb5d788b102caa0e3f0cb46a91d Mon Sep 17 00:00:00 2001 From: Jonah Jeleniewski Date: Thu, 12 Sep 2024 23:06:06 +1000 Subject: [PATCH] Fix if-guard generation around dummy fields --- CHANGELOG.md | 5 +++++ protocol_code_generator/generate/object_code_generator.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71ee338..dbe2ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Incorrect (de)serialization of data structures containing both `` and `` elements.' + (Only `ChestCloseServerPacket` was impacted.) + ## [1.1.1] - 2024-08-22 ### Changed diff --git a/protocol_code_generator/generate/object_code_generator.py b/protocol_code_generator/generate/object_code_generator.py index 081fe4f..750cccb 100644 --- a/protocol_code_generator/generate/object_code_generator.py +++ b/protocol_code_generator/generate/object_code_generator.py @@ -287,7 +287,7 @@ def _generate_dummy(self, protocol_dummy): .build() ) - needs_if_guards = not self._data.serialize and not self._data.deserialize + needs_if_guards = not self._data.serialize.empty or not self._data.deserialize.empty if needs_if_guards: self._data.serialize.begin_control_flow("if len(writer) == old_writer_length")