Cuberite
A lightweight, fast and extensible game server for Minecraft
FireworksSerializer.h
Go to the documentation of this file.
1 
2 // FireworksSerializer.h
3 
4 // Declares the cFireworkItem class representing a firework or firework star
5 
6 
7 
8 
9 
10 #pragma once
11 
12 
13 class cFastNBTWriter;
14 class cParsedNBT;
15 
16 
17 
18 
19 
21 {
22 public:
23  cFireworkItem(void) :
24  m_HasFlicker(false),
25  m_HasTrail(false),
26  m_Type(0),
28  {
29  }
30 
31  inline void CopyFrom(const cFireworkItem & a_Item)
32  {
34  m_HasFlicker = a_Item.m_HasFlicker;
35  m_HasTrail = a_Item.m_HasTrail;
36  m_Type = a_Item.m_Type;
37  m_Colours = a_Item.m_Colours;
39  }
40 
41  inline void EmptyData(void)
42  {
44  m_HasFlicker = false;
45  m_Type = 0;
46  m_HasTrail = false;
47  m_Colours.clear();
48  m_FadeColours.clear();
49  }
50 
51  inline bool IsEqualTo(const cFireworkItem & a_Item) const
52  {
53  return
54  (
56  (m_HasFlicker == a_Item.m_HasFlicker) &&
57  (m_HasTrail == a_Item.m_HasTrail) &&
58  (m_Type == a_Item.m_Type) &&
59  (m_Colours == a_Item.m_Colours) &&
60  (m_FadeColours == a_Item.m_FadeColours)
61  );
62  }
63 
65  static void WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_ID a_Type);
66 
68  static void ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_ID a_Type);
69 
71  static AString ColoursToString(const cFireworkItem & a_FireworkItem);
72 
74  static void ColoursFromString(const AString & a_String, cFireworkItem & a_FireworkItem);
75 
77  static AString FadeColoursToString(const cFireworkItem & a_FireworkItem);
78 
80  static void FadeColoursFromString(const AString & a_String, cFireworkItem & a_FireworkItem);
81 
83  static int GetVanillaColourCodeFromDye(NIBBLETYPE a_DyeMeta);
84 
86  bool m_HasTrail;
89  std::vector<int> m_Colours;
90  std::vector<int> m_FadeColours;
91 };
std::vector< int > m_FadeColours
static void WriteToNBTCompound(const cFireworkItem &a_FireworkItem, cFastNBTWriter &a_Writer, const ENUM_ITEM_ID a_Type)
Writes firework NBT data to a Writer object.
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
Definition: FastNBT.h:152
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
static void ColoursFromString(const AString &a_String, cFireworkItem &a_FireworkItem)
Parses a string containing encoded firework colours and populates a FireworkItem with it...
static void ParseFromNBT(cFireworkItem &a_FireworkItem, const cParsedNBT &a_NBT, int a_TagIdx, const ENUM_ITEM_ID a_Type)
Reads NBT data from a NBT object and populates a FireworkItem with it.
bool IsEqualTo(const cFireworkItem &a_Item) const
static void FadeColoursFromString(const AString &a_String, cFireworkItem &a_FireworkItem)
Parses a string containing encoded firework fade colours and populates a FireworkItem with it...
static int GetVanillaColourCodeFromDye(NIBBLETYPE a_DyeMeta)
Returns a colour code for fireworks used by the network code.
void CopyFrom(const cFireworkItem &a_Item)
std::string AString
Definition: StringUtils.h:13
void EmptyData(void)
ENUM_ITEM_ID
Definition: BlockID.h:293
static AString ColoursToString(const cFireworkItem &a_FireworkItem)
Converts the firework&#39;s vector of colours into a string of values separated by a semicolon.
static AString FadeColoursToString(const cFireworkItem &a_FireworkItem)
Converts the firework&#39;s vector of fade colours into a string of values separated by a semicolon...
std::vector< int > m_Colours