public final class FlagTransformer extends java.lang.Object implements EntityDataTransformer<java.lang.Long,java.util.EnumMap<EntityFlag,java.lang.Boolean>>
Entity flags are split into multiple groups of 64 flags each (FLAGS, FLAGS_2). Each transformer instance handles one group, identified by its index: - index 0 = FLAGS (flags 0-63) - index 1 = FLAGS_2 (flags 64-127)
IDENTITY| Constructor and Description |
|---|
FlagTransformer(org.cloudburstmc.protocol.common.util.TypeMap<EntityFlag> typeMap,
int index) |
| Modifier and Type | Method and Description |
|---|---|
java.util.EnumMap<EntityFlag,java.lang.Boolean> |
deserialize(BedrockCodecHelper helper,
EntityDataMap map,
java.lang.Long value)
Deserializes a packed long value into individual entity flags.
|
java.lang.Long |
serialize(BedrockCodecHelper helper,
EntityDataMap map,
java.util.EnumMap<EntityFlag,java.lang.Boolean> flags)
Serializes entity flags into a packed long value for network transmission.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitidentitypublic FlagTransformer(org.cloudburstmc.protocol.common.util.TypeMap<EntityFlag> typeMap, int index)
public java.lang.Long serialize(BedrockCodecHelper helper, EntityDataMap map, java.util.EnumMap<EntityFlag,java.lang.Boolean> flags)
Only flags within this transformer's range (determined by index) are processed. For example, if index=0, only flags 0-63 are handled; flags 64+ are ignored.
Returns null if no flags in this group are present, preventing unnecessary serialization of empty flag groups. This fixes the issue where missing flag groups would be written as zero, causing clients to incorrectly clear flags.
serialize in interface EntityDataTransformer<java.lang.Long,java.util.EnumMap<EntityFlag,java.lang.Boolean>>helper - the codec helpermap - the entity data mapflags - the complete flag mappublic java.util.EnumMap<EntityFlag,java.lang.Boolean> deserialize(BedrockCodecHelper helper, EntityDataMap map, java.lang.Long value)
Reads all 64 possible flag positions for this group, setting each flag to true or false based on the corresponding bit in the value.
deserialize in interface EntityDataTransformer<java.lang.Long,java.util.EnumMap<EntityFlag,java.lang.Boolean>>helper - the codec helpermap - the entity data map to populatevalue - the packed long value containing flag states