diff options
Diffstat (limited to 'src/Protocol/Protocol17x.cpp')
-rw-r--r-- | src/Protocol/Protocol17x.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index dc602ec6c..48bfc8583 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2637,6 +2637,10 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) a_Item.m_Lore = Lore; } + else if ((NBT.GetType(displaytag) == TAG_Int) && (NBT.GetName(displaytag) == "color")) + { + a_Item.m_ItemColor.m_Color = static_cast<unsigned int>(NBT.GetInt(displaytag)); + } } } else if ((TagName == "Fireworks") || (TagName == "Explosion")) @@ -2723,7 +2727,7 @@ void cProtocol172::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) a_Pkt.WriteBEInt8(a_Item.m_ItemCount); a_Pkt.WriteBEInt16(a_Item.m_ItemDamage); - if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR)) + if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR) && !a_Item.m_ItemColor.IsValid()) { a_Pkt.WriteBEInt16(-1); return; @@ -2740,9 +2744,15 @@ void cProtocol172::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench"; EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName); } - if (!a_Item.IsBothNameAndLoreEmpty()) + if (!a_Item.IsBothNameAndLoreEmpty() || a_Item.m_ItemColor.IsValid()) { Writer.BeginCompound("display"); + + if (a_Item.m_ItemColor.IsValid()) + { + Writer.AddInt("color", static_cast<int>(a_Item.m_ItemColor.m_Color)); + } + if (!a_Item.IsCustomNameEmpty()) { Writer.AddString("Name", a_Item.m_CustomName.c_str()); |