1
0

Merge pull request #2353 from SamJBarney/DyedArmor

Implements Dyed Leather Armor
This commit is contained in:
Julian Laubstein 2015-07-15 22:31:48 +02:00
commit 8b74adcfab
10 changed files with 420 additions and 6 deletions

View File

@ -552,6 +552,44 @@ GlisteringMelon = MelonSlice, 2:2 | GoldNugget, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1
GoldNugget, 9 = GoldIngot, * GoldNugget, 9 = GoldIngot, *
EnchantmentTable = Obsidian, 1:3, 2:3, 3:3, 2:2 | Diamond, 1:2, 3:2 | Book, 2:1 EnchantmentTable = Obsidian, 1:3, 2:3, 3:3, 2:2 | Diamond, 1:2, 3:2 | Book, 2:1
#******************************************************#
# Dyed Armor
# Do not modify
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, *
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, *
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
#******************************************************# #******************************************************#
# Fireworks & Co. # Fireworks & Co.

View File

@ -28,6 +28,7 @@ SET (SRCS
ChunkSender.cpp ChunkSender.cpp
ChunkStay.cpp ChunkStay.cpp
ClientHandle.cpp ClientHandle.cpp
Color.cpp
CommandOutput.cpp CommandOutput.cpp
CompositeChat.cpp CompositeChat.cpp
CraftingRecipes.cpp CraftingRecipes.cpp

76
src/Color.cpp Normal file
View File

@ -0,0 +1,76 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Color.h"
#define COLOR_RED_BITS 0x00FF0000
#define COLOR_GREEN_BITS 0x0000FF00
#define COLOR_BLUE_BITS 0x000000FF
#define COLOR_RED_OFFSET 16
#define COLOR_GREEN_OFFSET 8
void cColor::SetColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue)
{
m_Color = (static_cast<unsigned int>(a_Red) << COLOR_RED_OFFSET) + (static_cast<unsigned int>(a_Green) << COLOR_GREEN_OFFSET) + (static_cast<unsigned int>(a_Blue));
}
void cColor::SetRed(unsigned char a_Red)
{
m_Color = (static_cast<unsigned int>(a_Red) << COLOR_RED_OFFSET) + ((COLOR_GREEN_BITS | COLOR_BLUE_BITS) & m_Color);
}
void cColor::SetGreen(unsigned char a_Green)
{
m_Color = (static_cast<unsigned int>(a_Green) << COLOR_GREEN_OFFSET) + ((COLOR_RED_BITS | COLOR_BLUE_BITS) & m_Color);
}
void cColor::SetBlue(unsigned char a_Blue)
{
m_Color = static_cast<unsigned int>(a_Blue) + ((COLOR_RED_BITS | COLOR_GREEN_BITS) & m_Color);
}
unsigned char cColor::GetRed() const
{
return (m_Color & COLOR_RED_BITS) >> COLOR_RED_OFFSET;
}
unsigned char cColor::GetGreen() const
{
return (m_Color & COLOR_GREEN_BITS) >> COLOR_GREEN_OFFSET;
}
unsigned char cColor::GetBlue() const
{
return m_Color & COLOR_BLUE_BITS;
}

58
src/Color.h Normal file
View File

@ -0,0 +1,58 @@
// Color.h
// Declares a class to handle item color related code
#pragma once
// tolua_begin
class cColor
{
public:
enum
{
COLOR_MIN = 0,
COLOR_MAX = 255,
COLOR_LIMIT = 256,
COLOR_NONE = 0xFFFFFFFF,
};
cColor() { m_Color = COLOR_NONE;}
cColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue) { SetColor(a_Red, a_Green, a_Blue); }
/// Returns whether the color is a valid color
bool IsValid() const { return m_Color != COLOR_NONE; }
/// Changes the color
void SetColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue);
/// Alters the red value of the color
void SetRed(unsigned char a_Red);
/// Alters the green value of the color
void SetGreen(unsigned char a_Red);
/// Alters the blue value of the color
void SetBlue(unsigned char a_Red);
/// Returns the red value of the color
unsigned char GetRed() const;
/// Returns the green value of the color
unsigned char GetGreen() const;
/// Returns the blue value of the color
unsigned char GetBlue() const;
/// Resets the color
void Clear() { m_Color = COLOR_NONE; }
// tolua_end
unsigned int m_Color;
};

View File

@ -787,6 +787,9 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
// We use Recipe instead of a_Recipe because we want the wildcard ingredients' slot numbers as well, which was just added previously // We use Recipe instead of a_Recipe because we want the wildcard ingredients' slot numbers as well, which was just added previously
HandleFireworks(a_CraftingGrid, Recipe.get(), a_GridStride, a_OffsetX, a_OffsetY); HandleFireworks(a_CraftingGrid, Recipe.get(), a_GridStride, a_OffsetX, a_OffsetY);
// Handle Dyed Leather
HandleDyedLeather(a_CraftingGrid, Recipe.get(), a_GridStride, a_GridWidth, a_GridHeight);
return Recipe.release(); return Recipe.release();
} }
@ -874,3 +877,192 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe
void cCraftingRecipes::HandleDyedLeather(const cItem * a_CraftingGrid, cCraftingRecipes::cRecipe * a_Recipe, int a_GridStride, int a_GridWidth, int a_GridHeight)
{
short result_type = a_Recipe->m_Result.m_ItemType;
if ((result_type == E_ITEM_LEATHER_CAP) || (result_type == E_ITEM_LEATHER_TUNIC) || (result_type == E_ITEM_LEATHER_PANTS) || (result_type == E_ITEM_LEATHER_BOOTS))
{
bool found = false;
cItem temp;
float red = 0;
float green = 0;
float blue = 0;
float dye_count = 0;
for (int x = 0; x < a_GridWidth; ++x)
{
for (int y = 0; y < a_GridHeight; ++y)
{
int GridIdx = x + a_GridStride * y;
if ((a_CraftingGrid[GridIdx].m_ItemType == result_type) && (found == false))
{
found = true;
temp = a_CraftingGrid[GridIdx].CopyOne();
// The original color of the item affects the result
if (temp.m_ItemColor.IsValid())
{
red += temp.m_ItemColor.GetRed();
green += temp.m_ItemColor.GetGreen();
blue += temp.m_ItemColor.GetBlue();
++dye_count;
}
}
else if (a_CraftingGrid[GridIdx].m_ItemType == E_ITEM_DYE)
{
switch (a_CraftingGrid[GridIdx].m_ItemDamage)
{
case E_META_DYE_BLACK:
{
red += 23;
green += 23;
blue += 23;
break;
}
case E_META_DYE_RED:
{
red += 142;
green += 47;
blue += 47;
break;
}
case E_META_DYE_GREEN:
{
red += 95;
green += 118;
blue += 47;
break;
}
case E_META_DYE_BROWN:
{
red += 95;
green += 71;
blue += 47;
break;
}
case E_META_DYE_BLUE:
{
red += 47;
green += 71;
blue += 165;
break;
}
case E_META_DYE_PURPLE:
{
red += 118;
green += 59;
blue += 165;
break;
}
case E_META_DYE_CYAN:
{
red += 71;
green += 118;
blue += 142;
break;
}
case E_META_DYE_LIGHTGRAY:
{
red += 142;
green += 142;
blue += 142;
break;
}
case E_META_DYE_GRAY:
{
red += 71;
green += 71;
blue += 71;
break;
}
case E_META_DYE_PINK:
{
red += 225;
green += 118;
blue += 153;
break;
}
case E_META_DYE_LIGHTGREEN:
{
red += 118;
green += 190;
blue += 23;
break;
}
case E_META_DYE_YELLOW:
{
red += 213;
green += 213;
blue += 47;
break;
}
case E_META_DYE_LIGHTBLUE:
{
red += 95;
green += 142;
blue += 201;
break;
}
case E_META_DYE_MAGENTA:
{
red += 165;
green += 71;
blue += 201;
break;
}
case E_META_DYE_ORANGE:
{
red += 201;
green += 118;
blue += 47;
break;
}
case E_META_DYE_WHITE:
{
red += 237;
green += 237;
blue += 237;
break;
}
}
++dye_count;
}
else if (a_CraftingGrid[GridIdx].m_ItemType != E_ITEM_EMPTY)
{
return;
}
}
}
if (!found)
{
return;
}
// Calculate the rgb values
double maximum = static_cast<double>(std::max({red, green, blue}));
double average_red = red / dye_count;
double average_green = green / dye_count;
double average_blue = blue / dye_count;
double average_max = maximum / dye_count;
double max_average = std::max({average_red, average_green, average_blue});
double gain_factor = average_max / max_average;
unsigned char result_red = static_cast<unsigned char>(average_red * gain_factor);
unsigned char result_green = static_cast<unsigned char>(average_green * gain_factor);
unsigned char result_blue = static_cast<unsigned char>(average_blue * gain_factor);
// Set the results values
a_Recipe->m_Result = temp;
a_Recipe->m_Result.m_ItemColor.SetColor(result_red, result_green, result_blue);
}
}

View File

@ -168,6 +168,9 @@ protected:
/** Searches for anything firework related, and does the data setting if appropriate */ /** Searches for anything firework related, and does the data setting if appropriate */
void HandleFireworks(const cItem * a_CraftingGrid, cCraftingRecipes::cRecipe * a_Recipe, int a_GridStride, int a_OffsetX, int a_OffsetY); void HandleFireworks(const cItem * a_CraftingGrid, cCraftingRecipes::cRecipe * a_Recipe, int a_GridStride, int a_OffsetX, int a_OffsetY);
/// Searches for anything dye related for leather, calculates the appropriate color value, and sets the resulting value.
void HandleDyedLeather(const cItem * a_CraftingGrid, cCraftingRecipes::cRecipe * a_Recipe, int a_GridStride, int a_GridWidth, int a_GridHeight);
} ; } ;

View File

@ -142,6 +142,13 @@ void cItem::GetJson(Json::Value & a_OutValue) const
a_OutValue["Lore"] = m_Lore; a_OutValue["Lore"] = m_Lore;
} }
if (m_ItemColor.IsValid())
{
a_OutValue["Color_Red"] = m_ItemColor.GetRed();
a_OutValue["Color_Green"] = m_ItemColor.GetGreen();
a_OutValue["Color_Blue"] = m_ItemColor.GetBlue();
}
if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR)) if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
{ {
a_OutValue["Flicker"] = m_FireworkItem.m_HasFlicker; a_OutValue["Flicker"] = m_FireworkItem.m_HasFlicker;
@ -172,6 +179,18 @@ void cItem::FromJson(const Json::Value & a_Value)
m_CustomName = a_Value.get("Name", "").asString(); m_CustomName = a_Value.get("Name", "").asString();
m_Lore = a_Value.get("Lore", "").asString(); m_Lore = a_Value.get("Lore", "").asString();
int red = a_Value.get("Color_Red", -1).asInt();
int green = a_Value.get("Color_Green", -1).asInt();
int blue = a_Value.get("Color_Blue", -1).asInt();
if ((red > -1) && (red < static_cast<int>(cColor::COLOR_LIMIT)) && (green > -1) && (green < static_cast<int>(cColor::COLOR_LIMIT)) && (blue > -1) && (blue < static_cast<int>(cColor::COLOR_LIMIT)))
{
m_ItemColor.SetColor(static_cast<unsigned char>(red), static_cast<unsigned char>(green), static_cast<unsigned char>(blue));
}
else if ((red != -1) || (blue != -1) || (green != -1))
{
LOGWARNING("Item with invalid red, green, and blue values read in from json file.");
}
if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR)) if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
{ {
m_FireworkItem.m_HasFlicker = a_Value.get("Flicker", false).asBool(); m_FireworkItem.m_HasFlicker = a_Value.get("Flicker", false).asBool();

View File

@ -12,6 +12,7 @@
#include "Defines.h" #include "Defines.h"
#include "Enchantments.h" #include "Enchantments.h"
#include "WorldStorage/FireworksSerializer.h" #include "WorldStorage/FireworksSerializer.h"
#include "Color.h"
@ -19,6 +20,7 @@
// fwd: // fwd:
class cItemHandler; class cItemHandler;
class cColor;
namespace Json namespace Json
{ {
@ -41,7 +43,8 @@ public:
m_CustomName(""), m_CustomName(""),
m_Lore(""), m_Lore(""),
m_RepairCost(0), m_RepairCost(0),
m_FireworkItem() m_FireworkItem(),
m_ItemColor()
{ {
} }
@ -62,7 +65,8 @@ public:
m_CustomName (a_CustomName), m_CustomName (a_CustomName),
m_Lore (a_Lore), m_Lore (a_Lore),
m_RepairCost (0), m_RepairCost (0),
m_FireworkItem() m_FireworkItem(),
m_ItemColor()
{ {
if (!IsValidItem(m_ItemType)) if (!IsValidItem(m_ItemType))
{ {
@ -105,6 +109,7 @@ public:
m_Lore = ""; m_Lore = "";
m_RepairCost = 0; m_RepairCost = 0;
m_FireworkItem.EmptyData(); m_FireworkItem.EmptyData();
m_ItemColor.Clear();
} }
@ -114,6 +119,7 @@ public:
m_ItemCount = 0; m_ItemCount = 0;
m_ItemDamage = 0; m_ItemDamage = 0;
m_RepairCost = 0; m_RepairCost = 0;
m_ItemColor.Clear();
} }
@ -206,6 +212,7 @@ public:
int m_RepairCost; int m_RepairCost;
cFireworkItem m_FireworkItem; cFireworkItem m_FireworkItem;
cColor m_ItemColor;
}; };
// tolua_end // tolua_end

View File

@ -2637,6 +2637,10 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
a_Item.m_Lore = Lore; 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")) 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.WriteBEInt8(a_Item.m_ItemCount);
a_Pkt.WriteBEInt16(a_Item.m_ItemDamage); 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); a_Pkt.WriteBEInt16(-1);
return; 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"; const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName); EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName);
} }
if (!a_Item.IsBothNameAndLoreEmpty()) if (!a_Item.IsBothNameAndLoreEmpty() || a_Item.m_ItemColor.IsValid())
{ {
Writer.BeginCompound("display"); 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()) if (!a_Item.IsCustomNameEmpty())
{ {
Writer.AddString("Name", a_Item.m_CustomName.c_str()); Writer.AddString("Name", a_Item.m_CustomName.c_str());

View File

@ -2869,6 +2869,10 @@ void cProtocol180::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
a_Item.m_Lore = Lore; 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")) 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.WriteBEInt8(a_Item.m_ItemCount);
a_Pkt.WriteBEInt16(a_Item.m_ItemDamage); 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); a_Pkt.WriteBEInt8(0);
return; return;
} }
// Send the enchantments and custom names: // Send the enchantments and custom names:
cFastNBTWriter Writer; cFastNBTWriter Writer;
if (a_Item.m_RepairCost != 0) 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"; const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName); EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName);
} }
if (!a_Item.IsBothNameAndLoreEmpty()) if (!a_Item.IsBothNameAndLoreEmpty() || a_Item.m_ItemColor.IsValid())
{ {
Writer.BeginCompound("display"); 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()) if (!a_Item.IsCustomNameEmpty())
{ {
Writer.AddString("Name", a_Item.m_CustomName.c_str()); Writer.AddString("Name", a_Item.m_CustomName.c_str());