Skip to content

Commit 9d4a664

Browse files
Kas-tleSupremeMortal
authored andcommitted
Only log unknown entity flag if bit is set to true
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
1 parent 8bbe878 commit 9d4a664

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/transformer/FlagTransformer.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,25 @@ public EnumMap<EntityFlag, Boolean> deserialize(BedrockCodecHelper helper, Entit
109109

110110
// Iterate through all 64 possible flags in this group
111111
for (int i = lower; i < upper; i++) {
112+
// Get the bit position within this 64-bit group (0-63)
113+
int idx = i & 0x3f;
114+
112115
EntityFlag flag = this.typeMap.getTypeUnsafe(i);
116+
117+
// Check if the bit at this position is set
118+
boolean set = (value & (1L << idx)) != 0;
119+
113120
if (flag == null) {
114-
// Flag index exists in the protocol but isn't mapped to an EntityFlag enum value
115-
log.debug("Unknown entity flag detected with index {}", i);
121+
// Only log "Unknown entity flag" if the bit is actually set (1).
122+
// If the bit is 0, it is likely just unused padding at the end of the long
123+
// (e.g., indices 100-127 when only 100 flags are defined).
124+
if (set) {
125+
log.debug("Unknown entity flag set to true detected with index {}", i);
126+
}
116127
continue;
117128
}
118129

119-
// Get the bit position within this 64-bit group (0-63)
120-
int idx = i & 0x3f;
121-
122-
// Check if the bit at this position is set
123-
if ((value & (1L << idx)) != 0) {
130+
if (set) {
124131
flags.put(flag, true);
125132
} else {
126133
flags.put(flag, false);

0 commit comments

Comments
 (0)