4 #include "../WorldStorage/FastNBT.h"
5 #include "../BlockType.h"
54 default:
ASSERT(!
"Unhandled firework item!");
break;
80 if (ExplosionName ==
"Flicker")
84 else if (ExplosionName ==
"Trail")
88 else if (ExplosionName ==
"Type")
97 if (ExplosionName ==
"Colors")
102 DataLength -= DataLength % 4;
108 const auto * ColourData = (a_NBT.
GetData(explosiontag));
109 for (
size_t i = 0; i < DataLength; i += 4)
114 else if (ExplosionName ==
"FadeColors")
118 DataLength -= DataLength % 4;
124 const auto * FadeColourData = (a_NBT.
GetData(explosiontag));
125 for (
size_t i = 0; i < DataLength; i += 4)
141 if (a_NBT.
GetName(fireworkstag) ==
"Flight")
146 else if ((TagType ==
TAG_List) && (a_NBT.
GetName(fireworkstag) ==
"Explosions"))
157 default:
ASSERT(!
"Unhandled firework item!");
break;
168 for (
const auto col: a_FireworkItem.
m_Colours)
170 Result.append(fmt::format(FMT_STRING(
"{};"), col));
183 for (
size_t itr = 0; itr < Split.size(); ++itr)
185 if (Split[itr].empty())
190 a_FireworkItem.
m_Colours.push_back(atoi(Split[itr].c_str()));
203 Result.append(fmt::format(FMT_STRING(
"{};"), col));
216 for (
size_t itr = 0; itr < Split.size(); ++itr)
218 if (Split[itr].empty())
223 a_FireworkItem.
m_FadeColours.push_back(atoi(Split[itr].c_str()));
257 default:
ASSERT(!
"Unhandled dye meta whilst trying to get colour code for fireworks!");
return 0;
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
int GetBEInt(const std::byte *const a_Mem)
Reads four bytes from the specified memory location and interprets them as BigEndian int.
AStringVector StringSplit(const AString &str, const AString &delim)
Split the string at any of the listed delimiters.
std::vector< AString > AStringVector
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
int GetNextSibling(int a_Tag) const
Returns the next sibling of the specified tag, or -1 if none.
const std::byte * GetData(int a_Tag) const
Returns the data stored in this tag.
int GetFirstChild(int a_Tag) const
Returns the first child of the specified tag, or -1 if none / not applicable.
AString GetName(int a_Tag) const
Returns the tag's name.
eTagType GetType(int a_Tag) const
unsigned char GetByte(int a_Tag) const
Returns the value stored in a Byte tag.
size_t GetDataLength(int a_Tag) const
Returns the length of the tag's data, in bytes.
void AddByte(const AString &a_Name, unsigned char a_Value)
void BeginList(const AString &a_Name, eTagType a_ChildrenType)
void AddIntArray(const AString &a_Name, const Int32 *a_Value, size_t a_NumElements)
void BeginCompound(const AString &a_Name)
short m_FlightTimeInTicks
std::vector< int > m_FadeColours
static AString FadeColoursToString(const cFireworkItem &a_FireworkItem)
Converts the firework's vector of fade colours into a string of values separated by a semicolon.
static void FadeColoursFromString(const AString &a_String, cFireworkItem &a_FireworkItem)
Parses a string containing encoded firework fade colours and populates a FireworkItem with it.
std::vector< int > m_Colours
static void WriteToNBTCompound(const cFireworkItem &a_FireworkItem, cFastNBTWriter &a_Writer, const ENUM_ITEM_TYPE a_Type)
Writes firework NBT data to a Writer object.
static AString ColoursToString(const cFireworkItem &a_FireworkItem)
Converts the firework's vector of colours into a string of values separated by a semicolon.
static void ParseFromNBT(cFireworkItem &a_FireworkItem, const cParsedNBT &a_NBT, int a_TagIdx, const ENUM_ITEM_TYPE a_Type)
Reads NBT data from a NBT object and populates a FireworkItem with it.
static int GetVanillaColourCodeFromDye(NIBBLETYPE a_DyeMeta)
Returns a colour code for fireworks used by the network code.
static void ColoursFromString(const AString &a_String, cFireworkItem &a_FireworkItem)
Parses a string containing encoded firework colours and populates a FireworkItem with it.