@Override
public ByteBuf encode(ByteBuf buf, EntityPropertyMessage message) throws IOException {
ByteBufUtils.writeVarInt(buf, message.getId());
Map<String, Property> props = message.getProperties();
buf.writeInt(props.size());
for (Entry<String, Property> property : props.entrySet()) {
ByteBufUtils.writeUTF8(buf, property.getKey());
buf.writeDouble(property.getValue().getValue());
Collection<AttributeModifier> modifiers = property.getValue().getModifiers();
if (modifiers == null) {
ByteBufUtils.writeVarInt(buf, 0);
} else {
ByteBufUtils.writeVarInt(buf, modifiers.size());
for (AttributeModifier modifier : modifiers) {
GlowBufUtils.writeUuid(buf, modifier.getUniqueId());
buf.writeDouble(modifier.getAmount());
buf.writeByte(modifier.getOperation().ordinal());
}
}
}
return buf;
}
}