summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol18x.cpp
diff options
context:
space:
mode:
authorJulian Laubstein <julianlaubstein@yahoo.de>2015-07-15 22:31:48 +0200
committerJulian Laubstein <julianlaubstein@yahoo.de>2015-07-15 22:31:48 +0200
commit8b74adcfab2a39b8d663f9ebc21cc4cde42761ef (patch)
treebbb45c47667db874f73f57fd8fa55bac4f5f72c4 /src/Protocol/Protocol18x.cpp
parentMerge pull request #2350 from SamJBarney/PeonySnowFix (diff)
parentLeather Armor can now be dyed. (diff)
downloadcuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.gz
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.bz2
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.lz
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.xz
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.zst
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.zip
Diffstat (limited to 'src/Protocol/Protocol18x.cpp')
-rw-r--r--src/Protocol/Protocol18x.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index db510825e..98b22add1 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -2869,6 +2869,10 @@ void cProtocol180::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"))
@@ -3018,12 +3022,13 @@ void cProtocol180::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.WriteBEInt8(0);
return;
}
+
// Send the enchantments and custom names:
cFastNBTWriter Writer;
if (a_Item.m_RepairCost != 0)
@@ -3035,9 +3040,14 @@ void cProtocol180::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());