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 #include "../BlockType.h"
14 
15 
16 
17 
18 
19 class cFastNBTWriter;
20 class cParsedNBT;
21 
22 
23 
24 
25 
27 {
28 public:
29  cFireworkItem(void) :
30  m_HasFlicker(false),
31  m_HasTrail(false),
32  m_Type(0),
34  {
35  }
36 
37  inline void CopyFrom(const cFireworkItem & a_Item)
38  {
40  m_HasFlicker = a_Item.m_HasFlicker;
41  m_HasTrail = a_Item.m_HasTrail;
42  m_Type = a_Item.m_Type;
43  m_Colours = a_Item.m_Colours;
45  }
46 
47  inline void EmptyData(void)
48  {
50  m_HasFlicker = false;
51  m_Type = 0;
52  m_HasTrail = false;
53  m_Colours.clear();
54  m_FadeColours.clear();
55  }
56 
57  inline bool IsEqualTo(const cFireworkItem & a_Item) const
58  {
59  return
60  (
62  (m_HasFlicker == a_Item.m_HasFlicker) &&
63  (m_HasTrail == a_Item.m_HasTrail) &&
64  (m_Type == a_Item.m_Type) &&
65  (m_Colours == a_Item.m_Colours) &&
66  (m_FadeColours == a_Item.m_FadeColours)
67  );
68  }
69 
71  static void WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_TYPE a_Type);
72 
74  static void ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_TYPE a_Type);
75 
77  static AString ColoursToString(const cFireworkItem & a_FireworkItem);
78 
80  static void ColoursFromString(const AString & a_String, cFireworkItem & a_FireworkItem);
81 
83  static AString FadeColoursToString(const cFireworkItem & a_FireworkItem);
84 
86  static void FadeColoursFromString(const AString & a_String, cFireworkItem & a_FireworkItem);
87 
89  static int GetVanillaColourCodeFromDye(NIBBLETYPE a_DyeMeta);
90 
92  bool m_HasTrail;
95  std::vector<int> m_Colours;
96  std::vector<int> m_FadeColours;
97 };
ENUM_ITEM_TYPE
Definition: BlockType.h:295
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
std::string AString
Definition: StringUtils.h:11
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
Definition: FastNBT.h:153
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.
void CopyFrom(const cFireworkItem &a_Item)
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.
bool IsEqualTo(const cFireworkItem &a_Item) const
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.
void EmptyData(void)