| 658 | |
| 659 | |
| 660 | void cProtocol132::WriteItem(const cItem & a_Item) |
| 661 | { |
| 662 | short ItemType = a_Item.m_ItemType; |
| 663 | ASSERT(ItemType >= -1); // Check validity of packets in debug runtime |
| 664 | if (ItemType <= 0) |
| 665 | { |
| 666 | // Fix, to make sure no invalid values are sent. |
| 667 | ItemType = -1; |
| 668 | } |
| 669 | |
| 670 | if (a_Item.IsEmpty()) |
| 671 | { |
| 672 | WriteShort(-1); |
| 673 | return; |
| 674 | } |
| 675 | |
| 676 | WriteShort(ItemType); |
| 677 | WriteChar (a_Item.m_ItemCount); |
| 678 | WriteShort(a_Item.m_ItemDamage); |
| 679 | |
| 680 | if (a_Item.m_Enchantments.IsEmpty()) |
| 681 | { |
| 682 | WriteShort(-1); |
| 683 | return; |
| 684 | } |
| 685 | |
| 686 | // Send the enchantments: |
| 687 | cFastNBTWriter Writer; |
| 688 | const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench"; |
| 689 | EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName); |
| 690 | Writer.Finish(); |
| 691 | AString Compressed; |
| 692 | CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed); |
| 693 | WriteShort((short)Compressed.size()); |
| 694 | SendData(Compressed.data(), Compressed.size()); |
| 695 | } |
| 696 | |
| 697 | |
| 698 |
nothing calls this directly
no test coverage detected