summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2024-11-02 22:27:47 +0100
committerAlexander Harkness <me@bearbin.net>2024-11-02 22:27:47 +0100
commitcb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a (patch)
treef647b20e1823f1846af88e832cf82a4a02e96e69 /src/WorldStorage
parentImprove clang-format config file, remove automatically enforced code style from contrib guide. (diff)
downloadcuberite-clang-format-codebase.tar
cuberite-clang-format-codebase.tar.gz
cuberite-clang-format-codebase.tar.bz2
cuberite-clang-format-codebase.tar.lz
cuberite-clang-format-codebase.tar.xz
cuberite-clang-format-codebase.tar.zst
cuberite-clang-format-codebase.zip
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/EnchantmentSerializer.cpp30
-rw-r--r--src/WorldStorage/EnchantmentSerializer.h15
-rw-r--r--src/WorldStorage/FastNBT.cpp95
-rw-r--r--src/WorldStorage/FastNBT.h120
-rw-r--r--src/WorldStorage/FireworksSerializer.cpp67
-rw-r--r--src/WorldStorage/FireworksSerializer.h32
-rw-r--r--src/WorldStorage/MapSerializer.cpp17
-rw-r--r--src/WorldStorage/MapSerializer.h21
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp1073
-rw-r--r--src/WorldStorage/NBTChunkSerializer.h3
-rw-r--r--src/WorldStorage/NamespaceSerializer.cpp692
-rw-r--r--src/WorldStorage/NamespaceSerializer.h34
-rw-r--r--src/WorldStorage/SchematicFileSerializer.cpp66
-rw-r--r--src/WorldStorage/SchematicFileSerializer.h9
-rw-r--r--src/WorldStorage/ScoreboardSerializer.cpp26
-rw-r--r--src/WorldStorage/ScoreboardSerializer.h14
-rw-r--r--src/WorldStorage/StatisticsSerializer.cpp6
-rw-r--r--src/WorldStorage/StatisticsSerializer.h15
-rw-r--r--src/WorldStorage/WSSAnvil.cpp766
-rw-r--r--src/WorldStorage/WSSAnvil.h441
-rw-r--r--src/WorldStorage/WorldStorage.cpp44
-rw-r--r--src/WorldStorage/WorldStorage.h29
22 files changed, 2019 insertions, 1596 deletions
diff --git a/src/WorldStorage/EnchantmentSerializer.cpp b/src/WorldStorage/EnchantmentSerializer.cpp
index 08db91115..d1f21f9be 100644
--- a/src/WorldStorage/EnchantmentSerializer.cpp
+++ b/src/WorldStorage/EnchantmentSerializer.cpp
@@ -5,17 +5,24 @@
#include "FastNBT.h"
#include "../Enchantments.h"
-void EnchantmentSerializer::WriteToNBTCompound(const cEnchantments & a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName)
+void EnchantmentSerializer::WriteToNBTCompound(
+ const cEnchantments & a_Enchantments,
+ cFastNBTWriter & a_Writer,
+ const AString & a_ListTagName
+)
{
// Write the enchantments into the specified NBT writer
// begin with the LIST tag of the specified name ("ench" or "StoredEnchantments")
a_Writer.BeginList(a_ListTagName, TAG_Compound);
- for (cEnchantments::cMap::const_iterator itr = a_Enchantments.m_Enchantments.begin(), end = a_Enchantments.m_Enchantments.end(); itr != end; ++itr)
+ for (cEnchantments::cMap::const_iterator itr = a_Enchantments.m_Enchantments.begin(),
+ end = a_Enchantments.m_Enchantments.end();
+ itr != end;
+ ++itr)
{
a_Writer.BeginCompound("");
- a_Writer.AddShort("id", static_cast<Int16>(itr->first));
- a_Writer.AddShort("lvl", static_cast<Int16>(itr->second));
+ a_Writer.AddShort("id", static_cast<Int16>(itr->first));
+ a_Writer.AddShort("lvl", static_cast<Int16>(itr->second));
a_Writer.EndCompound();
} // for itr - m_Enchantments[]
a_Writer.EndList();
@@ -32,8 +39,11 @@ void EnchantmentSerializer::ParseFromNBT(cEnchantments & a_Enchantments, const c
// Verify that the tag is a list:
if (a_NBT.GetType(a_EnchListTagIdx) != TAG_List)
{
- LOGWARNING("%s: Invalid EnchListTag type: exp %d, got %d. Enchantments not parsed",
- __FUNCTION__, TAG_List, a_NBT.GetType(a_EnchListTagIdx)
+ LOGWARNING(
+ "%s: Invalid EnchListTag type: exp %d, got %d. Enchantments not parsed",
+ __FUNCTION__,
+ TAG_List,
+ a_NBT.GetType(a_EnchListTagIdx)
);
ASSERT(!"Bad EnchListTag type");
return;
@@ -42,8 +52,11 @@ void EnchantmentSerializer::ParseFromNBT(cEnchantments & a_Enchantments, const c
// Verify that the list is of Compounds:
if (a_NBT.GetChildrenType(a_EnchListTagIdx) != TAG_Compound)
{
- LOGWARNING("%s: Invalid NBT list children type: exp %d, got %d. Enchantments not parsed",
- __FUNCTION__, TAG_Compound, a_NBT.GetChildrenType(a_EnchListTagIdx)
+ LOGWARNING(
+ "%s: Invalid NBT list children type: exp %d, got %d. Enchantments not parsed",
+ __FUNCTION__,
+ TAG_Compound,
+ a_NBT.GetChildrenType(a_EnchListTagIdx)
);
ASSERT(!"Bad EnchListTag children type");
return;
@@ -85,4 +98,3 @@ void EnchantmentSerializer::ParseFromNBT(cEnchantments & a_Enchantments, const c
a_Enchantments.m_Enchantments[id] = static_cast<unsigned int>(lvl);
} // for tag - children of the ench list tag
}
-
diff --git a/src/WorldStorage/EnchantmentSerializer.h b/src/WorldStorage/EnchantmentSerializer.h
index 4dc75cb86..87cab8a68 100644
--- a/src/WorldStorage/EnchantmentSerializer.h
+++ b/src/WorldStorage/EnchantmentSerializer.h
@@ -12,14 +12,11 @@ class cParsedNBT;
namespace EnchantmentSerializer
{
- /** Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") */
- void WriteToNBTCompound(const cEnchantments & a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName);
-
- /** Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) */
- void ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx);
-
-};
-
-
+/** Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or
+ * "StoredEnchantments") */
+void WriteToNBTCompound(const cEnchantments & a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName);
+/** Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) */
+void ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx);
+}; // namespace EnchantmentSerializer
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index df93e21e4..e0d70695d 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -13,14 +13,28 @@
// The number of NBT tags that are reserved when an NBT parsing is started.
// You can override this by using a cmdline define
#ifndef NBT_RESERVE_SIZE
- #define NBT_RESERVE_SIZE 200
+#define NBT_RESERVE_SIZE 200
#endif // NBT_RESERVE_SIZE
#ifdef _MSC_VER
- // Dodge a C4127 (conditional expression is constant) for this specific macro usage
- #define PROPAGATE_ERROR(X) do { auto Err = (X); if (Err != eNBTParseError::npSuccess) return Err; } while ((false, false))
+// Dodge a C4127 (conditional expression is constant) for this specific macro usage
+#define PROPAGATE_ERROR(X) \
+ do \
+ { \
+ auto Err = (X); \
+ if (Err != eNBTParseError::npSuccess) \
+ return Err; \
+ } \
+ while ((false, false))
#else
- #define PROPAGATE_ERROR(X) do { auto Err = (X); if (Err != eNBTParseError::npSuccess) return Err; } while (false)
+#define PROPAGATE_ERROR(X) \
+ do \
+ { \
+ auto Err = (X); \
+ if (Err != eNBTParseError::npSuccess) \
+ return Err; \
+ } \
+ while (false)
#endif
@@ -31,16 +45,13 @@
namespace
{
-class cNBTParseErrorCategory final :
- public std::error_category
+class cNBTParseErrorCategory final : public std::error_category
{
cNBTParseErrorCategory() = default;
-public:
+
+ public:
/** Category name */
- virtual const char * name() const noexcept override
- {
- return "NBT parse error";
- }
+ virtual const char * name() const noexcept override { return "NBT parse error"; }
/** Maps a parse error code to an error message */
virtual AString message(int a_Condition) const override;
@@ -117,7 +128,7 @@ AString cNBTParseErrorCategory::message(int a_Condition) const
UNREACHABLE("Unsupported nbt parse error");
}
-} // namespace (anonymous)
+} // namespace
@@ -125,7 +136,7 @@ AString cNBTParseErrorCategory::message(int a_Condition) const
std::error_code make_error_code(eNBTParseError a_Err) noexcept
{
- return { static_cast<int>(a_Err), cNBTParseErrorCategory::Get() };
+ return {static_cast<int>(a_Err), cNBTParseErrorCategory::Get()};
}
@@ -135,21 +146,22 @@ std::error_code make_error_code(eNBTParseError a_Err) noexcept
////////////////////////////////////////////////////////////////////////////////
// cParsedNBT:
-#define NEEDBYTES(N, ERR) \
- do { \
+#define NEEDBYTES(N, ERR) \
+ do \
+ { \
if (m_Data.size() - m_Pos < static_cast<size_t>(N)) \
- { \
- return ERR; \
- } \
- } while (false)
+ { \
+ return ERR; \
+ } \
+ } \
+ while (false)
cParsedNBT::cParsedNBT(const ContiguousByteBufferView a_Data) :
- m_Data(a_Data),
- m_Pos(0)
+ m_Data(a_Data), m_Pos(0)
{
m_Error = Parse();
}
@@ -281,14 +293,14 @@ eNBTParseError cParsedNBT::ReadList(eTagType a_ChildrenType)
-#define CASE_SIMPLE_TAG(TAGTYPE, LEN) \
- case TAG_##TAGTYPE: \
- { \
+#define CASE_SIMPLE_TAG(TAGTYPE, LEN) \
+ case TAG_##TAGTYPE: \
+ { \
NEEDBYTES(LEN, eNBTParseError::npSimpleMissing); \
- Tag.m_DataStart = m_Pos; \
- Tag.m_DataLength = LEN; \
- m_Pos += LEN; \
- return eNBTParseError::npSuccess; \
+ Tag.m_DataStart = m_Pos; \
+ Tag.m_DataLength = LEN; \
+ m_Pos += LEN; \
+ return eNBTParseError::npSuccess; \
}
eNBTParseError cParsedNBT::ReadTag(void)
@@ -296,11 +308,11 @@ eNBTParseError cParsedNBT::ReadTag(void)
cFastNBTTag & Tag = m_Tags.back();
switch (Tag.m_Type)
{
- CASE_SIMPLE_TAG(Byte, 1)
- CASE_SIMPLE_TAG(Short, 2)
- CASE_SIMPLE_TAG(Int, 4)
- CASE_SIMPLE_TAG(Long, 8)
- CASE_SIMPLE_TAG(Float, 4)
+ CASE_SIMPLE_TAG(Byte, 1)
+ CASE_SIMPLE_TAG(Short, 2)
+ CASE_SIMPLE_TAG(Int, 4)
+ CASE_SIMPLE_TAG(Long, 8)
+ CASE_SIMPLE_TAG(Float, 4)
CASE_SIMPLE_TAG(Double, 8)
case TAG_String:
@@ -387,12 +399,11 @@ int cParsedNBT::FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLen
{
a_NameLength = strlen(a_Name);
}
- for (int Child = m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild; Child != -1; Child = m_Tags[static_cast<size_t>(Child)].m_NextSibling)
+ for (int Child = m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild; Child != -1;
+ Child = m_Tags[static_cast<size_t>(Child)].m_NextSibling)
{
- if (
- (m_Tags[static_cast<size_t>(Child)].m_NameLength == a_NameLength) &&
- (memcmp(m_Data.data() + m_Tags[static_cast<size_t>(Child)].m_NameStart, a_Name, a_NameLength) == 0)
- )
+ if ((m_Tags[static_cast<size_t>(Child)].m_NameLength == a_NameLength) &&
+ (memcmp(m_Data.data() + m_Tags[static_cast<size_t>(Child)].m_NameStart, a_Name, a_NameLength) == 0))
{
return Child;
}
@@ -523,9 +534,9 @@ void cFastNBTWriter::BeginList(const AString & a_Name, eTagType a_ChildrenType)
m_Result.append(4, std::byte(0));
++m_CurrentStack;
- m_Stack[m_CurrentStack].m_Type = TAG_List;
- m_Stack[m_CurrentStack].m_Pos = static_cast<int>(m_Result.size()) - 4;
- m_Stack[m_CurrentStack].m_Count = 0;
+ m_Stack[m_CurrentStack].m_Type = TAG_List;
+ m_Stack[m_CurrentStack].m_Pos = static_cast<int>(m_Result.size()) - 4;
+ m_Stack[m_CurrentStack].m_Count = 0;
m_Stack[m_CurrentStack].m_ItemType = a_ChildrenType;
}
@@ -618,7 +629,7 @@ void cFastNBTWriter::AddString(const AString & a_Name, const std::string_view a_
TagCommon(a_Name, TAG_String);
const UInt16 Length = htons(static_cast<UInt16>(a_Value.size()));
m_Result.append(reinterpret_cast<const std::byte *>(&Length), sizeof(Length));
- m_Result.append({ reinterpret_cast<const std::byte *>(a_Value.data()), a_Value.size() });
+ m_Result.append({reinterpret_cast<const std::byte *>(a_Value.data()), a_Value.size()});
}
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index d9c388179..6fc8a9aea 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -28,21 +28,21 @@ It directly outputs a string containing the serialized NBT data.
enum eTagType
{
- TAG_Min = 0, // The minimum value for a tag type
- TAG_End = 0,
- TAG_Byte = 1,
- TAG_Short = 2,
- TAG_Int = 3,
- TAG_Long = 4,
- TAG_Float = 5,
- TAG_Double = 6,
+ TAG_Min = 0, // The minimum value for a tag type
+ TAG_End = 0,
+ TAG_Byte = 1,
+ TAG_Short = 2,
+ TAG_Int = 3,
+ TAG_Long = 4,
+ TAG_Float = 5,
+ TAG_Double = 6,
TAG_ByteArray = 7,
- TAG_String = 8,
- TAG_List = 9,
- TAG_Compound = 10,
- TAG_IntArray = 11,
- TAG_Max = 11, // The maximum value for a tag type
-} ;
+ TAG_String = 8,
+ TAG_List = 9,
+ TAG_Compound = 10,
+ TAG_IntArray = 11,
+ TAG_Max = 11, // The maximum value for a tag type
+};
@@ -56,8 +56,7 @@ Structure (all with the tree structure it describes) supports moving in memory (
*/
struct cFastNBTTag
{
-public:
-
+ public:
eTagType m_Type;
// The following members are indices into the data stream. m_DataLength == 0 if no data available
@@ -102,7 +101,7 @@ public:
m_LastChild(-1)
{
}
-} ;
+};
@@ -130,12 +129,10 @@ std::error_code make_error_code(eNBTParseError a_Err) noexcept;
namespace std
{
- template <>
- struct is_error_code_enum<eNBTParseError>:
- public std::true_type
- {
- };
-}
+template <> struct is_error_code_enum<eNBTParseError> : public std::true_type
+{
+};
+} // namespace std
@@ -143,15 +140,15 @@ namespace std
/** Parses and contains the parsed data
Also implements data accessor functions for tree traversal and value getters
-The data pointer passed in the constructor is assumed to be valid throughout the object's life. Care must be taken not to initialize from a temporary.
-The parser decomposes the input data into a tree of tags that is stored as an array of cFastNBTTag items,
-and accessing the tree is done by using the array indices for tags. Each tag stores the indices for its parent,
-first child, last child, prev sibling and next sibling, a value of -1 indicates that the indice is not valid.
-Each primitive tag also stores the length of the contained data, in bytes.
+The data pointer passed in the constructor is assumed to be valid throughout the object's life. Care must be taken not
+to initialize from a temporary. The parser decomposes the input data into a tree of tags that is stored as an array of
+cFastNBTTag items, and accessing the tree is done by using the array indices for tags. Each tag stores the indices for
+its parent, first child, last child, prev sibling and next sibling, a value of -1 indicates that the indice is not
+valid. Each primitive tag also stores the length of the contained data, in bytes.
*/
class cParsedNBT
{
-public:
+ public:
cParsedNBT(ContiguousByteBufferView a_Data);
bool IsValid(void) const { return (m_Error == eNBTParseError::npSuccess); }
@@ -166,10 +163,10 @@ public:
int GetRoot(void) const { return 0; }
/** Returns the first child of the specified tag, or -1 if none / not applicable. */
- int GetFirstChild (int a_Tag) const { return m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild; }
+ int GetFirstChild(int a_Tag) const { return m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild; }
/** Returns the last child of the specified tag, or -1 if none / not applicable. */
- int GetLastChild (int a_Tag) const { return m_Tags[static_cast<size_t>(a_Tag)].m_LastChild; }
+ int GetLastChild(int a_Tag) const { return m_Tags[static_cast<size_t>(a_Tag)].m_LastChild; }
/** Returns the next sibling of the specified tag, or -1 if none. */
int GetNextSibling(int a_Tag) const { return m_Tags[static_cast<size_t>(a_Tag)].m_NextSibling; }
@@ -213,7 +210,9 @@ public:
eTagType GetChildrenType(int a_Tag) const
{
ASSERT(m_Tags[static_cast<size_t>(a_Tag)].m_Type == TAG_List);
- return (m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild < 0) ? TAG_End : m_Tags[static_cast<size_t>(m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild)].m_Type;
+ return (m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild < 0)
+ ? TAG_End
+ : m_Tags[static_cast<size_t>(m_Tags[static_cast<size_t>(a_Tag)].m_FirstChild)].m_Type;
}
/** Returns the value stored in a Byte tag. Not valid for any other tag type. */
@@ -277,45 +276,47 @@ public:
}
/** Returns the value stored in a String tag. Not valid for any other tag type. */
- inline AString GetString(int a_Tag) const
- {
- return AString(GetStringView(a_Tag));
- }
+ inline AString GetString(int a_Tag) const { return AString(GetStringView(a_Tag)); }
/** Returns the value stored in a String tag. Not valid for any other tag type. */
inline std::string_view GetStringView(int a_Tag) const
{
ASSERT(m_Tags[static_cast<size_t>(a_Tag)].m_Type == TAG_String);
- return { reinterpret_cast<const char *>(GetData(a_Tag)), GetDataLength(a_Tag) };
+ return {reinterpret_cast<const char *>(GetData(a_Tag)), GetDataLength(a_Tag)};
}
/** Returns the tag's name. For tags that are not named, returns an empty string. */
inline AString GetName(int a_Tag) const
{
AString res;
- res.assign(reinterpret_cast<const char *>(m_Data.data()) + m_Tags[static_cast<size_t>(a_Tag)].m_NameStart, static_cast<size_t>(m_Tags[static_cast<size_t>(a_Tag)].m_NameLength));
+ res.assign(
+ reinterpret_cast<const char *>(m_Data.data()) + m_Tags[static_cast<size_t>(a_Tag)].m_NameStart,
+ static_cast<size_t>(m_Tags[static_cast<size_t>(a_Tag)].m_NameLength)
+ );
return res;
}
-protected:
-
+ protected:
ContiguousByteBufferView m_Data;
std::vector<cFastNBTTag> m_Tags;
- eNBTParseError m_Error; // npSuccess if parsing succeeded
+ eNBTParseError m_Error; // npSuccess if parsing succeeded
// Used while parsing:
size_t m_Pos;
eNBTParseError Parse(void);
- eNBTParseError ReadString(size_t & a_StringStart, size_t & a_StringLen); // Reads a simple string (2 bytes length + data), sets the string descriptors
+ eNBTParseError ReadString(
+ size_t & a_StringStart,
+ size_t & a_StringLen
+ ); // Reads a simple string (2 bytes length + data), sets the string descriptors
eNBTParseError ReadCompound(void); // Reads the latest tag as a compound
eNBTParseError ReadList(eTagType a_ChildrenType); // Reads the latest tag as a list of items of type a_ChildrenType
- eNBTParseError ReadTag(void); // Reads the latest tag, depending on its m_Type setting
+ eNBTParseError ReadTag(void); // Reads the latest tag, depending on its m_Type setting
/** Returns the minimum size, in bytes, of the specified tag type.
Used for sanity-checking. */
static size_t GetMinTagSize(eTagType a_TagType);
-} ;
+};
@@ -323,7 +324,7 @@ protected:
class cFastNBTWriter
{
-public:
+ public:
cFastNBTWriter(const AString & a_RootTagName = "");
void BeginCompound(const AString & a_Name);
@@ -332,16 +333,16 @@ public:
void BeginList(const AString & a_Name, eTagType a_ChildrenType);
void EndList(void);
- void AddByte (const AString & a_Name, unsigned char a_Value);
- void AddShort (const AString & a_Name, Int16 a_Value);
- void AddInt (const AString & a_Name, Int32 a_Value);
- void AddLong (const AString & a_Name, Int64 a_Value);
- void AddFloat (const AString & a_Name, float a_Value);
- void AddDouble (const AString & a_Name, double a_Value);
- void AddString (const AString & a_Name, std::string_view a_Value);
+ void AddByte(const AString & a_Name, unsigned char a_Value);
+ void AddShort(const AString & a_Name, Int16 a_Value);
+ void AddInt(const AString & a_Name, Int32 a_Value);
+ void AddLong(const AString & a_Name, Int64 a_Value);
+ void AddFloat(const AString & a_Name, float a_Value);
+ void AddDouble(const AString & a_Name, double a_Value);
+ void AddString(const AString & a_Name, std::string_view a_Value);
void AddByteArray(const AString & a_Name, const char * a_Value, size_t a_NumElements);
void AddByteArray(const AString & a_Name, size_t a_NumElements, unsigned char a_Value);
- void AddIntArray (const AString & a_Name, const Int32 * a_Value, size_t a_NumElements);
+ void AddIntArray(const AString & a_Name, const Int32 * a_Value, size_t a_NumElements);
void AddByteArray(const AString & a_Name, const AString & a_Value)
{
@@ -352,21 +353,20 @@ public:
void Finish(void);
-protected:
-
+ protected:
struct sParent
{
- int m_Type; // TAG_Compound or TAG_List
- int m_Pos; // for TAG_List, the position of the list count
+ int m_Type; // TAG_Compound or TAG_List
+ int m_Pos; // for TAG_List, the position of the list count
int m_Count; // for TAG_List, the element count
eTagType m_ItemType; // for TAG_List, the element type
- } ;
+ };
static const int MAX_STACK = 50; // Highly doubtful that an NBT would be constructed this many levels deep
// These two fields emulate a stack. A raw array is used due to speed issues - no reallocations are allowed.
sParent m_Stack[MAX_STACK];
- int m_CurrentStack;
+ int m_CurrentStack;
ContiguousByteBuffer m_Result;
@@ -391,4 +391,4 @@ protected:
m_Stack[m_CurrentStack].m_Count++;
}
}
-} ;
+};
diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp
index f0fe7e48e..c3a2e7dce 100644
--- a/src/WorldStorage/FireworksSerializer.cpp
+++ b/src/WorldStorage/FireworksSerializer.cpp
@@ -8,7 +8,11 @@
-void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_TYPE a_Type)
+void cFireworkItem::WriteToNBTCompound(
+ const cFireworkItem & a_FireworkItem,
+ cFastNBTWriter & a_Writer,
+ const ENUM_ITEM_TYPE a_Type
+)
{
switch (a_Type)
{
@@ -27,7 +31,11 @@ void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFa
}
if (!a_FireworkItem.m_FadeColours.empty())
{
- a_Writer.AddIntArray("FadeColors", a_FireworkItem.m_FadeColours.data(), a_FireworkItem.m_FadeColours.size());
+ a_Writer.AddIntArray(
+ "FadeColors",
+ a_FireworkItem.m_FadeColours.data(),
+ a_FireworkItem.m_FadeColours.size()
+ );
}
a_Writer.EndCompound();
a_Writer.EndList();
@@ -46,7 +54,11 @@ void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFa
}
if (!a_FireworkItem.m_FadeColours.empty())
{
- a_Writer.AddIntArray("FadeColors", a_FireworkItem.m_FadeColours.data(), a_FireworkItem.m_FadeColours.size());
+ a_Writer.AddIntArray(
+ "FadeColors",
+ a_FireworkItem.m_FadeColours.data(),
+ a_FireworkItem.m_FadeColours.size()
+ );
}
a_Writer.EndCompound();
break;
@@ -59,7 +71,12 @@ void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFa
-void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_TYPE a_Type)
+void cFireworkItem::ParseFromNBT(
+ cFireworkItem & a_FireworkItem,
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ const ENUM_ITEM_TYPE a_Type
+)
{
if (a_TagIdx < 0)
{
@@ -70,7 +87,8 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
{
case E_ITEM_FIREWORK_STAR:
{
- for (int explosiontag = a_NBT.GetFirstChild(a_TagIdx); explosiontag >= 0; explosiontag = a_NBT.GetNextSibling(explosiontag))
+ for (int explosiontag = a_NBT.GetFirstChild(a_TagIdx); explosiontag >= 0;
+ explosiontag = a_NBT.GetNextSibling(explosiontag))
{
eTagType TagType = a_NBT.GetType(explosiontag);
if (TagType == TAG_Byte) // Custon name tag
@@ -133,7 +151,8 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
}
case E_ITEM_FIREWORK_ROCKET:
{
- for (int fireworkstag = a_NBT.GetFirstChild(a_TagIdx); fireworkstag >= 0; fireworkstag = a_NBT.GetNextSibling(fireworkstag))
+ for (int fireworkstag = a_NBT.GetFirstChild(a_TagIdx); fireworkstag >= 0;
+ fireworkstag = a_NBT.GetNextSibling(fireworkstag))
{
eTagType TagType = a_NBT.GetType(fireworkstag);
if (TagType == TAG_Byte) // Custon name tag
@@ -165,7 +184,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
AString cFireworkItem::ColoursToString(const cFireworkItem & a_FireworkItem)
{
AString Result;
- for (const auto col: a_FireworkItem.m_Colours)
+ for (const auto col : a_FireworkItem.m_Colours)
{
Result.append(fmt::format(FMT_STRING("{};"), col));
}
@@ -198,7 +217,7 @@ void cFireworkItem::ColoursFromString(const AString & a_String, cFireworkItem &
AString cFireworkItem::FadeColoursToString(const cFireworkItem & a_FireworkItem)
{
AString Result;
- for (const auto col: a_FireworkItem.m_FadeColours)
+ for (const auto col : a_FireworkItem.m_FadeColours)
{
Result.append(fmt::format(FMT_STRING("{};"), col));
}
@@ -238,22 +257,22 @@ int cFireworkItem::GetVanillaColourCodeFromDye(NIBBLETYPE a_DyeMeta)
switch (a_DyeMeta)
{
- case E_META_DYE_BLACK: return 0x1E1B1B;
- case E_META_DYE_RED: return 0xB3312C;
- case E_META_DYE_GREEN: return 0x3B511A;
- case E_META_DYE_BROWN: return 0x51301A;
- case E_META_DYE_BLUE: return 0x253192;
- case E_META_DYE_PURPLE: return 0x7B2FBE;
- case E_META_DYE_CYAN: return 0x287697;
- case E_META_DYE_LIGHTGRAY: return 0xABABAB;
- case E_META_DYE_GRAY: return 0x434343;
- case E_META_DYE_PINK: return 0xD88198;
+ case E_META_DYE_BLACK: return 0x1E1B1B;
+ case E_META_DYE_RED: return 0xB3312C;
+ case E_META_DYE_GREEN: return 0x3B511A;
+ case E_META_DYE_BROWN: return 0x51301A;
+ case E_META_DYE_BLUE: return 0x253192;
+ case E_META_DYE_PURPLE: return 0x7B2FBE;
+ case E_META_DYE_CYAN: return 0x287697;
+ case E_META_DYE_LIGHTGRAY: return 0xABABAB;
+ case E_META_DYE_GRAY: return 0x434343;
+ case E_META_DYE_PINK: return 0xD88198;
case E_META_DYE_LIGHTGREEN: return 0x41CD34;
- case E_META_DYE_YELLOW: return 0xDECF2A;
- case E_META_DYE_LIGHTBLUE: return 0x6689D3;
- case E_META_DYE_MAGENTA: return 0xC354CD;
- case E_META_DYE_ORANGE: return 0xEB8844;
- case E_META_DYE_WHITE: return 0xF0F0F0;
- default: ASSERT(!"Unhandled dye meta whilst trying to get colour code for fireworks!"); return 0;
+ case E_META_DYE_YELLOW: return 0xDECF2A;
+ case E_META_DYE_LIGHTBLUE: return 0x6689D3;
+ case E_META_DYE_MAGENTA: return 0xC354CD;
+ case E_META_DYE_ORANGE: return 0xEB8844;
+ case E_META_DYE_WHITE: return 0xF0F0F0;
+ default: ASSERT(!"Unhandled dye meta whilst trying to get colour code for fireworks!"); return 0;
}
}
diff --git a/src/WorldStorage/FireworksSerializer.h b/src/WorldStorage/FireworksSerializer.h
index 32264d2f3..f794959dc 100644
--- a/src/WorldStorage/FireworksSerializer.h
+++ b/src/WorldStorage/FireworksSerializer.h
@@ -25,12 +25,9 @@ class cParsedNBT;
class cFireworkItem
{
-public:
+ public:
cFireworkItem(void) :
- m_HasFlicker(false),
- m_HasTrail(false),
- m_Type(0),
- m_FlightTimeInTicks(0)
+ m_HasFlicker(false), m_HasTrail(false), m_Type(0), m_FlightTimeInTicks(0)
{
}
@@ -56,22 +53,27 @@ public:
inline bool IsEqualTo(const cFireworkItem & a_Item) const
{
- return
- (
- (m_FlightTimeInTicks == a_Item.m_FlightTimeInTicks) &&
- (m_HasFlicker == a_Item.m_HasFlicker) &&
- (m_HasTrail == a_Item.m_HasTrail) &&
- (m_Type == a_Item.m_Type) &&
- (m_Colours == a_Item.m_Colours) &&
+ return (
+ (m_FlightTimeInTicks == a_Item.m_FlightTimeInTicks) && (m_HasFlicker == a_Item.m_HasFlicker) &&
+ (m_HasTrail == a_Item.m_HasTrail) && (m_Type == a_Item.m_Type) && (m_Colours == a_Item.m_Colours) &&
(m_FadeColours == a_Item.m_FadeColours)
- );
+ );
}
/** Writes firework NBT data to a Writer object */
- static void WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_TYPE a_Type);
+ static void WriteToNBTCompound(
+ const cFireworkItem & a_FireworkItem,
+ cFastNBTWriter & a_Writer,
+ const ENUM_ITEM_TYPE a_Type
+ );
/** Reads NBT data from a NBT object and populates a FireworkItem with it */
- static void ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_TYPE a_Type);
+ static void ParseFromNBT(
+ cFireworkItem & a_FireworkItem,
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ const ENUM_ITEM_TYPE a_Type
+ );
/** Converts the firework's vector of colours into a string of values separated by a semicolon */
static AString ColoursToString(const cFireworkItem & a_FireworkItem);
diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp
index 3e50740b3..8761495a9 100644
--- a/src/WorldStorage/MapSerializer.cpp
+++ b/src/WorldStorage/MapSerializer.cpp
@@ -14,7 +14,7 @@
-cMapSerializer::cMapSerializer(const AString & a_WorldName, cMap * a_Map):
+cMapSerializer::cMapSerializer(const AString & a_WorldName, cMap * a_Map) :
m_Map(a_Map)
{
auto DataPath = fmt::format(FMT_STRING("{}{}data"), a_WorldName, cFile::PathSeparator());
@@ -50,10 +50,10 @@ bool cMapSerializer::Save(void)
SaveMapToNBT(Writer);
Writer.Finish();
- #ifndef NDEBUG
+#ifndef NDEBUG
cParsedNBT TestParse(Writer.GetResult());
ASSERT(TestParse.IsValid());
- #endif // !NDEBUG
+#endif // !NDEBUG
GZipFile::Write(m_Path, Writer.GetResult());
@@ -71,7 +71,7 @@ void cMapSerializer::SaveMapToNBT(cFastNBTWriter & a_Writer)
a_Writer.AddByte("scale", static_cast<Byte>(m_Map->GetScale()));
a_Writer.AddByte("dimension", static_cast<Byte>(m_Map->GetDimension()));
- a_Writer.AddShort("width", static_cast<Int16>(m_Map->GetWidth()));
+ a_Writer.AddShort("width", static_cast<Int16>(m_Map->GetWidth()));
a_Writer.AddShort("height", static_cast<Int16>(m_Map->GetHeight()));
a_Writer.AddInt("xCenter", m_Map->GetCenterX());
@@ -166,7 +166,8 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
-cIDCountSerializer::cIDCountSerializer(const AString & a_WorldName) : m_MapCount(0)
+cIDCountSerializer::cIDCountSerializer(const AString & a_WorldName) :
+ m_MapCount(0)
{
auto DataPath = fmt::format(FMT_STRING("{}{}data"), a_WorldName, cFile::PathSeparator());
m_Path = fmt::format(FMT_STRING("{}{}idcounts.dat"), DataPath, cFile::PathSeparator());
@@ -188,7 +189,7 @@ bool cIDCountSerializer::Load()
// NOTE: idcounts.dat is not compressed (raw format)
// Parse the NBT data:
- cParsedNBT NBT({ reinterpret_cast<const std::byte *>(Data.data()), Data.size() });
+ cParsedNBT NBT({reinterpret_cast<const std::byte *>(Data.data()), Data.size()});
if (!NBT.IsValid())
{
// NBT Parsing failed
@@ -223,10 +224,10 @@ bool cIDCountSerializer::Save(void)
Writer.Finish();
- #ifndef NDEBUG
+#ifndef NDEBUG
cParsedNBT TestParse(Writer.GetResult());
ASSERT(TestParse.IsValid());
- #endif // !NDEBUG
+#endif // !NDEBUG
cFile File;
if (!File.Open(m_Path, cFile::fmWrite))
diff --git a/src/WorldStorage/MapSerializer.h b/src/WorldStorage/MapSerializer.h
index 007f1347b..fcb187425 100644
--- a/src/WorldStorage/MapSerializer.h
+++ b/src/WorldStorage/MapSerializer.h
@@ -24,8 +24,7 @@ class cMap;
/** Utility class used to serialize maps. */
class cMapSerializer
{
-public:
-
+ public:
cMapSerializer(const AString & a_WorldName, cMap * a_Map);
/** Try to load the map */
@@ -35,8 +34,7 @@ public:
bool Save(void);
-private:
-
+ private:
void SaveMapToNBT(cFastNBTWriter & a_Writer);
bool LoadMapFromNBT(const cParsedNBT & a_NBT);
@@ -44,9 +42,7 @@ private:
cMap * m_Map;
AString m_Path;
-
-
-} ;
+};
@@ -57,8 +53,7 @@ the last registered ID of each item is serialized to an NBT file.
*/
class cIDCountSerializer
{
-public:
-
+ public:
cIDCountSerializer(const AString & a_WorldName);
/** Try to load the ID counts */
@@ -72,14 +67,8 @@ public:
inline void SetMapCount(unsigned int a_MapCount) { m_MapCount = a_MapCount; }
-private:
-
+ private:
AString m_Path;
unsigned int m_MapCount;
-
};
-
-
-
-
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index c61e6d185..a274b28d9 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -54,11 +54,9 @@
/** Collects and stores the chunk data via the cChunkDataCallback interface */
-class SerializerCollector final :
- public cChunkDataCopyCollector
+class SerializerCollector final : public cChunkDataCopyCollector
{
-public:
-
+ public:
// The data collected from the chunk:
UInt8 Biomes[cChunkDef::Width * cChunkDef::Width];
int Heights[cChunkDef::Width * cChunkDef::Width];
@@ -82,12 +80,8 @@ public:
- SerializerCollector(cFastNBTWriter & aWriter):
- mIsTagOpen(false),
- mHasHadEntity(false),
- mHasHadBlockEntity(false),
- mIsLightValid(false),
- mWriter(aWriter)
+ SerializerCollector(cFastNBTWriter & aWriter) :
+ mIsTagOpen(false), mHasHadEntity(false), mHasHadBlockEntity(false), mIsLightValid(false), mWriter(aWriter)
{
}
@@ -95,10 +89,7 @@ public:
- virtual void LightIsValid(bool a_IsLightValid) override
- {
- mIsLightValid = a_IsLightValid;
- }
+ virtual void LightIsValid(bool a_IsLightValid) override { mIsLightValid = a_IsLightValid; }
@@ -161,20 +152,20 @@ public:
switch (a_Entity->GetEntityType())
{
- case cEntity::etBoat: AddBoatEntity (static_cast<cBoat *> (a_Entity)); break;
- case cEntity::etEnderCrystal: AddEnderCrystalEntity(static_cast<cEnderCrystal *> (a_Entity)); break;
- case cEntity::etFallingBlock: AddFallingBlockEntity(static_cast<cFallingBlock *> (a_Entity)); break;
- case cEntity::etMinecart: AddMinecartEntity (static_cast<cMinecart *> (a_Entity)); break;
- case cEntity::etMonster: AddMonsterEntity (static_cast<cMonster *> (a_Entity)); break;
- case cEntity::etPickup: AddPickupEntity (static_cast<cPickup *> (a_Entity)); break;
- case cEntity::etProjectile: AddProjectileEntity (static_cast<cProjectileEntity *>(a_Entity)); break;
- case cEntity::etTNT: AddTNTEntity (static_cast<cTNTEntity *> (a_Entity)); break;
- case cEntity::etExpOrb: AddExpOrbEntity (static_cast<cExpOrb *> (a_Entity)); break;
- case cEntity::etItemFrame: AddItemFrameEntity (static_cast<cItemFrame *> (a_Entity)); break;
- case cEntity::etLeashKnot: AddLeashKnotEntity (static_cast<cLeashKnot *> (a_Entity)); break;
- case cEntity::etPainting: AddPaintingEntity (static_cast<cPainting *> (a_Entity)); break;
- case cEntity::etPlayer: return; // Players aren't saved into the world
- case cEntity::etFloater: return; // Floaters aren't saved either
+ case cEntity::etBoat: AddBoatEntity(static_cast<cBoat *>(a_Entity)); break;
+ case cEntity::etEnderCrystal: AddEnderCrystalEntity(static_cast<cEnderCrystal *>(a_Entity)); break;
+ case cEntity::etFallingBlock: AddFallingBlockEntity(static_cast<cFallingBlock *>(a_Entity)); break;
+ case cEntity::etMinecart: AddMinecartEntity(static_cast<cMinecart *>(a_Entity)); break;
+ case cEntity::etMonster: AddMonsterEntity(static_cast<cMonster *>(a_Entity)); break;
+ case cEntity::etPickup: AddPickupEntity(static_cast<cPickup *>(a_Entity)); break;
+ case cEntity::etProjectile: AddProjectileEntity(static_cast<cProjectileEntity *>(a_Entity)); break;
+ case cEntity::etTNT: AddTNTEntity(static_cast<cTNTEntity *>(a_Entity)); break;
+ case cEntity::etExpOrb: AddExpOrbEntity(static_cast<cExpOrb *>(a_Entity)); break;
+ case cEntity::etItemFrame: AddItemFrameEntity(static_cast<cItemFrame *>(a_Entity)); break;
+ case cEntity::etLeashKnot: AddLeashKnotEntity(static_cast<cLeashKnot *>(a_Entity)); break;
+ case cEntity::etPainting: AddPaintingEntity(static_cast<cPainting *>(a_Entity)); break;
+ case cEntity::etPlayer: return; // Players aren't saved into the world
+ case cEntity::etFloater: return; // Floaters aren't saved either
default:
{
ASSERT(!"Unhandled entity type is being saved");
@@ -208,30 +199,34 @@ public:
{
// Banners:
case E_BLOCK_STANDING_BANNER:
- case E_BLOCK_WALL_BANNER: AddBannerEntity (static_cast<cBannerEntity *> (a_Entity)); break;
+ case E_BLOCK_WALL_BANNER: AddBannerEntity(static_cast<cBannerEntity *>(a_Entity)); break;
// Others:
- case E_BLOCK_BEACON: AddBeaconEntity (static_cast<cBeaconEntity *> (a_Entity)); break;
- case E_BLOCK_BED: AddBedEntity (static_cast<cBedEntity *> (a_Entity)); break;
- case E_BLOCK_BREWING_STAND: AddBrewingstandEntity (static_cast<cBrewingstandEntity *> (a_Entity)); break;
- case E_BLOCK_CHEST: AddChestEntity (static_cast<cChestEntity *> (a_Entity), a_Entity->GetBlockType()); break;
- case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity (static_cast<cCommandBlockEntity *> (a_Entity)); break;
- case E_BLOCK_DISPENSER: AddDispenserEntity (static_cast<cDispenserEntity *> (a_Entity)); break;
- case E_BLOCK_DROPPER: AddDropperEntity (static_cast<cDropperEntity *> (a_Entity)); break;
- case E_BLOCK_ENCHANTMENT_TABLE: AddEnchantingTableEntity(static_cast<cEnchantingTableEntity *>(a_Entity)); break;
- case E_BLOCK_ENDER_CHEST: AddEnderchestEntity (static_cast<cEnderChestEntity *> (a_Entity)); break;
- case E_BLOCK_END_PORTAL: AddEndPortalEntity (static_cast<cEndPortalEntity *> (a_Entity)); break;
- case E_BLOCK_FLOWER_POT: AddFlowerPotEntity (static_cast<cFlowerPotEntity *> (a_Entity)); break;
- case E_BLOCK_FURNACE: AddFurnaceEntity (static_cast<cFurnaceEntity *> (a_Entity)); break;
- case E_BLOCK_HEAD: AddMobHeadEntity (static_cast<cMobHeadEntity *> (a_Entity)); break;
- case E_BLOCK_HOPPER: AddHopperEntity (static_cast<cHopperEntity *> (a_Entity)); break;
- case E_BLOCK_JUKEBOX: AddJukeboxEntity (static_cast<cJukeboxEntity *> (a_Entity)); break;
- case E_BLOCK_LIT_FURNACE: AddFurnaceEntity (static_cast<cFurnaceEntity *> (a_Entity)); break;
- case E_BLOCK_MOB_SPAWNER: AddMobSpawnerEntity (static_cast<cMobSpawnerEntity *> (a_Entity)); break;
- case E_BLOCK_NOTE_BLOCK: AddNoteEntity (static_cast<cNoteEntity *> (a_Entity)); break;
- case E_BLOCK_SIGN_POST: AddSignEntity (static_cast<cSignEntity *> (a_Entity)); break;
- case E_BLOCK_TRAPPED_CHEST: AddChestEntity (static_cast<cChestEntity *> (a_Entity), a_Entity->GetBlockType()); break;
- case E_BLOCK_WALLSIGN: AddSignEntity (static_cast<cSignEntity *> (a_Entity)); break;
+ case E_BLOCK_BEACON: AddBeaconEntity(static_cast<cBeaconEntity *>(a_Entity)); break;
+ case E_BLOCK_BED: AddBedEntity(static_cast<cBedEntity *>(a_Entity)); break;
+ case E_BLOCK_BREWING_STAND: AddBrewingstandEntity(static_cast<cBrewingstandEntity *>(a_Entity)); break;
+ case E_BLOCK_CHEST: AddChestEntity(static_cast<cChestEntity *>(a_Entity), a_Entity->GetBlockType()); break;
+ case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity(static_cast<cCommandBlockEntity *>(a_Entity)); break;
+ case E_BLOCK_DISPENSER: AddDispenserEntity(static_cast<cDispenserEntity *>(a_Entity)); break;
+ case E_BLOCK_DROPPER: AddDropperEntity(static_cast<cDropperEntity *>(a_Entity)); break;
+ case E_BLOCK_ENCHANTMENT_TABLE:
+ AddEnchantingTableEntity(static_cast<cEnchantingTableEntity *>(a_Entity));
+ break;
+ case E_BLOCK_ENDER_CHEST: AddEnderchestEntity(static_cast<cEnderChestEntity *>(a_Entity)); break;
+ case E_BLOCK_END_PORTAL: AddEndPortalEntity(static_cast<cEndPortalEntity *>(a_Entity)); break;
+ case E_BLOCK_FLOWER_POT: AddFlowerPotEntity(static_cast<cFlowerPotEntity *>(a_Entity)); break;
+ case E_BLOCK_FURNACE: AddFurnaceEntity(static_cast<cFurnaceEntity *>(a_Entity)); break;
+ case E_BLOCK_HEAD: AddMobHeadEntity(static_cast<cMobHeadEntity *>(a_Entity)); break;
+ case E_BLOCK_HOPPER: AddHopperEntity(static_cast<cHopperEntity *>(a_Entity)); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity(static_cast<cJukeboxEntity *>(a_Entity)); break;
+ case E_BLOCK_LIT_FURNACE: AddFurnaceEntity(static_cast<cFurnaceEntity *>(a_Entity)); break;
+ case E_BLOCK_MOB_SPAWNER: AddMobSpawnerEntity(static_cast<cMobSpawnerEntity *>(a_Entity)); break;
+ case E_BLOCK_NOTE_BLOCK: AddNoteEntity(static_cast<cNoteEntity *>(a_Entity)); break;
+ case E_BLOCK_SIGN_POST: AddSignEntity(static_cast<cSignEntity *>(a_Entity)); break;
+ case E_BLOCK_TRAPPED_CHEST:
+ AddChestEntity(static_cast<cChestEntity *>(a_Entity), a_Entity->GetBlockType());
+ break;
+ case E_BLOCK_WALLSIGN: AddSignEntity(static_cast<cSignEntity *>(a_Entity)); break;
default:
{
ASSERT(!"Unhandled block entity saved into Anvil");
@@ -274,60 +269,60 @@ public:
void AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName = AString())
{
mWriter.BeginCompound(a_CompoundName);
- mWriter.AddShort("id", static_cast<Int16>(a_Item.m_ItemType));
- mWriter.AddShort("Damage", static_cast<Int16>((a_Item.m_ItemDamage)));
- mWriter.AddByte ("Count", static_cast<Byte>(a_Item.m_ItemCount));
+ mWriter.AddShort("id", static_cast<Int16>(a_Item.m_ItemType));
+ mWriter.AddShort("Damage", static_cast<Int16>((a_Item.m_ItemDamage)));
+ mWriter.AddByte("Count", static_cast<Byte>(a_Item.m_ItemCount));
if (a_Slot >= 0)
{
- mWriter.AddByte ("Slot", static_cast<unsigned char>(a_Slot));
+ mWriter.AddByte("Slot", static_cast<unsigned char>(a_Slot));
}
// Write the tag compound (for enchantment, firework, custom name and repair cost):
- if (
- (!a_Item.m_Enchantments.IsEmpty()) ||
+ if ((!a_Item.m_Enchantments.IsEmpty()) ||
((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) ||
- (a_Item.m_RepairCost > 0) ||
- (a_Item.m_CustomName != "") ||
- (!a_Item.m_LoreTable.empty())
- )
+ (a_Item.m_RepairCost > 0) || (a_Item.m_CustomName != "") || (!a_Item.m_LoreTable.empty()))
{
mWriter.BeginCompound("tag");
- if (a_Item.m_RepairCost > 0)
+ if (a_Item.m_RepairCost > 0)
+ {
+ mWriter.AddInt("RepairCost", a_Item.m_RepairCost);
+ }
+
+ if ((a_Item.m_CustomName != "") || (!a_Item.m_LoreTable.empty()))
+ {
+ mWriter.BeginCompound("display");
+ if (a_Item.m_CustomName != "")
{
- mWriter.AddInt("RepairCost", a_Item.m_RepairCost);
+ mWriter.AddString("Name", a_Item.m_CustomName);
}
-
- if ((a_Item.m_CustomName != "") || (!a_Item.m_LoreTable.empty()))
+ if (!a_Item.m_LoreTable.empty())
{
- mWriter.BeginCompound("display");
- if (a_Item.m_CustomName != "")
+ mWriter.BeginList("Lore", TAG_String);
+
+ for (const auto & Line : a_Item.m_LoreTable)
{
- mWriter.AddString("Name", a_Item.m_CustomName);
+ mWriter.AddString("", Line);
}
- if (!a_Item.m_LoreTable.empty())
- {
- mWriter.BeginList("Lore", TAG_String);
- for (const auto & Line : a_Item.m_LoreTable)
- {
- mWriter.AddString("", Line);
- }
-
- mWriter.EndList();
- }
- mWriter.EndCompound();
+ mWriter.EndList();
}
+ mWriter.EndCompound();
+ }
- if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR))
- {
- cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, mWriter, static_cast<ENUM_ITEM_TYPE>(a_Item.m_ItemType));
- }
+ if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR))
+ {
+ cFireworkItem::WriteToNBTCompound(
+ a_Item.m_FireworkItem,
+ mWriter,
+ static_cast<ENUM_ITEM_TYPE>(a_Item.m_ItemType)
+ );
+ }
- if (!a_Item.m_Enchantments.IsEmpty())
- {
- const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
- EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, mWriter, TagName);
- }
+ if (!a_Item.m_Enchantments.IsEmpty())
+ {
+ const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
+ EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, mWriter, TagName);
+ }
mWriter.EndCompound();
}
@@ -340,7 +335,8 @@ public:
/** Writes an item grid into the writer.
Begins the stored slot numbers with a_BeginSlotNum.
- Note that it doesn't begin nor end the list tag, so that multiple grids may be concatenated together using this function. */
+ Note that it doesn't begin nor end the list tag, so that multiple grids may be concatenated together using this
+ function. */
void AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotNum = 0)
{
int NumSlots = a_Grid.GetNumSlots();
@@ -361,9 +357,9 @@ public:
void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID)
{
- mWriter.AddInt ("x", a_Entity->GetPosX());
- mWriter.AddInt ("y", a_Entity->GetPosY());
- mWriter.AddInt ("z", a_Entity->GetPosZ());
+ mWriter.AddInt("x", a_Entity->GetPosX());
+ mWriter.AddInt("y", a_Entity->GetPosY());
+ mWriter.AddInt("z", a_Entity->GetPosZ());
mWriter.AddString("id", a_EntityTypeID);
}
@@ -374,12 +370,12 @@ public:
void AddBannerEntity(cBannerEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity,"Banner");
- mWriter.AddInt("Base", static_cast<int>(a_Entity->GetBaseColor()));
- if (!a_Entity->GetCustomName().empty())
- {
- mWriter.AddString("CustomName", a_Entity->GetCustomName());
- }
+ AddBasicTileEntity(a_Entity, "Banner");
+ mWriter.AddInt("Base", static_cast<int>(a_Entity->GetBaseColor()));
+ if (!a_Entity->GetCustomName().empty())
+ {
+ mWriter.AddString("CustomName", a_Entity->GetCustomName());
+ }
mWriter.EndCompound();
}
@@ -390,13 +386,13 @@ public:
void AddBeaconEntity(cBeaconEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Beacon");
- mWriter.AddInt("Levels", a_Entity->GetBeaconLevel());
- mWriter.AddInt("Primary", static_cast<int>(a_Entity->GetPrimaryEffect()));
- mWriter.AddInt("Secondary", static_cast<int>(a_Entity->GetSecondaryEffect()));
- mWriter.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- mWriter.EndList();
+ AddBasicTileEntity(a_Entity, "Beacon");
+ mWriter.AddInt("Levels", a_Entity->GetBeaconLevel());
+ mWriter.AddInt("Primary", static_cast<int>(a_Entity->GetPrimaryEffect()));
+ mWriter.AddInt("Secondary", static_cast<int>(a_Entity->GetSecondaryEffect()));
+ mWriter.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ mWriter.EndList();
mWriter.EndCompound();
}
@@ -419,12 +415,12 @@ public:
void AddBrewingstandEntity(cBrewingstandEntity * a_Brewingstand)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Brewingstand, "Brewingstand");
- mWriter.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Brewingstand->GetContents());
- mWriter.EndList();
- mWriter.AddShort("BrewTime", a_Brewingstand->GetTimeBrewed());
- mWriter.AddShort("Fuel", a_Brewingstand->GetRemainingFuel());
+ AddBasicTileEntity(a_Brewingstand, "Brewingstand");
+ mWriter.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Brewingstand->GetContents());
+ mWriter.EndList();
+ mWriter.AddShort("BrewTime", a_Brewingstand->GetTimeBrewed());
+ mWriter.AddShort("Fuel", a_Brewingstand->GetRemainingFuel());
mWriter.EndCompound();
}
@@ -435,10 +431,10 @@ public:
void AddChestEntity(cChestEntity * a_Entity, BLOCKTYPE a_ChestType)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Chest");
- mWriter.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- mWriter.EndList();
+ AddBasicTileEntity(a_Entity, "Chest");
+ mWriter.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ mWriter.EndList();
mWriter.EndCompound();
}
@@ -449,10 +445,10 @@ public:
void AddDispenserEntity(cDispenserEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Trap");
- mWriter.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- mWriter.EndList();
+ AddBasicTileEntity(a_Entity, "Trap");
+ mWriter.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ mWriter.EndList();
mWriter.EndCompound();
}
@@ -463,10 +459,10 @@ public:
void AddDropperEntity(cDropperEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Dropper");
- mWriter.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- mWriter.EndList();
+ AddBasicTileEntity(a_Entity, "Dropper");
+ mWriter.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ mWriter.EndList();
mWriter.EndCompound();
}
@@ -477,11 +473,11 @@ public:
void AddEnchantingTableEntity(cEnchantingTableEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "EnchantingTable");
- if (!a_Entity->GetCustomName().empty())
- {
- mWriter.AddString("CustomName", a_Entity->GetCustomName());
- }
+ AddBasicTileEntity(a_Entity, "EnchantingTable");
+ if (!a_Entity->GetCustomName().empty())
+ {
+ mWriter.AddString("CustomName", a_Entity->GetCustomName());
+ }
mWriter.EndCompound();
}
@@ -491,7 +487,7 @@ public:
void AddEnderchestEntity(cEnderChestEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "EnderChest");
+ AddBasicTileEntity(a_Entity, "EnderChest");
mWriter.EndCompound();
}
@@ -501,7 +497,7 @@ public:
void AddEndPortalEntity(cEndPortalEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "EndPortal");
+ AddBasicTileEntity(a_Entity, "EndPortal");
mWriter.EndCompound();
}
@@ -512,12 +508,12 @@ public:
void AddFurnaceEntity(cFurnaceEntity * a_Furnace)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Furnace, "Furnace");
- mWriter.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Furnace->GetContents());
- mWriter.EndList();
- mWriter.AddShort("BurnTime", static_cast<Int16>(a_Furnace->GetFuelBurnTimeLeft()));
- mWriter.AddShort("CookTime", static_cast<Int16>(a_Furnace->GetTimeCooked()));
+ AddBasicTileEntity(a_Furnace, "Furnace");
+ mWriter.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Furnace->GetContents());
+ mWriter.EndList();
+ mWriter.AddShort("BurnTime", static_cast<Int16>(a_Furnace->GetFuelBurnTimeLeft()));
+ mWriter.AddShort("CookTime", static_cast<Int16>(a_Furnace->GetTimeCooked()));
mWriter.EndCompound();
}
@@ -528,10 +524,10 @@ public:
void AddHopperEntity(cHopperEntity * a_Entity)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Hopper");
- mWriter.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- mWriter.EndList();
+ AddBasicTileEntity(a_Entity, "Hopper");
+ mWriter.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ mWriter.EndList();
mWriter.EndCompound();
}
@@ -542,8 +538,8 @@ public:
void AddJukeboxEntity(cJukeboxEntity * a_Jukebox)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Jukebox, "RecordPlayer");
- mWriter.AddInt("Record", a_Jukebox->GetRecord());
+ AddBasicTileEntity(a_Jukebox, "RecordPlayer");
+ mWriter.AddInt("Record", a_Jukebox->GetRecord());
mWriter.EndCompound();
}
@@ -554,15 +550,15 @@ public:
void AddMobSpawnerEntity(cMobSpawnerEntity * a_MobSpawner)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_MobSpawner, "MobSpawner");
- mWriter.AddString("EntityId", NamespaceSerializer::From(a_MobSpawner->GetEntity()));
- mWriter.AddShort("SpawnCount", a_MobSpawner->GetSpawnCount());
- mWriter.AddShort("SpawnRange", a_MobSpawner->GetSpawnRange());
- mWriter.AddShort("Delay", a_MobSpawner->GetSpawnDelay());
- mWriter.AddShort("MinSpawnDelay", a_MobSpawner->GetMinSpawnDelay());
- mWriter.AddShort("MaxSpawnDelay", a_MobSpawner->GetMaxSpawnDelay());
- mWriter.AddShort("MaxNearbyEntities", a_MobSpawner->GetMaxNearbyEntities());
- mWriter.AddShort("RequiredPlayerRange", a_MobSpawner->GetRequiredPlayerRange());
+ AddBasicTileEntity(a_MobSpawner, "MobSpawner");
+ mWriter.AddString("EntityId", NamespaceSerializer::From(a_MobSpawner->GetEntity()));
+ mWriter.AddShort("SpawnCount", a_MobSpawner->GetSpawnCount());
+ mWriter.AddShort("SpawnRange", a_MobSpawner->GetSpawnRange());
+ mWriter.AddShort("Delay", a_MobSpawner->GetSpawnDelay());
+ mWriter.AddShort("MinSpawnDelay", a_MobSpawner->GetMinSpawnDelay());
+ mWriter.AddShort("MaxSpawnDelay", a_MobSpawner->GetMaxSpawnDelay());
+ mWriter.AddShort("MaxNearbyEntities", a_MobSpawner->GetMaxNearbyEntities());
+ mWriter.AddShort("RequiredPlayerRange", a_MobSpawner->GetRequiredPlayerRange());
mWriter.EndCompound();
}
@@ -573,8 +569,8 @@ public:
void AddNoteEntity(cNoteEntity * a_Note)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Note, "Music");
- mWriter.AddByte("note", static_cast<Byte>(a_Note->GetNote()));
+ AddBasicTileEntity(a_Note, "Music");
+ mWriter.AddByte("note", static_cast<Byte>(a_Note->GetNote()));
mWriter.EndCompound();
}
@@ -585,11 +581,11 @@ public:
void AddCommandBlockEntity(cCommandBlockEntity * a_CmdBlock)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_CmdBlock, "Control");
- mWriter.AddString("Command", a_CmdBlock->GetCommand());
- mWriter.AddInt ("SuccessCount", a_CmdBlock->GetResult());
- mWriter.AddString("LastOutput", a_CmdBlock->GetLastOutput());
- mWriter.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it.
+ AddBasicTileEntity(a_CmdBlock, "Control");
+ mWriter.AddString("Command", a_CmdBlock->GetCommand());
+ mWriter.AddInt("SuccessCount", a_CmdBlock->GetResult());
+ mWriter.AddString("LastOutput", a_CmdBlock->GetLastOutput());
+ mWriter.AddByte("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it.
mWriter.EndCompound();
}
@@ -600,11 +596,11 @@ public:
void AddSignEntity(cSignEntity * a_Sign)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_Sign, "Sign");
- mWriter.AddString("Text1", a_Sign->GetLine(0));
- mWriter.AddString("Text2", a_Sign->GetLine(1));
- mWriter.AddString("Text3", a_Sign->GetLine(2));
- mWriter.AddString("Text4", a_Sign->GetLine(3));
+ AddBasicTileEntity(a_Sign, "Sign");
+ mWriter.AddString("Text1", a_Sign->GetLine(0));
+ mWriter.AddString("Text2", a_Sign->GetLine(1));
+ mWriter.AddString("Text3", a_Sign->GetLine(2));
+ mWriter.AddString("Text4", a_Sign->GetLine(3));
mWriter.EndCompound();
}
@@ -615,23 +611,23 @@ public:
void AddMobHeadEntity(cMobHeadEntity * a_MobHead)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_MobHead, "Skull");
- mWriter.AddByte ("SkullType", a_MobHead->GetType() & 0xFF);
- mWriter.AddByte ("Rot", a_MobHead->GetRotation() & 0xFF);
-
- // The new Block Entity format for a Mob Head. See: https://minecraft.wiki/w/Head#Block_entity
- mWriter.BeginCompound("Owner");
- mWriter.AddString("Id", a_MobHead->GetOwnerUUID().ToShortString());
- mWriter.AddString("Name", a_MobHead->GetOwnerName());
- mWriter.BeginCompound("Properties");
- mWriter.BeginList("textures", TAG_Compound);
- mWriter.BeginCompound("");
- mWriter.AddString("Signature", a_MobHead->GetOwnerTextureSignature());
- mWriter.AddString("Value", a_MobHead->GetOwnerTexture());
- mWriter.EndCompound();
- mWriter.EndList();
- mWriter.EndCompound();
- mWriter.EndCompound();
+ AddBasicTileEntity(a_MobHead, "Skull");
+ mWriter.AddByte("SkullType", a_MobHead->GetType() & 0xFF);
+ mWriter.AddByte("Rot", a_MobHead->GetRotation() & 0xFF);
+
+ // The new Block Entity format for a Mob Head. See: https://minecraft.wiki/w/Head#Block_entity
+ mWriter.BeginCompound("Owner");
+ mWriter.AddString("Id", a_MobHead->GetOwnerUUID().ToShortString());
+ mWriter.AddString("Name", a_MobHead->GetOwnerName());
+ mWriter.BeginCompound("Properties");
+ mWriter.BeginList("textures", TAG_Compound);
+ mWriter.BeginCompound("");
+ mWriter.AddString("Signature", a_MobHead->GetOwnerTextureSignature());
+ mWriter.AddString("Value", a_MobHead->GetOwnerTexture());
+ mWriter.EndCompound();
+ mWriter.EndList();
+ mWriter.EndCompound();
+ mWriter.EndCompound();
mWriter.EndCompound();
}
@@ -642,9 +638,9 @@ public:
void AddFlowerPotEntity(cFlowerPotEntity * a_FlowerPot)
{
mWriter.BeginCompound("");
- AddBasicTileEntity(a_FlowerPot, "FlowerPot");
- mWriter.AddInt ("Item", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemType));
- mWriter.AddInt ("Data", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemDamage));
+ AddBasicTileEntity(a_FlowerPot, "FlowerPot");
+ mWriter.AddInt("Item", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemType));
+ mWriter.AddInt("Data", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemDamage));
mWriter.EndCompound();
}
@@ -656,18 +652,18 @@ public:
{
mWriter.AddString("id", a_ClassName);
mWriter.BeginList("Pos", TAG_Double);
- mWriter.AddDouble("", a_Entity->GetPosX());
- mWriter.AddDouble("", a_Entity->GetPosY());
- mWriter.AddDouble("", a_Entity->GetPosZ());
+ mWriter.AddDouble("", a_Entity->GetPosX());
+ mWriter.AddDouble("", a_Entity->GetPosY());
+ mWriter.AddDouble("", a_Entity->GetPosZ());
mWriter.EndList();
mWriter.BeginList("Motion", TAG_Double);
- mWriter.AddDouble("", a_Entity->GetSpeedX());
- mWriter.AddDouble("", a_Entity->GetSpeedY());
- mWriter.AddDouble("", a_Entity->GetSpeedZ());
+ mWriter.AddDouble("", a_Entity->GetSpeedX());
+ mWriter.AddDouble("", a_Entity->GetSpeedY());
+ mWriter.AddDouble("", a_Entity->GetSpeedZ());
mWriter.EndList();
mWriter.BeginList("Rotation", TAG_Double);
- mWriter.AddDouble("", a_Entity->GetYaw());
- mWriter.AddDouble("", a_Entity->GetPitch());
+ mWriter.AddDouble("", a_Entity->GetYaw());
+ mWriter.AddDouble("", a_Entity->GetPitch());
mWriter.EndList();
mWriter.AddFloat("Health", a_Entity->GetHealth());
}
@@ -679,8 +675,8 @@ public:
void AddBoatEntity(cBoat * a_Boat)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_Boat, "Boat");
- mWriter.AddString("Type", cBoat::MaterialToString(a_Boat->GetMaterial()));
+ AddBasicEntity(a_Boat, "Boat");
+ mWriter.AddString("Type", cBoat::MaterialToString(a_Boat->GetMaterial()));
mWriter.EndCompound();
}
@@ -691,17 +687,17 @@ public:
void AddEnderCrystalEntity(cEnderCrystal * a_EnderCrystal)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_EnderCrystal, "EnderCrystal");
- mWriter.AddByte("ShowBottom", a_EnderCrystal->ShowsBottom() ? 1 : 0);
- if (a_EnderCrystal->DisplaysBeam())
- {
- mWriter.BeginCompound("BeamTarget");
- const auto & BeamTarget = a_EnderCrystal->GetBeamTarget();
- mWriter.AddInt("X", BeamTarget.x);
- mWriter.AddInt("Y", BeamTarget.y);
- mWriter.AddInt("Z", BeamTarget.z);
- mWriter.EndCompound();
- }
+ AddBasicEntity(a_EnderCrystal, "EnderCrystal");
+ mWriter.AddByte("ShowBottom", a_EnderCrystal->ShowsBottom() ? 1 : 0);
+ if (a_EnderCrystal->DisplaysBeam())
+ {
+ mWriter.BeginCompound("BeamTarget");
+ const auto & BeamTarget = a_EnderCrystal->GetBeamTarget();
+ mWriter.AddInt("X", BeamTarget.x);
+ mWriter.AddInt("Y", BeamTarget.y);
+ mWriter.AddInt("Z", BeamTarget.z);
+ mWriter.EndCompound();
+ }
mWriter.EndCompound();
}
@@ -712,12 +708,12 @@ public:
void AddFallingBlockEntity(cFallingBlock * a_FallingBlock)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_FallingBlock, "FallingSand");
- mWriter.AddInt("TileID", a_FallingBlock->GetBlockType());
- mWriter.AddByte("Data", a_FallingBlock->GetBlockMeta());
- mWriter.AddByte("Time", 1); // Unused in Cuberite, Vanilla said to need nonzero
- mWriter.AddByte("DropItem", 1);
- mWriter.AddByte("HurtEntities", a_FallingBlock->GetBlockType() == E_BLOCK_ANVIL);
+ AddBasicEntity(a_FallingBlock, "FallingSand");
+ mWriter.AddInt("TileID", a_FallingBlock->GetBlockType());
+ mWriter.AddByte("Data", a_FallingBlock->GetBlockMeta());
+ mWriter.AddByte("Time", 1); // Unused in Cuberite, Vanilla said to need nonzero
+ mWriter.AddByte("DropItem", 1);
+ mWriter.AddByte("HurtEntities", a_FallingBlock->GetBlockType() == E_BLOCK_ANVIL);
mWriter.EndCompound();
}
@@ -729,38 +725,38 @@ public:
{
mWriter.BeginCompound("");
- switch (a_Minecart->GetPayload())
+ switch (a_Minecart->GetPayload())
+ {
+ case cMinecart::mpChest:
{
- case cMinecart::mpChest:
- {
- AddBasicEntity(a_Minecart, "MinecartChest");
- // Add chest contents into the Items tag:
- AddMinecartChestContents(static_cast<cMinecartWithChest *>(a_Minecart));
- break;
- }
- case cMinecart::mpFurnace:
- {
- AddBasicEntity(a_Minecart, "MinecartFurnace");
- // TODO: Add "Push" and "Fuel" tags
- break;
- }
- case cMinecart::mpHopper:
- {
- AddBasicEntity(a_Minecart, "MinecartHopper");
- // TODO: Add hopper contents?
- break;
- }
- case cMinecart::mpTNT:
- {
- AddBasicEntity(a_Minecart, "MinecartTNT");
- break;
- }
- case cMinecart::mpNone:
- {
- AddBasicEntity(a_Minecart, "MinecartRideable");
- break;
- }
- } // switch (Payload)
+ AddBasicEntity(a_Minecart, "MinecartChest");
+ // Add chest contents into the Items tag:
+ AddMinecartChestContents(static_cast<cMinecartWithChest *>(a_Minecart));
+ break;
+ }
+ case cMinecart::mpFurnace:
+ {
+ AddBasicEntity(a_Minecart, "MinecartFurnace");
+ // TODO: Add "Push" and "Fuel" tags
+ break;
+ }
+ case cMinecart::mpHopper:
+ {
+ AddBasicEntity(a_Minecart, "MinecartHopper");
+ // TODO: Add hopper contents?
+ break;
+ }
+ case cMinecart::mpTNT:
+ {
+ AddBasicEntity(a_Minecart, "MinecartTNT");
+ break;
+ }
+ case cMinecart::mpNone:
+ {
+ AddBasicEntity(a_Minecart, "MinecartRideable");
+ break;
+ }
+ } // switch (Payload)
mWriter.EndCompound();
}
@@ -772,244 +768,247 @@ public:
void AddMonsterEntity(cMonster * a_Monster)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_Monster, NamespaceSerializer::From(a_Monster->GetMobType()));
- mWriter.BeginList("DropChances", TAG_Float);
- mWriter.AddFloat("", a_Monster->GetDropChanceWeapon());
- mWriter.AddFloat("", a_Monster->GetDropChanceHelmet());
- mWriter.AddFloat("", a_Monster->GetDropChanceChestplate());
- mWriter.AddFloat("", a_Monster->GetDropChanceLeggings());
- mWriter.AddFloat("", a_Monster->GetDropChanceBoots());
- mWriter.EndList();
- mWriter.AddByte("CanPickUpLoot", (a_Monster->CanPickUpLoot())? 1 : 0);
- mWriter.AddString("CustomName", a_Monster->GetCustomName());
- mWriter.AddByte("CustomNameVisible", static_cast<Byte>(a_Monster->IsCustomNameAlwaysVisible()));
+ AddBasicEntity(a_Monster, NamespaceSerializer::From(a_Monster->GetMobType()));
+ mWriter.BeginList("DropChances", TAG_Float);
+ mWriter.AddFloat("", a_Monster->GetDropChanceWeapon());
+ mWriter.AddFloat("", a_Monster->GetDropChanceHelmet());
+ mWriter.AddFloat("", a_Monster->GetDropChanceChestplate());
+ mWriter.AddFloat("", a_Monster->GetDropChanceLeggings());
+ mWriter.AddFloat("", a_Monster->GetDropChanceBoots());
+ mWriter.EndList();
+ mWriter.AddByte("CanPickUpLoot", (a_Monster->CanPickUpLoot()) ? 1 : 0);
+ mWriter.AddString("CustomName", a_Monster->GetCustomName());
+ mWriter.AddByte("CustomNameVisible", static_cast<Byte>(a_Monster->IsCustomNameAlwaysVisible()));
- // Mob was leashed
- if (a_Monster->IsLeashed() || (a_Monster->GetLeashToPos() != nullptr))
- {
- mWriter.AddByte("Leashed", 1);
+ // Mob was leashed
+ if (a_Monster->IsLeashed() || (a_Monster->GetLeashToPos() != nullptr))
+ {
+ mWriter.AddByte("Leashed", 1);
- const Vector3d * LeashedToPos = nullptr;
+ const Vector3d * LeashedToPos = nullptr;
- if (a_Monster->GetLeashToPos() != nullptr)
- {
- LeashedToPos = a_Monster->GetLeashToPos();
- }
- else if (a_Monster->GetLeashedTo()->IsLeashKnot())
- {
- LeashedToPos = & a_Monster->GetLeashedTo()->GetPosition();
- }
+ if (a_Monster->GetLeashToPos() != nullptr)
+ {
+ LeashedToPos = a_Monster->GetLeashToPos();
+ }
+ else if (a_Monster->GetLeashedTo()->IsLeashKnot())
+ {
+ LeashedToPos = &a_Monster->GetLeashedTo()->GetPosition();
+ }
- if (LeashedToPos != nullptr)
- {
- mWriter.BeginCompound("Leash");
- mWriter.AddDouble("X", LeashedToPos->x);
- mWriter.AddDouble("Y", LeashedToPos->y);
- mWriter.AddDouble("Z", LeashedToPos->z);
- mWriter.EndCompound();
- }
+ if (LeashedToPos != nullptr)
+ {
+ mWriter.BeginCompound("Leash");
+ mWriter.AddDouble("X", LeashedToPos->x);
+ mWriter.AddDouble("Y", LeashedToPos->y);
+ mWriter.AddDouble("Z", LeashedToPos->z);
+ mWriter.EndCompound();
}
+ }
- switch (a_Monster->GetMobType())
+ switch (a_Monster->GetMobType())
+ {
+ case mtBat:
{
- case mtBat:
- {
- mWriter.AddByte("BatFlags", static_cast<const cBat *>(a_Monster)->IsHanging());
- break;
- }
- case mtCreeper:
- {
- const cCreeper *Creeper = static_cast<const cCreeper *>(a_Monster);
- mWriter.AddByte("powered", Creeper->IsCharged());
- mWriter.AddByte("ignited", Creeper->IsBlowing());
- break;
- }
- case mtEnderman:
- {
- const cEnderman *Enderman = static_cast<const cEnderman *>(a_Monster);
- mWriter.AddShort("carried", static_cast<Int16>(Enderman->GetCarriedBlock()));
- mWriter.AddShort("carriedData", static_cast<Int16>(Enderman->GetCarriedMeta()));
- break;
- }
- case mtHorse:
- {
- const cHorse *Horse = static_cast<const cHorse *>(a_Monster);
- mWriter.AddByte("ChestedHorse", Horse->IsChested()? 1 : 0);
- mWriter.AddByte("EatingHaystack", Horse->IsEating()? 1 : 0);
- mWriter.AddByte("Tame", Horse->IsTame()? 1: 0);
- mWriter.AddInt ("Type", Horse->GetHorseType());
- mWriter.AddInt ("Color", Horse->GetHorseColor());
- mWriter.AddInt ("Style", Horse->GetHorseStyle());
- mWriter.AddInt ("ArmorType", Horse->GetHorseArmour());
- mWriter.AddByte("Saddle", Horse->IsSaddled()? 1 : 0);
- mWriter.AddInt ("Age", Horse->GetAge());
- break;
- }
- case mtMagmaCube:
- {
- mWriter.AddInt("Size", static_cast<const cMagmaCube *>(a_Monster)->GetSize());
- break;
- }
- case mtOcelot:
- {
- const auto *Ocelot = static_cast<const cOcelot *>(a_Monster);
- if (!Ocelot->GetOwnerName().empty())
- {
- mWriter.AddString("Owner", Ocelot->GetOwnerName());
- }
- if (!Ocelot->GetOwnerUUID().IsNil())
- {
- mWriter.AddString("OwnerUUID", Ocelot->GetOwnerUUID().ToShortString());
- }
- mWriter.AddByte("Sitting", Ocelot->IsSitting() ? 1 : 0);
- mWriter.AddInt("CatType", Ocelot->GetOcelotType());
- mWriter.AddInt("Age", Ocelot->GetAge());
- break;
- }
- case mtPig:
- {
- mWriter.AddInt("Age", static_cast<const cPig *>(a_Monster)->GetAge());
- break;
- }
- case mtRabbit:
- {
- const cRabbit * Rabbit = static_cast<const cRabbit *>(a_Monster);
- mWriter.AddInt("RabbitType", static_cast<Int32>(Rabbit->GetRabbitType()));
- mWriter.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks());
- mWriter.AddInt("Age", Rabbit->GetAge());
- break;
- }
- case mtSheep:
- {
- const cSheep *Sheep = static_cast<const cSheep *>(a_Monster);
- mWriter.AddByte("Sheared", Sheep->IsSheared()? 1 : 0);
- mWriter.AddByte("Color", static_cast<Byte>(Sheep->GetFurColor()));
- mWriter.AddInt ("Age", Sheep->GetAge());
- break;
- }
- case mtSlime:
- {
- mWriter.AddInt("Size", static_cast<const cSlime *>(a_Monster)->GetSize());
- break;
- }
- case mtVillager:
- {
- const cVillager *Villager = static_cast<const cVillager *>(a_Monster);
- mWriter.AddInt("Profession", Villager->GetVilType());
- mWriter.AddInt("Age", Villager->GetAge());
- mWriter.BeginList("Inventory", TAG_Compound);
- AddItemGrid(Villager->GetInventory());
- mWriter.EndList();
- break;
- }
- case mtWither:
- {
- mWriter.AddInt("Invul", static_cast<Int32>(static_cast<const cWither *>(a_Monster)->GetWitherInvulnerableTicks()));
- break;
- }
- case mtWolf:
- {
- const cWolf *Wolf = static_cast<const cWolf *>(a_Monster);
- if (!Wolf->GetOwnerName().empty())
- {
- mWriter.AddString("Owner", Wolf->GetOwnerName());
- }
- if (!Wolf->GetOwnerUUID().IsNil())
- {
- mWriter.AddString("OwnerUUID", Wolf->GetOwnerUUID().ToShortString());
- }
- mWriter.AddByte("Sitting", Wolf->IsSitting() ? 1 : 0);
- mWriter.AddByte("Angry", Wolf->IsAngry() ? 1 : 0);
- mWriter.AddByte("CollarColor", static_cast<Byte>(Wolf->GetCollarColor()));
- mWriter.AddInt ("Age", Wolf->GetAge());
- break;
- }
- case mtZombie:
- {
- mWriter.AddInt("Age", static_cast<const cZombie *>(a_Monster)->GetAge());
- break;
- }
- case mtZombiePigman:
- {
- mWriter.AddInt("Age", static_cast<const cZombiePigman *>(a_Monster)->GetAge());
- break;
- }
- case mtZombieVillager:
+ mWriter.AddByte("BatFlags", static_cast<const cBat *>(a_Monster)->IsHanging());
+ break;
+ }
+ case mtCreeper:
+ {
+ const cCreeper * Creeper = static_cast<const cCreeper *>(a_Monster);
+ mWriter.AddByte("powered", Creeper->IsCharged());
+ mWriter.AddByte("ignited", Creeper->IsBlowing());
+ break;
+ }
+ case mtEnderman:
+ {
+ const cEnderman * Enderman = static_cast<const cEnderman *>(a_Monster);
+ mWriter.AddShort("carried", static_cast<Int16>(Enderman->GetCarriedBlock()));
+ mWriter.AddShort("carriedData", static_cast<Int16>(Enderman->GetCarriedMeta()));
+ break;
+ }
+ case mtHorse:
+ {
+ const cHorse * Horse = static_cast<const cHorse *>(a_Monster);
+ mWriter.AddByte("ChestedHorse", Horse->IsChested() ? 1 : 0);
+ mWriter.AddByte("EatingHaystack", Horse->IsEating() ? 1 : 0);
+ mWriter.AddByte("Tame", Horse->IsTame() ? 1 : 0);
+ mWriter.AddInt("Type", Horse->GetHorseType());
+ mWriter.AddInt("Color", Horse->GetHorseColor());
+ mWriter.AddInt("Style", Horse->GetHorseStyle());
+ mWriter.AddInt("ArmorType", Horse->GetHorseArmour());
+ mWriter.AddByte("Saddle", Horse->IsSaddled() ? 1 : 0);
+ mWriter.AddInt("Age", Horse->GetAge());
+ break;
+ }
+ case mtMagmaCube:
+ {
+ mWriter.AddInt("Size", static_cast<const cMagmaCube *>(a_Monster)->GetSize());
+ break;
+ }
+ case mtOcelot:
+ {
+ const auto * Ocelot = static_cast<const cOcelot *>(a_Monster);
+ if (!Ocelot->GetOwnerName().empty())
{
- const cZombieVillager *ZombieVillager = reinterpret_cast<const cZombieVillager *>(a_Monster);
- mWriter.AddInt("Profession", ZombieVillager->GetProfession());
- mWriter.AddInt("ConversionTime", ZombieVillager->ConversionTime());
- mWriter.AddInt("Age", ZombieVillager->GetAge());
- break;
+ mWriter.AddString("Owner", Ocelot->GetOwnerName());
}
- case mtBlaze:
- case mtCaveSpider:
- case mtChicken:
- case mtCow:
- case mtEnderDragon:
- case mtGhast:
- case mtGiant:
- case mtGuardian:
- case mtIronGolem:
- case mtMooshroom:
- case mtSilverfish:
- case mtSkeleton:
- case mtSnowGolem:
- case mtSpider:
- case mtSquid:
- case mtWitch:
- case mtWitherSkeleton:
+ if (!Ocelot->GetOwnerUUID().IsNil())
{
- // Other mobs have no special tags.
- break;
+ mWriter.AddString("OwnerUUID", Ocelot->GetOwnerUUID().ToShortString());
}
- case mtCat:
- case mtCod:
- case mtDolphin:
- case mtDonkey:
- case mtDrowned:
- case mtElderGuardian:
- case mtEndermite:
- case mtEvoker:
- case mtFox:
- case mtHoglin:
- case mtHusk:
- case mtIllusioner:
- case mtLlama:
- case mtMule:
- case mtPanda:
- case mtParrot:
- case mtPhantom:
- case mtPiglin:
- case mtPiglinBrute:
- case mtPillager:
- case mtPolarBear:
- case mtPufferfish:
- case mtRavager:
- case mtSalmon:
- case mtShulker:
- case mtSkeletonHorse:
- case mtStray:
- case mtStrider:
- case mtTraderLlama:
- case mtTropicalFish:
- case mtTurtle:
- case mtVex:
- case mtVindicator:
- case mtWanderingTrader:
- case mtZoglin:
- case mtZombieHorse:
+ mWriter.AddByte("Sitting", Ocelot->IsSitting() ? 1 : 0);
+ mWriter.AddInt("CatType", Ocelot->GetOcelotType());
+ mWriter.AddInt("Age", Ocelot->GetAge());
+ break;
+ }
+ case mtPig:
+ {
+ mWriter.AddInt("Age", static_cast<const cPig *>(a_Monster)->GetAge());
+ break;
+ }
+ case mtRabbit:
+ {
+ const cRabbit * Rabbit = static_cast<const cRabbit *>(a_Monster);
+ mWriter.AddInt("RabbitType", static_cast<Int32>(Rabbit->GetRabbitType()));
+ mWriter.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks());
+ mWriter.AddInt("Age", Rabbit->GetAge());
+ break;
+ }
+ case mtSheep:
+ {
+ const cSheep * Sheep = static_cast<const cSheep *>(a_Monster);
+ mWriter.AddByte("Sheared", Sheep->IsSheared() ? 1 : 0);
+ mWriter.AddByte("Color", static_cast<Byte>(Sheep->GetFurColor()));
+ mWriter.AddInt("Age", Sheep->GetAge());
+ break;
+ }
+ case mtSlime:
+ {
+ mWriter.AddInt("Size", static_cast<const cSlime *>(a_Monster)->GetSize());
+ break;
+ }
+ case mtVillager:
+ {
+ const cVillager * Villager = static_cast<const cVillager *>(a_Monster);
+ mWriter.AddInt("Profession", Villager->GetVilType());
+ mWriter.AddInt("Age", Villager->GetAge());
+ mWriter.BeginList("Inventory", TAG_Compound);
+ AddItemGrid(Villager->GetInventory());
+ mWriter.EndList();
+ break;
+ }
+ case mtWither:
+ {
+ mWriter.AddInt(
+ "Invul",
+ static_cast<Int32>(static_cast<const cWither *>(a_Monster)->GetWitherInvulnerableTicks())
+ );
+ break;
+ }
+ case mtWolf:
+ {
+ const cWolf * Wolf = static_cast<const cWolf *>(a_Monster);
+ if (!Wolf->GetOwnerName().empty())
{
- // All the entities not added
- LOGD("Saving unimplemented entity type: %d", NamespaceSerializer::From(a_Monster->GetMobType()));
- break;
+ mWriter.AddString("Owner", Wolf->GetOwnerName());
}
- case mtInvalidType:
+ if (!Wolf->GetOwnerUUID().IsNil())
{
- ASSERT(!"NBTChunkSerializer::SerializerCollector::AddMonsterEntity: Recieved mob of invalid type");
- break;
+ mWriter.AddString("OwnerUUID", Wolf->GetOwnerUUID().ToShortString());
}
+ mWriter.AddByte("Sitting", Wolf->IsSitting() ? 1 : 0);
+ mWriter.AddByte("Angry", Wolf->IsAngry() ? 1 : 0);
+ mWriter.AddByte("CollarColor", static_cast<Byte>(Wolf->GetCollarColor()));
+ mWriter.AddInt("Age", Wolf->GetAge());
+ break;
+ }
+ case mtZombie:
+ {
+ mWriter.AddInt("Age", static_cast<const cZombie *>(a_Monster)->GetAge());
+ break;
+ }
+ case mtZombiePigman:
+ {
+ mWriter.AddInt("Age", static_cast<const cZombiePigman *>(a_Monster)->GetAge());
+ break;
+ }
+ case mtZombieVillager:
+ {
+ const cZombieVillager * ZombieVillager = reinterpret_cast<const cZombieVillager *>(a_Monster);
+ mWriter.AddInt("Profession", ZombieVillager->GetProfession());
+ mWriter.AddInt("ConversionTime", ZombieVillager->ConversionTime());
+ mWriter.AddInt("Age", ZombieVillager->GetAge());
+ break;
+ }
+ case mtBlaze:
+ case mtCaveSpider:
+ case mtChicken:
+ case mtCow:
+ case mtEnderDragon:
+ case mtGhast:
+ case mtGiant:
+ case mtGuardian:
+ case mtIronGolem:
+ case mtMooshroom:
+ case mtSilverfish:
+ case mtSkeleton:
+ case mtSnowGolem:
+ case mtSpider:
+ case mtSquid:
+ case mtWitch:
+ case mtWitherSkeleton:
+ {
+ // Other mobs have no special tags.
+ break;
}
+ case mtCat:
+ case mtCod:
+ case mtDolphin:
+ case mtDonkey:
+ case mtDrowned:
+ case mtElderGuardian:
+ case mtEndermite:
+ case mtEvoker:
+ case mtFox:
+ case mtHoglin:
+ case mtHusk:
+ case mtIllusioner:
+ case mtLlama:
+ case mtMule:
+ case mtPanda:
+ case mtParrot:
+ case mtPhantom:
+ case mtPiglin:
+ case mtPiglinBrute:
+ case mtPillager:
+ case mtPolarBear:
+ case mtPufferfish:
+ case mtRavager:
+ case mtSalmon:
+ case mtShulker:
+ case mtSkeletonHorse:
+ case mtStray:
+ case mtStrider:
+ case mtTraderLlama:
+ case mtTropicalFish:
+ case mtTurtle:
+ case mtVex:
+ case mtVindicator:
+ case mtWanderingTrader:
+ case mtZoglin:
+ case mtZombieHorse:
+ {
+ // All the entities not added
+ LOGD("Saving unimplemented entity type: %d", NamespaceSerializer::From(a_Monster->GetMobType()));
+ break;
+ }
+ case mtInvalidType:
+ {
+ ASSERT(!"NBTChunkSerializer::SerializerCollector::AddMonsterEntity: Recieved mob of invalid type");
+ break;
+ }
+ }
mWriter.EndCompound();
}
@@ -1020,9 +1019,9 @@ public:
void AddPickupEntity(cPickup * a_Pickup)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_Pickup, "Item");
- AddItem(a_Pickup->GetItem(), -1, "Item");
- mWriter.AddShort("Age", static_cast<Int16>(a_Pickup->GetAge()));
+ AddBasicEntity(a_Pickup, "Item");
+ AddItem(a_Pickup->GetItem(), -1, "Item");
+ mWriter.AddShort("Age", static_cast<Int16>(a_Pickup->GetAge()));
mWriter.EndCompound();
}
@@ -1033,55 +1032,55 @@ public:
void AddProjectileEntity(cProjectileEntity * a_Projectile)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_Projectile, a_Projectile->GetMCAClassName());
- mWriter.AddByte("inGround", a_Projectile->IsInGround() ? 1 : 0);
+ AddBasicEntity(a_Projectile, a_Projectile->GetMCAClassName());
+ mWriter.AddByte("inGround", a_Projectile->IsInGround() ? 1 : 0);
- switch (a_Projectile->GetProjectileKind())
+ switch (a_Projectile->GetProjectileKind())
+ {
+ case cProjectileEntity::pkArrow:
{
- case cProjectileEntity::pkArrow:
- {
- cArrowEntity * Arrow = static_cast<cArrowEntity *>(a_Projectile);
-
- mWriter.AddShort("xTile", static_cast<Int16>(Arrow->GetBlockHit().x));
- mWriter.AddShort("yTile", static_cast<Int16>(Arrow->GetBlockHit().y));
- mWriter.AddShort("zTile", static_cast<Int16>(Arrow->GetBlockHit().z));
- mWriter.AddByte("pickup", static_cast<unsigned char>(Arrow->GetPickupState()));
- mWriter.AddDouble("damage", Arrow->GetDamageCoeff());
- break;
- }
- case cProjectileEntity::pkSplashPotion:
- {
- cSplashPotionEntity * Potion = static_cast<cSplashPotionEntity *>(a_Projectile);
-
- mWriter.AddInt("EffectType", static_cast<Int16>(Potion->GetEntityEffectType()));
- mWriter.AddInt("EffectDuration", static_cast<Int16>(Potion->GetEntityEffect().GetDuration()));
- mWriter.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
- mWriter.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
- mWriter.AddInt("PotionName", Potion->GetPotionColor());
- break;
- }
- case cProjectileEntity::pkGhastFireball:
- {
- mWriter.AddInt("ExplosionPower", 1);
- break;
- }
- case cProjectileEntity::pkFireCharge:
- case cProjectileEntity::pkWitherSkull:
- case cProjectileEntity::pkEnderPearl:
- case cProjectileEntity::pkSnowball:
- {
- break;
- }
- default:
- {
- ASSERT(!"Unsaved projectile entity!");
- }
- } // switch (ProjectileKind)
+ cArrowEntity * Arrow = static_cast<cArrowEntity *>(a_Projectile);
- if (!a_Projectile->GetCreatorName().empty())
+ mWriter.AddShort("xTile", static_cast<Int16>(Arrow->GetBlockHit().x));
+ mWriter.AddShort("yTile", static_cast<Int16>(Arrow->GetBlockHit().y));
+ mWriter.AddShort("zTile", static_cast<Int16>(Arrow->GetBlockHit().z));
+ mWriter.AddByte("pickup", static_cast<unsigned char>(Arrow->GetPickupState()));
+ mWriter.AddDouble("damage", Arrow->GetDamageCoeff());
+ break;
+ }
+ case cProjectileEntity::pkSplashPotion:
+ {
+ cSplashPotionEntity * Potion = static_cast<cSplashPotionEntity *>(a_Projectile);
+
+ mWriter.AddInt("EffectType", static_cast<Int16>(Potion->GetEntityEffectType()));
+ mWriter.AddInt("EffectDuration", static_cast<Int16>(Potion->GetEntityEffect().GetDuration()));
+ mWriter.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
+ mWriter.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
+ mWriter.AddInt("PotionName", Potion->GetPotionColor());
+ break;
+ }
+ case cProjectileEntity::pkGhastFireball:
+ {
+ mWriter.AddInt("ExplosionPower", 1);
+ break;
+ }
+ case cProjectileEntity::pkFireCharge:
+ case cProjectileEntity::pkWitherSkull:
+ case cProjectileEntity::pkEnderPearl:
+ case cProjectileEntity::pkSnowball:
+ {
+ break;
+ }
+ default:
{
- mWriter.AddString("ownerName", a_Projectile->GetCreatorName());
+ ASSERT(!"Unsaved projectile entity!");
}
+ } // switch (ProjectileKind)
+
+ if (!a_Projectile->GetCreatorName().empty())
+ {
+ mWriter.AddString("ownerName", a_Projectile->GetCreatorName());
+ }
mWriter.EndCompound();
}
@@ -1104,8 +1103,8 @@ public:
void AddTNTEntity(cTNTEntity * a_TNT)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_TNT, "PrimedTnt");
- mWriter.AddByte("Fuse", static_cast<unsigned char>(a_TNT->GetFuseTicks()));
+ AddBasicEntity(a_TNT, "PrimedTnt");
+ mWriter.AddByte("Fuse", static_cast<unsigned char>(a_TNT->GetFuseTicks()));
mWriter.EndCompound();
}
@@ -1116,9 +1115,9 @@ public:
void AddExpOrbEntity(cExpOrb * a_ExpOrb)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_ExpOrb, "XPOrb");
- mWriter.AddShort("Age", static_cast<Int16>(a_ExpOrb->GetAge()));
- mWriter.AddShort("Value", static_cast<Int16>(a_ExpOrb->GetReward()));
+ AddBasicEntity(a_ExpOrb, "XPOrb");
+ mWriter.AddShort("Age", static_cast<Int16>(a_ExpOrb->GetAge()));
+ mWriter.AddShort("Value", static_cast<Int16>(a_ExpOrb->GetReward()));
mWriter.EndCompound();
}
@@ -1129,11 +1128,11 @@ public:
void AddItemFrameEntity(cItemFrame * a_ItemFrame)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_ItemFrame, "ItemFrame");
- AddHangingEntity(a_ItemFrame);
- AddItem(a_ItemFrame->GetItem(), -1, "Item");
- mWriter.AddByte("ItemRotation", static_cast<Byte>(a_ItemFrame->GetItemRotation()));
- mWriter.AddFloat("ItemDropChance", 1.0F);
+ AddBasicEntity(a_ItemFrame, "ItemFrame");
+ AddHangingEntity(a_ItemFrame);
+ AddItem(a_ItemFrame->GetItem(), -1, "Item");
+ mWriter.AddByte("ItemRotation", static_cast<Byte>(a_ItemFrame->GetItemRotation()));
+ mWriter.AddFloat("ItemDropChance", 1.0F);
mWriter.EndCompound();
}
@@ -1144,8 +1143,8 @@ public:
void AddLeashKnotEntity(cLeashKnot * a_LeashKnot)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_LeashKnot, "LeashKnot");
- AddHangingEntity(a_LeashKnot);
+ AddBasicEntity(a_LeashKnot, "LeashKnot");
+ AddHangingEntity(a_LeashKnot);
mWriter.EndCompound();
}
@@ -1156,9 +1155,9 @@ public:
void AddPaintingEntity(cPainting * a_Painting)
{
mWriter.BeginCompound("");
- AddBasicEntity(a_Painting, "Painting");
- AddHangingEntity(a_Painting);
- mWriter.AddString("Motive", a_Painting->GetName());
+ AddBasicEntity(a_Painting, "Painting");
+ AddHangingEntity(a_Painting);
+ mWriter.AddString("Motive", a_Painting->GetName());
mWriter.EndCompound();
}
@@ -1169,15 +1168,15 @@ public:
void AddMinecartChestContents(cMinecartWithChest * a_Minecart)
{
mWriter.BeginList("Items", TAG_Compound);
- for (int i = 0; i < cMinecartWithChest::ContentsHeight * cMinecartWithChest::ContentsWidth; i++)
+ for (int i = 0; i < cMinecartWithChest::ContentsHeight * cMinecartWithChest::ContentsWidth; i++)
+ {
+ const cItem & Item = a_Minecart->GetSlot(i);
+ if (Item.IsEmpty())
{
- const cItem & Item = a_Minecart->GetSlot(i);
- if (Item.IsEmpty())
- {
- continue;
- }
- AddItem(Item, i);
+ continue;
}
+ AddItem(Item, i);
+ }
mWriter.EndList();
}
}; // SerializerCollector
@@ -1195,7 +1194,8 @@ void NBTChunkSerializer::Serialize(const cWorld & aWorld, cChunkCoords aCoords,
aWriter.BeginCompound("Level");
aWriter.AddInt("xPos", aCoords.m_ChunkX);
aWriter.AddInt("zPos", aCoords.m_ChunkZ);
- [[maybe_unused]] const bool Result = aWorld.GetChunkData(aCoords, serializer); // Chunk must be present in order to save
+ [[maybe_unused]] const bool Result =
+ aWorld.GetChunkData(aCoords, serializer); // Chunk must be present in order to save
ASSERT(Result);
serializer.Finish(); // Close NBT tags
@@ -1207,8 +1207,7 @@ void NBTChunkSerializer::Serialize(const cWorld & aWorld, cChunkCoords aCoords,
// Save blockdata:
aWriter.BeginList("Sections", TAG_Compound);
- ChunkDef_ForEachSection(serializer.m_BlockData, serializer.m_LightData,
- {
+ ChunkDef_ForEachSection(serializer.m_BlockData, serializer.m_LightData, {
aWriter.BeginCompound("");
if (Blocks != nullptr)
@@ -1231,11 +1230,13 @@ void NBTChunkSerializer::Serialize(const cWorld & aWorld, cChunkCoords aCoords,
if (BlockLights != nullptr)
{
- aWriter.AddByteArray("BlockLight", reinterpret_cast<const char *>(BlockLights->data()), BlockLights->size());
+ aWriter
+ .AddByteArray("BlockLight", reinterpret_cast<const char *>(BlockLights->data()), BlockLights->size());
}
else
{
- aWriter.AddByteArray("BlockLight", ChunkLightData::SectionLightCount, ChunkLightData::DefaultBlockLightValue);
+ aWriter
+ .AddByteArray("BlockLight", ChunkLightData::SectionLightCount, ChunkLightData::DefaultBlockLightValue);
}
if (SkyLights != nullptr)
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index c2de79269..12dabed75 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -19,8 +19,7 @@ The Writer is expected to be set up so that the serializer can write the chunk's
Provides a single static entry point that does all the work, through a hidden worker class in the CPP file. */
class NBTChunkSerializer
{
-public:
-
+ public:
/** Serializes the chunk into the specified writer. The chunk must be present. */
static void Serialize(const cWorld & aWorld, cChunkCoords aCoords, cFastNBTWriter & aWriter);
};
diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp
index d4a025af7..8f36ec1d1 100644
--- a/src/WorldStorage/NamespaceSerializer.cpp
+++ b/src/WorldStorage/NamespaceSerializer.cpp
@@ -144,76 +144,76 @@ std::string_view NamespaceSerializer::From(const eMonsterType a_ID)
{
switch (a_ID)
{
- case mtBat: return "bat";
- case mtBlaze: return "blaze";
- case mtCat: return "cat";
- case mtCaveSpider: return "cave_spider";
- case mtChicken: return "chicken";
- case mtCod: return "cod";
- case mtCow: return "cow";
- case mtCreeper: return "creeper";
- case mtDolphin: return "dolphin";
- case mtDonkey: return "donkey";
- case mtDrowned: return "drowned";
- case mtElderGuardian: return "elder_guardian";
- case mtEnderDragon: return "ender_dragon";
- case mtEnderman: return "enderman";
- case mtEndermite: return "endermite";
- case mtEvoker: return "evoker";
- case mtFox: return "fox";
- case mtGhast: return "ghast";
- case mtGiant: return "giant";
- case mtGuardian: return "guardian";
- case mtHorse: return "horse";
- case mtHoglin: return "hoglin";
- case mtHusk: return "husk";
- case mtIllusioner: return "illusioner";
- case mtIronGolem: return "iron_golem";
- case mtLlama: return "llama";
- case mtMagmaCube: return "magma_cube";
- case mtMooshroom: return "mooshroom";
- case mtMule: return "mule";
- case mtOcelot: return "ocelot";
- case mtPanda: return "panda";
- case mtParrot: return "parrot";
- case mtPhantom: return "phantom";
- case mtPig: return "pig";
- case mtPiglin: return "piglin";
- case mtPiglinBrute: return "piglin_brute";
- case mtPillager: return "pillager";
- case mtPolarBear: return "polar_bear";
- case mtPufferfish: return "pufferfish";
- case mtRabbit: return "rabbit";
- case mtRavager: return "ravager";
- case mtSalmon: return "salmon";
- case mtSheep: return "sheep";
- case mtShulker: return "shulker";
- case mtSilverfish: return "silverfish";
- case mtSkeleton: return "skeleton";
- case mtSkeletonHorse: return "skeleton_horse";
- case mtSlime: return "slime";
- case mtSnowGolem: return "snow_golem";
- case mtSpider: return "spider";
- case mtSquid: return "squid";
- case mtStray: return "stray";
- case mtStrider: return "strider";
- case mtTraderLlama: return "trader_llama";
- case mtTropicalFish: return "tropical_fish";
- case mtTurtle: return "turtle";
- case mtVex: return "vex";
- case mtVillager: return "villager";
- case mtVindicator: return "vindicator";
- case mtWanderingTrader:return "wandering_trader";
- case mtWitch: return "witch";
- case mtWither: return "wither";
- case mtWitherSkeleton: return "wither_skeleton";
- case mtWolf: return "wolf";
- case mtZoglin: return "zoglin";
- case mtZombie: return "zombie";
- case mtZombieHorse: return "zombie_horse";
- case mtZombiePigman: return "zombified_piglin";
- case mtZombieVillager: return "zombie_villager";
- case mtInvalidType: break;
+ case mtBat: return "bat";
+ case mtBlaze: return "blaze";
+ case mtCat: return "cat";
+ case mtCaveSpider: return "cave_spider";
+ case mtChicken: return "chicken";
+ case mtCod: return "cod";
+ case mtCow: return "cow";
+ case mtCreeper: return "creeper";
+ case mtDolphin: return "dolphin";
+ case mtDonkey: return "donkey";
+ case mtDrowned: return "drowned";
+ case mtElderGuardian: return "elder_guardian";
+ case mtEnderDragon: return "ender_dragon";
+ case mtEnderman: return "enderman";
+ case mtEndermite: return "endermite";
+ case mtEvoker: return "evoker";
+ case mtFox: return "fox";
+ case mtGhast: return "ghast";
+ case mtGiant: return "giant";
+ case mtGuardian: return "guardian";
+ case mtHorse: return "horse";
+ case mtHoglin: return "hoglin";
+ case mtHusk: return "husk";
+ case mtIllusioner: return "illusioner";
+ case mtIronGolem: return "iron_golem";
+ case mtLlama: return "llama";
+ case mtMagmaCube: return "magma_cube";
+ case mtMooshroom: return "mooshroom";
+ case mtMule: return "mule";
+ case mtOcelot: return "ocelot";
+ case mtPanda: return "panda";
+ case mtParrot: return "parrot";
+ case mtPhantom: return "phantom";
+ case mtPig: return "pig";
+ case mtPiglin: return "piglin";
+ case mtPiglinBrute: return "piglin_brute";
+ case mtPillager: return "pillager";
+ case mtPolarBear: return "polar_bear";
+ case mtPufferfish: return "pufferfish";
+ case mtRabbit: return "rabbit";
+ case mtRavager: return "ravager";
+ case mtSalmon: return "salmon";
+ case mtSheep: return "sheep";
+ case mtShulker: return "shulker";
+ case mtSilverfish: return "silverfish";
+ case mtSkeleton: return "skeleton";
+ case mtSkeletonHorse: return "skeleton_horse";
+ case mtSlime: return "slime";
+ case mtSnowGolem: return "snow_golem";
+ case mtSpider: return "spider";
+ case mtSquid: return "squid";
+ case mtStray: return "stray";
+ case mtStrider: return "strider";
+ case mtTraderLlama: return "trader_llama";
+ case mtTropicalFish: return "tropical_fish";
+ case mtTurtle: return "turtle";
+ case mtVex: return "vex";
+ case mtVillager: return "villager";
+ case mtVindicator: return "vindicator";
+ case mtWanderingTrader: return "wandering_trader";
+ case mtWitch: return "witch";
+ case mtWither: return "wither";
+ case mtWitherSkeleton: return "wither_skeleton";
+ case mtWolf: return "wolf";
+ case mtZoglin: return "zoglin";
+ case mtZombie: return "zombie";
+ case mtZombieHorse: return "zombie_horse";
+ case mtZombiePigman: return "zombified_piglin";
+ case mtZombieVillager: return "zombie_villager";
+ case mtInvalidType: break;
}
UNREACHABLE("Tried to save unknown monster type");
}
@@ -226,46 +226,46 @@ std::string_view NamespaceSerializer::From(const BannerPattern a_Pattern)
{
switch (a_Pattern)
{
- case BannerPattern::BottomStripe: return "bs";
- case BannerPattern::TopStripe: return "ts";
- case BannerPattern::LeftStripe: return "ls";
- case BannerPattern::RightStripe: return "rs";
- case BannerPattern::CenterStripeVertical: return "cs";
- case BannerPattern::MiddleStripeHorizontal: return "ms";
- case BannerPattern::DownRightStripe: return "drs";
- case BannerPattern::DownLeftStripe: return "dls";
- case BannerPattern::SmallVerticalStripes: return "ss";
- case BannerPattern::DiagonalCross: return "cr";
- case BannerPattern::SquareCross: return "sc";
- case BannerPattern::LeftOfDiagonal: return "ld";
+ case BannerPattern::BottomStripe: return "bs";
+ case BannerPattern::TopStripe: return "ts";
+ case BannerPattern::LeftStripe: return "ls";
+ case BannerPattern::RightStripe: return "rs";
+ case BannerPattern::CenterStripeVertical: return "cs";
+ case BannerPattern::MiddleStripeHorizontal: return "ms";
+ case BannerPattern::DownRightStripe: return "drs";
+ case BannerPattern::DownLeftStripe: return "dls";
+ case BannerPattern::SmallVerticalStripes: return "ss";
+ case BannerPattern::DiagonalCross: return "cr";
+ case BannerPattern::SquareCross: return "sc";
+ case BannerPattern::LeftOfDiagonal: return "ld";
case BannerPattern::RightOfUpsideDownDiagonal: return "rud";
- case BannerPattern::LeftOfUpsideDownDiagonal: return "lud";
- case BannerPattern::RightOfDiagonal: return "rd";
- case BannerPattern::VerticalHalfLeft: return "vh";
- case BannerPattern::VerticalHalfRight: return "vhr";
- case BannerPattern::HorizontalHalfTop: return "hh";
- case BannerPattern::HorizontalHalfBottom: return "hhb";
- case BannerPattern::BottomLeftCorner: return "bl";
- case BannerPattern::BottomRightCorner: return "br";
- case BannerPattern::TopLeftCorner: return "tl";
- case BannerPattern::TopRightCorner: return "tr";
- case BannerPattern::BottomTriangle: return "bt";
- case BannerPattern::TopTriangle: return "tt";
- case BannerPattern::BottomTriangleSawtooth: return "bts";
- case BannerPattern::TopTriangleSawtooth: return "tts";
- case BannerPattern::MiddleCircle: return "mc";
- case BannerPattern::MiddleRhombus: return "mr";
- case BannerPattern::Border: return "bo";
- case BannerPattern::CurlyBorder: return "cbo";
- case BannerPattern::Brick: return "bri";
- case BannerPattern::Gradient: return "gra";
- case BannerPattern::GradientUpsideDown: return "gru";
- case BannerPattern::Creeper: return "cre";
- case BannerPattern::Skull: return "sku";
- case BannerPattern::Flower: return "flo";
- case BannerPattern::Mojang: return "moj";
- case BannerPattern::Globe: return "glb";
- case BannerPattern::Piglin: return "pig";
+ case BannerPattern::LeftOfUpsideDownDiagonal: return "lud";
+ case BannerPattern::RightOfDiagonal: return "rd";
+ case BannerPattern::VerticalHalfLeft: return "vh";
+ case BannerPattern::VerticalHalfRight: return "vhr";
+ case BannerPattern::HorizontalHalfTop: return "hh";
+ case BannerPattern::HorizontalHalfBottom: return "hhb";
+ case BannerPattern::BottomLeftCorner: return "bl";
+ case BannerPattern::BottomRightCorner: return "br";
+ case BannerPattern::TopLeftCorner: return "tl";
+ case BannerPattern::TopRightCorner: return "tr";
+ case BannerPattern::BottomTriangle: return "bt";
+ case BannerPattern::TopTriangle: return "tt";
+ case BannerPattern::BottomTriangleSawtooth: return "bts";
+ case BannerPattern::TopTriangleSawtooth: return "tts";
+ case BannerPattern::MiddleCircle: return "mc";
+ case BannerPattern::MiddleRhombus: return "mr";
+ case BannerPattern::Border: return "bo";
+ case BannerPattern::CurlyBorder: return "cbo";
+ case BannerPattern::Brick: return "bri";
+ case BannerPattern::Gradient: return "gra";
+ case BannerPattern::GradientUpsideDown: return "gru";
+ case BannerPattern::Creeper: return "cre";
+ case BannerPattern::Skull: return "sku";
+ case BannerPattern::Flower: return "flo";
+ case BannerPattern::Mojang: return "moj";
+ case BannerPattern::Globe: return "glb";
+ case BannerPattern::Piglin: return "pig";
}
UNREACHABLE("Unsupported banner pattern");
}
@@ -276,121 +276,120 @@ std::string_view NamespaceSerializer::From(const BannerPattern a_Pattern)
CustomStatistic NamespaceSerializer::ToCustomStatistic(const std::string_view ID)
{
- static const std::unordered_map<std::string_view, CustomStatistic> CustomStatistics
- {
- { "animals_bred", CustomStatistic::AnimalsBred },
- { "aviate_one_cm", CustomStatistic::AviateOneCm },
- { "bell_ring", CustomStatistic::BellRing },
- { "boat_one_cm", CustomStatistic::BoatOneCm },
- { "clean_armor", CustomStatistic::CleanArmor },
- { "clean_banner", CustomStatistic::CleanBanner },
- { "clean_shulker_box", CustomStatistic::CleanShulkerBox },
- { "climb_one_cm", CustomStatistic::ClimbOneCm },
- { "crouch_one_cm", CustomStatistic::CrouchOneCm },
- { "damage_absorbed", CustomStatistic::DamageAbsorbed },
- { "damage_blocked_by_shield", CustomStatistic::DamageBlockedByShield },
- { "damage_dealt", CustomStatistic::DamageDealt },
- { "damage_dealt_absorbed", CustomStatistic::DamageDealtAbsorbed },
- { "damage_dealt_resisted", CustomStatistic::DamageDealtResisted },
- { "damage_resisted", CustomStatistic::DamageResisted },
- { "damage_taken", CustomStatistic::DamageTaken },
- { "deaths", CustomStatistic::Deaths },
- { "drop", CustomStatistic::Drop },
- { "eat_cake_slice", CustomStatistic::EatCakeSlice },
- { "enchant_item", CustomStatistic::EnchantItem },
- { "fall_one_cm", CustomStatistic::FallOneCm },
- { "fill_cauldron", CustomStatistic::FillCauldron },
- { "fish_caught", CustomStatistic::FishCaught },
- { "fly_one_cm", CustomStatistic::FlyOneCm },
- { "horse_one_cm", CustomStatistic::HorseOneCm },
- { "inspect_dispenser", CustomStatistic::InspectDispenser },
- { "inspect_dropper", CustomStatistic::InspectDropper },
- { "inspect_hopper", CustomStatistic::InspectHopper },
- { "interact_with_anvil", CustomStatistic::InteractWithAnvil },
- { "interact_with_beacon", CustomStatistic::InteractWithBeacon },
- { "interact_with_blast_furnace", CustomStatistic::InteractWithBlastFurnace },
- { "interact_with_brewingstand", CustomStatistic::InteractWithBrewingstand },
- { "interact_with_campfire", CustomStatistic::InteractWithCampfire },
- { "interact_with_cartography_table", CustomStatistic::InteractWithCartographyTable },
- { "interact_with_crafting_table", CustomStatistic::InteractWithCraftingTable },
- { "interact_with_furnace", CustomStatistic::InteractWithFurnace },
- { "interact_with_grindstone", CustomStatistic::InteractWithGrindstone },
- { "interact_with_lectern", CustomStatistic::InteractWithLectern },
- { "interact_with_loom", CustomStatistic::InteractWithLoom },
- { "interact_with_smithing_table", CustomStatistic::InteractWithSmithingTable },
- { "interact_with_smoker", CustomStatistic::InteractWithSmoker },
- { "interact_with_stonecutter", CustomStatistic::InteractWithStonecutter },
- { "jump", CustomStatistic::Jump },
- { "leave_game", CustomStatistic::LeaveGame },
- { "minecart_one_cm", CustomStatistic::MinecartOneCm },
- { "mob_kills", CustomStatistic::MobKills },
- { "open_barrel", CustomStatistic::OpenBarrel },
- { "open_chest", CustomStatistic::OpenChest },
- { "open_enderchest", CustomStatistic::OpenEnderchest },
- { "open_shulker_box", CustomStatistic::OpenShulkerBox },
- { "pig_one_cm", CustomStatistic::PigOneCm },
- { "play_noteblock", CustomStatistic::PlayNoteblock },
- { "play_one_minute", CustomStatistic::PlayOneMinute },
- { "play_record", CustomStatistic::PlayRecord },
- { "player_kills", CustomStatistic::PlayerKills },
- { "pot_flower", CustomStatistic::PotFlower },
- { "raid_trigger", CustomStatistic::RaidTrigger },
- { "raid_win", CustomStatistic::RaidWin },
- { "sleep_in_bed", CustomStatistic::SleepInBed },
- { "sneak_time", CustomStatistic::SneakTime },
- { "sprint_one_cm", CustomStatistic::SprintOneCm },
- { "strider_one_cm", CustomStatistic::StriderOneCm },
- { "swim_one_cm", CustomStatistic::SwimOneCm },
- { "talked_to_villager", CustomStatistic::TalkedToVillager },
- { "target_hit", CustomStatistic::TargetHit },
- { "time_since_death", CustomStatistic::TimeSinceDeath },
- { "time_since_rest", CustomStatistic::TimeSinceRest },
- { "traded_with_villager", CustomStatistic::TradedWithVillager },
- { "trigger_trapped_chest", CustomStatistic::TriggerTrappedChest },
- { "tune_noteblock", CustomStatistic::TuneNoteblock },
- { "use_cauldron", CustomStatistic::UseCauldron },
- { "walk_on_water_one_cm", CustomStatistic::WalkOnWaterOneCm },
- { "walk_one_cm", CustomStatistic::WalkOneCm },
- { "walk_under_water_one_cm", CustomStatistic::WalkUnderWaterOneCm },
+ static const std::unordered_map<std::string_view, CustomStatistic> CustomStatistics {
+ {"animals_bred", CustomStatistic::AnimalsBred},
+ {"aviate_one_cm", CustomStatistic::AviateOneCm},
+ {"bell_ring", CustomStatistic::BellRing},
+ {"boat_one_cm", CustomStatistic::BoatOneCm},
+ {"clean_armor", CustomStatistic::CleanArmor},
+ {"clean_banner", CustomStatistic::CleanBanner},
+ {"clean_shulker_box", CustomStatistic::CleanShulkerBox},
+ {"climb_one_cm", CustomStatistic::ClimbOneCm},
+ {"crouch_one_cm", CustomStatistic::CrouchOneCm},
+ {"damage_absorbed", CustomStatistic::DamageAbsorbed},
+ {"damage_blocked_by_shield", CustomStatistic::DamageBlockedByShield},
+ {"damage_dealt", CustomStatistic::DamageDealt},
+ {"damage_dealt_absorbed", CustomStatistic::DamageDealtAbsorbed},
+ {"damage_dealt_resisted", CustomStatistic::DamageDealtResisted},
+ {"damage_resisted", CustomStatistic::DamageResisted},
+ {"damage_taken", CustomStatistic::DamageTaken},
+ {"deaths", CustomStatistic::Deaths},
+ {"drop", CustomStatistic::Drop},
+ {"eat_cake_slice", CustomStatistic::EatCakeSlice},
+ {"enchant_item", CustomStatistic::EnchantItem},
+ {"fall_one_cm", CustomStatistic::FallOneCm},
+ {"fill_cauldron", CustomStatistic::FillCauldron},
+ {"fish_caught", CustomStatistic::FishCaught},
+ {"fly_one_cm", CustomStatistic::FlyOneCm},
+ {"horse_one_cm", CustomStatistic::HorseOneCm},
+ {"inspect_dispenser", CustomStatistic::InspectDispenser},
+ {"inspect_dropper", CustomStatistic::InspectDropper},
+ {"inspect_hopper", CustomStatistic::InspectHopper},
+ {"interact_with_anvil", CustomStatistic::InteractWithAnvil},
+ {"interact_with_beacon", CustomStatistic::InteractWithBeacon},
+ {"interact_with_blast_furnace", CustomStatistic::InteractWithBlastFurnace},
+ {"interact_with_brewingstand", CustomStatistic::InteractWithBrewingstand},
+ {"interact_with_campfire", CustomStatistic::InteractWithCampfire},
+ {"interact_with_cartography_table", CustomStatistic::InteractWithCartographyTable},
+ {"interact_with_crafting_table", CustomStatistic::InteractWithCraftingTable},
+ {"interact_with_furnace", CustomStatistic::InteractWithFurnace},
+ {"interact_with_grindstone", CustomStatistic::InteractWithGrindstone},
+ {"interact_with_lectern", CustomStatistic::InteractWithLectern},
+ {"interact_with_loom", CustomStatistic::InteractWithLoom},
+ {"interact_with_smithing_table", CustomStatistic::InteractWithSmithingTable},
+ {"interact_with_smoker", CustomStatistic::InteractWithSmoker},
+ {"interact_with_stonecutter", CustomStatistic::InteractWithStonecutter},
+ {"jump", CustomStatistic::Jump},
+ {"leave_game", CustomStatistic::LeaveGame},
+ {"minecart_one_cm", CustomStatistic::MinecartOneCm},
+ {"mob_kills", CustomStatistic::MobKills},
+ {"open_barrel", CustomStatistic::OpenBarrel},
+ {"open_chest", CustomStatistic::OpenChest},
+ {"open_enderchest", CustomStatistic::OpenEnderchest},
+ {"open_shulker_box", CustomStatistic::OpenShulkerBox},
+ {"pig_one_cm", CustomStatistic::PigOneCm},
+ {"play_noteblock", CustomStatistic::PlayNoteblock},
+ {"play_one_minute", CustomStatistic::PlayOneMinute},
+ {"play_record", CustomStatistic::PlayRecord},
+ {"player_kills", CustomStatistic::PlayerKills},
+ {"pot_flower", CustomStatistic::PotFlower},
+ {"raid_trigger", CustomStatistic::RaidTrigger},
+ {"raid_win", CustomStatistic::RaidWin},
+ {"sleep_in_bed", CustomStatistic::SleepInBed},
+ {"sneak_time", CustomStatistic::SneakTime},
+ {"sprint_one_cm", CustomStatistic::SprintOneCm},
+ {"strider_one_cm", CustomStatistic::StriderOneCm},
+ {"swim_one_cm", CustomStatistic::SwimOneCm},
+ {"talked_to_villager", CustomStatistic::TalkedToVillager},
+ {"target_hit", CustomStatistic::TargetHit},
+ {"time_since_death", CustomStatistic::TimeSinceDeath},
+ {"time_since_rest", CustomStatistic::TimeSinceRest},
+ {"traded_with_villager", CustomStatistic::TradedWithVillager},
+ {"trigger_trapped_chest", CustomStatistic::TriggerTrappedChest},
+ {"tune_noteblock", CustomStatistic::TuneNoteblock},
+ {"use_cauldron", CustomStatistic::UseCauldron},
+ {"walk_on_water_one_cm", CustomStatistic::WalkOnWaterOneCm},
+ {"walk_one_cm", CustomStatistic::WalkOneCm},
+ {"walk_under_water_one_cm", CustomStatistic::WalkUnderWaterOneCm},
// Old ones just for compatibility
- { "junk_fished", CustomStatistic::JunkFished },
- { "treasure_fished", CustomStatistic::TreasureFished },
+ {"junk_fished", CustomStatistic::JunkFished},
+ {"treasure_fished", CustomStatistic::TreasureFished},
// The old advancements
- { "cuberite:achievement.openInventory", CustomStatistic::AchOpenInventory },
- { "cuberite:achievement.mineWood", CustomStatistic::AchMineWood },
- { "cuberite:achievement.buildWorkBench", CustomStatistic::AchBuildWorkBench },
- { "cuberite:achievement.buildPickaxe", CustomStatistic::AchBuildPickaxe },
- { "cuberite:achievement.buildFurnace", CustomStatistic::AchBuildFurnace },
- { "cuberite:achievement.acquireIron", CustomStatistic::AchAcquireIron },
- { "cuberite:achievement.buildHoe", CustomStatistic::AchBuildHoe },
- { "cuberite:achievement.makeBread", CustomStatistic::AchMakeBread },
- { "cuberite:achievement.bakeCake", CustomStatistic::AchBakeCake },
- { "cuberite:achievement.buildBetterPickaxe", CustomStatistic::AchBuildBetterPickaxe },
- { "cuberite:achievement.cookFish", CustomStatistic::AchCookFish },
- { "cuberite:achievement.onARail", CustomStatistic::AchOnARail },
- { "cuberite:achievement.buildSword", CustomStatistic::AchBuildSword },
- { "cuberite:achievement.killEnemy", CustomStatistic::AchKillEnemy },
- { "cuberite:achievement.killCow", CustomStatistic::AchKillCow },
- { "cuberite:achievement.flyPig", CustomStatistic::AchFlyPig },
- { "cuberite:achievement.snipeSkeleton", CustomStatistic::AchSnipeSkeleton },
- { "cuberite:achievement.diamonds", CustomStatistic::AchDiamonds },
- { "cuberite:achievement.portal", CustomStatistic::AchPortal },
- { "cuberite:achievement.ghast", CustomStatistic::AchGhast },
- { "cuberite:achievement.blazeRod", CustomStatistic::AchBlazeRod },
- { "cuberite:achievement.potion", CustomStatistic::AchPotion },
- { "cuberite:achievement.theEnd", CustomStatistic::AchTheEnd },
- { "cuberite:achievement.theEnd2", CustomStatistic::AchTheEnd2 },
- { "cuberite:achievement.enchantments", CustomStatistic::AchEnchantments },
- { "cuberite:achievement.overkill", CustomStatistic::AchOverkill },
- { "cuberite:achievement.bookcase", CustomStatistic::AchBookcase },
- { "cuberite:achievement.exploreAllBiomes", CustomStatistic::AchExploreAllBiomes },
- { "cuberite:achievement.spawnWither", CustomStatistic::AchSpawnWither },
- { "cuberite:achievement.killWither", CustomStatistic::AchKillWither },
- { "cuberite:achievement.fullBeacon", CustomStatistic::AchFullBeacon },
- { "cuberite:achievement.breedCow", CustomStatistic::AchBreedCow },
- { "cuberite:achievement.diamondsToYou", CustomStatistic::AchDiamondsToYou}
+ {"cuberite:achievement.openInventory", CustomStatistic::AchOpenInventory},
+ {"cuberite:achievement.mineWood", CustomStatistic::AchMineWood},
+ {"cuberite:achievement.buildWorkBench", CustomStatistic::AchBuildWorkBench},
+ {"cuberite:achievement.buildPickaxe", CustomStatistic::AchBuildPickaxe},
+ {"cuberite:achievement.buildFurnace", CustomStatistic::AchBuildFurnace},
+ {"cuberite:achievement.acquireIron", CustomStatistic::AchAcquireIron},
+ {"cuberite:achievement.buildHoe", CustomStatistic::AchBuildHoe},
+ {"cuberite:achievement.makeBread", CustomStatistic::AchMakeBread},
+ {"cuberite:achievement.bakeCake", CustomStatistic::AchBakeCake},
+ {"cuberite:achievement.buildBetterPickaxe", CustomStatistic::AchBuildBetterPickaxe},
+ {"cuberite:achievement.cookFish", CustomStatistic::AchCookFish},
+ {"cuberite:achievement.onARail", CustomStatistic::AchOnARail},
+ {"cuberite:achievement.buildSword", CustomStatistic::AchBuildSword},
+ {"cuberite:achievement.killEnemy", CustomStatistic::AchKillEnemy},
+ {"cuberite:achievement.killCow", CustomStatistic::AchKillCow},
+ {"cuberite:achievement.flyPig", CustomStatistic::AchFlyPig},
+ {"cuberite:achievement.snipeSkeleton", CustomStatistic::AchSnipeSkeleton},
+ {"cuberite:achievement.diamonds", CustomStatistic::AchDiamonds},
+ {"cuberite:achievement.portal", CustomStatistic::AchPortal},
+ {"cuberite:achievement.ghast", CustomStatistic::AchGhast},
+ {"cuberite:achievement.blazeRod", CustomStatistic::AchBlazeRod},
+ {"cuberite:achievement.potion", CustomStatistic::AchPotion},
+ {"cuberite:achievement.theEnd", CustomStatistic::AchTheEnd},
+ {"cuberite:achievement.theEnd2", CustomStatistic::AchTheEnd2},
+ {"cuberite:achievement.enchantments", CustomStatistic::AchEnchantments},
+ {"cuberite:achievement.overkill", CustomStatistic::AchOverkill},
+ {"cuberite:achievement.bookcase", CustomStatistic::AchBookcase},
+ {"cuberite:achievement.exploreAllBiomes", CustomStatistic::AchExploreAllBiomes},
+ {"cuberite:achievement.spawnWither", CustomStatistic::AchSpawnWither},
+ {"cuberite:achievement.killWither", CustomStatistic::AchKillWither},
+ {"cuberite:achievement.fullBeacon", CustomStatistic::AchFullBeacon},
+ {"cuberite:achievement.breedCow", CustomStatistic::AchBreedCow},
+ {"cuberite:achievement.diamondsToYou", CustomStatistic::AchDiamondsToYou}
};
return CustomStatistics.at(ID);
@@ -400,13 +399,15 @@ CustomStatistic NamespaceSerializer::ToCustomStatistic(const std::string_view ID
-std::pair<NamespaceSerializer::Namespace, std::string_view> NamespaceSerializer::SplitNamespacedID(const std::string_view ID)
+std::pair<NamespaceSerializer::Namespace, std::string_view> NamespaceSerializer::SplitNamespacedID(
+ const std::string_view ID
+)
{
const auto NamespaceIndex = ID.find(':');
if (NamespaceIndex == std::string_view::npos)
{
// No explicit namespace defaults to the Minecraft namespace:
- return { Namespace::Minecraft, ID };
+ return {Namespace::Minecraft, ID};
}
const auto Namespace = ID.substr(0, NamespaceIndex);
@@ -415,15 +416,15 @@ std::pair<NamespaceSerializer::Namespace, std::string_view> NamespaceSerializer:
// An unprefixed ID in the vanilla Minecraft namespace.
const auto Value = ID.substr(NamespaceIndex + 1);
- return { Namespace::Minecraft, Value };
+ return {Namespace::Minecraft, Value};
}
if (Namespace == "cuberite")
{
- return { Namespace::Cuberite, ID };
+ return {Namespace::Cuberite, ID};
}
- return { Namespace::Unknown, ID };
+ return {Namespace::Unknown, ID};
}
@@ -432,116 +433,115 @@ std::pair<NamespaceSerializer::Namespace, std::string_view> NamespaceSerializer:
eMonsterType NamespaceSerializer::ToMonsterType(const std::string_view a_ID)
{
- static const std::unordered_map<std::string_view, eMonsterType> MonsterTypes
- {
- { "bat", mtBat },
- { "blaze", mtBlaze },
- { "cat", mtCat },
- { "cave_spider", mtCaveSpider },
- { "chicken", mtChicken },
- { "cod", mtCod },
- { "cow", mtCow },
- { "creeper", mtCreeper },
- { "dolphin", mtDolphin },
- { "donkey", mtDonkey },
- { "drowned", mtDrowned },
- { "elder_guardian", mtElderGuardian },
- { "ender_dragon", mtEnderDragon },
- { "enderman", mtEnderman },
- { "endermite", mtEndermite },
- { "evoker", mtEvoker },
- { "fox", mtFox },
- { "ghast", mtGhast },
- { "giant", mtGiant },
- { "guardian", mtGuardian },
- { "horse", mtHorse },
- { "hoglin", mtHoglin },
- { "husk", mtHusk },
- { "illusioner", mtIllusioner },
- { "iron_golem", mtIronGolem },
- { "llama", mtLlama },
- { "magma_cube", mtMagmaCube },
- { "mooshroom", mtMooshroom },
- { "mule", mtMule },
- { "ocelot", mtOcelot },
- { "panda", mtPanda },
- { "parrot", mtParrot },
- { "phantom", mtPhantom },
- { "pig", mtPig },
- { "piglin", mtPiglin },
- { "piglin_brute", mtPiglinBrute },
- { "pillager", mtPillager },
- { "polar_bear", mtPolarBear },
- { "pufferfish", mtPufferfish },
- { "rabbit", mtRabbit },
- { "ravager", mtRavager },
- { "salmon", mtSalmon },
- { "sheep", mtSheep },
- { "shulker", mtShulker },
- { "silverfish", mtSilverfish },
- { "skeleton", mtSkeleton },
- { "skeleton_horse", mtSkeletonHorse },
- { "slime", mtSlime },
- { "snow_golem", mtSnowGolem },
- { "spider", mtSpider },
- { "squid", mtSquid },
- { "stray", mtStray },
- { "strider", mtStrider },
- { "trader_llama", mtTraderLlama },
- { "tropical_fish", mtTropicalFish },
- { "turtle", mtTurtle },
- { "vex", mtVex },
- { "villager", mtVillager },
- { "vindicator", mtVindicator },
- { "wandering_trader", mtWanderingTrader },
- { "witch", mtWitch },
- { "wither", mtWither },
- { "wither_skeleton", mtWitherSkeleton },
- { "wolf", mtWolf },
- { "zoglin", mtZoglin },
- { "zombie", mtZombie },
- { "zombie_horse", mtZombieHorse },
- { "zombified_piglin", mtZombiePigman },
- { "zombie_villager", mtZombieVillager },
-
- { "snowman", mtSnowGolem },
- { "villager_golem", mtIronGolem },
- { "zombie_pigman", mtZombiePigman },
+ static const std::unordered_map<std::string_view, eMonsterType> MonsterTypes {
+ {"bat", mtBat},
+ {"blaze", mtBlaze},
+ {"cat", mtCat},
+ {"cave_spider", mtCaveSpider},
+ {"chicken", mtChicken},
+ {"cod", mtCod},
+ {"cow", mtCow},
+ {"creeper", mtCreeper},
+ {"dolphin", mtDolphin},
+ {"donkey", mtDonkey},
+ {"drowned", mtDrowned},
+ {"elder_guardian", mtElderGuardian},
+ {"ender_dragon", mtEnderDragon},
+ {"enderman", mtEnderman},
+ {"endermite", mtEndermite},
+ {"evoker", mtEvoker},
+ {"fox", mtFox},
+ {"ghast", mtGhast},
+ {"giant", mtGiant},
+ {"guardian", mtGuardian},
+ {"horse", mtHorse},
+ {"hoglin", mtHoglin},
+ {"husk", mtHusk},
+ {"illusioner", mtIllusioner},
+ {"iron_golem", mtIronGolem},
+ {"llama", mtLlama},
+ {"magma_cube", mtMagmaCube},
+ {"mooshroom", mtMooshroom},
+ {"mule", mtMule},
+ {"ocelot", mtOcelot},
+ {"panda", mtPanda},
+ {"parrot", mtParrot},
+ {"phantom", mtPhantom},
+ {"pig", mtPig},
+ {"piglin", mtPiglin},
+ {"piglin_brute", mtPiglinBrute},
+ {"pillager", mtPillager},
+ {"polar_bear", mtPolarBear},
+ {"pufferfish", mtPufferfish},
+ {"rabbit", mtRabbit},
+ {"ravager", mtRavager},
+ {"salmon", mtSalmon},
+ {"sheep", mtSheep},
+ {"shulker", mtShulker},
+ {"silverfish", mtSilverfish},
+ {"skeleton", mtSkeleton},
+ {"skeleton_horse", mtSkeletonHorse},
+ {"slime", mtSlime},
+ {"snow_golem", mtSnowGolem},
+ {"spider", mtSpider},
+ {"squid", mtSquid},
+ {"stray", mtStray},
+ {"strider", mtStrider},
+ {"trader_llama", mtTraderLlama},
+ {"tropical_fish", mtTropicalFish},
+ {"turtle", mtTurtle},
+ {"vex", mtVex},
+ {"villager", mtVillager},
+ {"vindicator", mtVindicator},
+ {"wandering_trader", mtWanderingTrader},
+ {"witch", mtWitch},
+ {"wither", mtWither},
+ {"wither_skeleton", mtWitherSkeleton},
+ {"wolf", mtWolf},
+ {"zoglin", mtZoglin},
+ {"zombie", mtZombie},
+ {"zombie_horse", mtZombieHorse},
+ {"zombified_piglin", mtZombiePigman},
+ {"zombie_villager", mtZombieVillager},
+
+ {"snowman", mtSnowGolem},
+ {"villager_golem", mtIronGolem},
+ {"zombie_pigman", mtZombiePigman},
// Old names:
- { "Bat", mtBat },
- { "Blaze", mtBlaze },
- { "CaveSpider", mtCaveSpider },
- { "Chicken", mtChicken },
- { "Cow", mtCow },
- { "Creeper", mtCreeper },
- { "EnderDragon", mtEnderDragon },
- { "Enderman", mtEnderman },
- { "Ghast", mtGhast },
- { "Giant", mtGiant },
- { "Guardian", mtGuardian },
- { "Horse", mtHorse },
- { "VillagerGolem", mtIronGolem },
- { "LavaSlime", mtMagmaCube },
- { "MushroomCow", mtMooshroom },
- { "Ozelot", mtOcelot },
- { "Pig", mtPig },
- { "Rabbit", mtRabbit },
- { "Sheep", mtSheep },
- { "Silverfish", mtSilverfish },
- { "Skeleton", mtSkeleton },
- { "Slime", mtSlime },
- { "SnowMan", mtSnowGolem },
- { "Spider", mtSpider },
- { "Squid", mtSquid },
- { "Villager", mtVillager },
- { "Witch", mtWitch },
- { "WitherBoss", mtWither },
- { "WitherSkeleton", mtWitherSkeleton },
- { "Wolf", mtWolf },
- { "Zombie", mtZombie },
- { "PigZombie", mtZombiePigman },
- { "ZombieVillager", mtZombieVillager }
+ {"Bat", mtBat},
+ {"Blaze", mtBlaze},
+ {"CaveSpider", mtCaveSpider},
+ {"Chicken", mtChicken},
+ {"Cow", mtCow},
+ {"Creeper", mtCreeper},
+ {"EnderDragon", mtEnderDragon},
+ {"Enderman", mtEnderman},
+ {"Ghast", mtGhast},
+ {"Giant", mtGiant},
+ {"Guardian", mtGuardian},
+ {"Horse", mtHorse},
+ {"VillagerGolem", mtIronGolem},
+ {"LavaSlime", mtMagmaCube},
+ {"MushroomCow", mtMooshroom},
+ {"Ozelot", mtOcelot},
+ {"Pig", mtPig},
+ {"Rabbit", mtRabbit},
+ {"Sheep", mtSheep},
+ {"Silverfish", mtSilverfish},
+ {"Skeleton", mtSkeleton},
+ {"Slime", mtSlime},
+ {"SnowMan", mtSnowGolem},
+ {"Spider", mtSpider},
+ {"Squid", mtSquid},
+ {"Villager", mtVillager},
+ {"Witch", mtWitch},
+ {"WitherBoss", mtWither},
+ {"WitherSkeleton", mtWitherSkeleton},
+ {"Wolf", mtWolf},
+ {"Zombie", mtZombie},
+ {"PigZombie", mtZombiePigman},
+ {"ZombieVillager", mtZombieVillager}
};
return MonsterTypes.at(a_ID);
@@ -555,19 +555,23 @@ AString NamespaceSerializer::Prettify(AString a_ID)
{
bool NextLetterCapitalized = true;
- std::for_each(a_ID.begin(), a_ID.end(), [&](char & a_Letter)
- {
- if (NextLetterCapitalized)
- {
- a_Letter = static_cast<char>(std::toupper(a_Letter));
- NextLetterCapitalized = false;
- }
- else if (a_Letter == '_')
+ std::for_each(
+ a_ID.begin(),
+ a_ID.end(),
+ [&](char & a_Letter)
{
- a_Letter = ' ';
- NextLetterCapitalized = true;
+ if (NextLetterCapitalized)
+ {
+ a_Letter = static_cast<char>(std::toupper(a_Letter));
+ NextLetterCapitalized = false;
+ }
+ else if (a_Letter == '_')
+ {
+ a_Letter = ' ';
+ NextLetterCapitalized = true;
+ }
}
- });
+ );
return a_ID;
}
diff --git a/src/WorldStorage/NamespaceSerializer.h b/src/WorldStorage/NamespaceSerializer.h
index 625d348be..82d04c14d 100644
--- a/src/WorldStorage/NamespaceSerializer.h
+++ b/src/WorldStorage/NamespaceSerializer.h
@@ -6,25 +6,25 @@
namespace NamespaceSerializer
{
- enum class Namespace
- {
- Minecraft,
- Cuberite,
- Unknown
- };
+enum class Namespace
+{
+ Minecraft,
+ Cuberite,
+ Unknown
+};
- unsigned DataVersion();
+unsigned DataVersion();
- std::string_view From(CustomStatistic a_ID);
- std::string_view From(eMonsterType a_ID);
- std::string_view From(BannerPattern a_ID);
+std::string_view From(CustomStatistic a_ID);
+std::string_view From(eMonsterType a_ID);
+std::string_view From(BannerPattern a_ID);
- CustomStatistic ToCustomStatistic(std::string_view a_ID);
- eMonsterType ToMonsterType(std::string_view a_ID);
+CustomStatistic ToCustomStatistic(std::string_view a_ID);
+eMonsterType ToMonsterType(std::string_view a_ID);
- std::pair<Namespace, std::string_view> SplitNamespacedID(std::string_view ID);
+std::pair<Namespace, std::string_view> SplitNamespacedID(std::string_view ID);
- // Examples: Input: "wolf" -> Output: "Wolf", Input: "iron_golem" -> Output: "Iron Golem"
- AString Prettify(AString a_ID);
- AString PrettifyEntityName(const AString & a_ID, const bool a_IsTamed = false);
-}
+// Examples: Input: "wolf" -> Output: "Wolf", Input: "iron_golem" -> Output: "Iron Golem"
+AString Prettify(AString a_ID);
+AString PrettifyEntityName(const AString & a_ID, const bool a_IsTamed = false);
+} // namespace NamespaceSerializer
diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp
index 656a98709..d808bb53e 100644
--- a/src/WorldStorage/SchematicFileSerializer.cpp
+++ b/src/WorldStorage/SchematicFileSerializer.cpp
@@ -1,7 +1,8 @@
// SchematicFileSerializer.cpp
-// Implements the cSchematicFileSerializer class representing the interface to load and save cBlockArea to a .schematic file
+// Implements the cSchematicFileSerializer class representing the interface to load and save cBlockArea to a .schematic
+// file
#include "Globals.h"
@@ -33,7 +34,10 @@ void cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea & a_BlockArea, c
-void cSchematicFileSerializer::LoadFromSchematicString(cBlockArea & a_BlockArea, const ContiguousByteBufferView a_SchematicData)
+void cSchematicFileSerializer::LoadFromSchematicString(
+ cBlockArea & a_BlockArea,
+ const ContiguousByteBufferView a_SchematicData
+)
{
const auto Extracted = Compression::Extractor().ExtractGZip(a_SchematicData);
const cParsedNBT NBT(Extracted.GetView());
@@ -76,22 +80,23 @@ void cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, co
AString Materials = a_NBT.GetString(TMaterials);
if (Materials.compare("Alpha") != 0)
{
- throw std::runtime_error(fmt::format("Materials tag is present and \"{}\" instead of \"Alpha\". Possibly a wrong-format schematic file.", Materials));
+ throw std::runtime_error(fmt::format(
+ "Materials tag is present and \"{}\" instead of \"Alpha\". Possibly a wrong-format schematic file.",
+ Materials
+ ));
}
}
int TSizeX = a_NBT.FindChildByName(a_NBT.GetRoot(), "Width");
int TSizeY = a_NBT.FindChildByName(a_NBT.GetRoot(), "Height");
int TSizeZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "Length");
- if (
- (TSizeX < 0) || (TSizeY < 0) || (TSizeZ < 0) ||
- (a_NBT.GetType(TSizeX) != TAG_Short) ||
- (a_NBT.GetType(TSizeY) != TAG_Short) ||
- (a_NBT.GetType(TSizeZ) != TAG_Short)
- )
+ if ((TSizeX < 0) || (TSizeY < 0) || (TSizeZ < 0) || (a_NBT.GetType(TSizeX) != TAG_Short) ||
+ (a_NBT.GetType(TSizeY) != TAG_Short) || (a_NBT.GetType(TSizeZ) != TAG_Short))
{
throw std::runtime_error(fmt::format(
"Dimensions are missing from the schematic file ({}, {}, {}), ({}, {}, {})",
- TSizeX, TSizeY, TSizeZ,
+ TSizeX,
+ TSizeY,
+ TSizeZ,
(TSizeX >= 0) ? a_NBT.GetType(TSizeX) : -1,
(TSizeY >= 0) ? a_NBT.GetType(TSizeY) : -1,
(TSizeZ >= 0) ? a_NBT.GetType(TSizeZ) : -1
@@ -103,7 +108,9 @@ void cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, co
int SizeZ = a_NBT.GetShort(TSizeZ);
if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > 65535) || (SizeZ < 1) || (SizeZ > 65535))
{
- throw std::runtime_error(fmt::format("Dimensions are invalid in the schematic file: {}, {}, {}", SizeX, SizeY, SizeZ));
+ throw std::runtime_error(
+ fmt::format("Dimensions are invalid in the schematic file: {}, {}, {}", SizeX, SizeY, SizeZ)
+ );
}
int TBlockTypes = a_NBT.FindChildByName(a_NBT.GetRoot(), "Blocks");
@@ -115,18 +122,19 @@ void cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, co
bool AreMetasPresent = (TBlockMetas > 0) && (a_NBT.GetType(TBlockMetas) == TAG_ByteArray);
a_BlockArea.Clear();
- a_BlockArea.SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (cBlockArea::baTypes | cBlockArea::baMetas) : cBlockArea::baTypes);
+ a_BlockArea.SetSize(
+ SizeX,
+ SizeY,
+ SizeZ,
+ AreMetasPresent ? (cBlockArea::baTypes | cBlockArea::baMetas) : cBlockArea::baTypes
+ );
int TOffsetX = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetX");
int TOffsetY = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetY");
int TOffsetZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetZ");
- if (
- (TOffsetX < 0) || (TOffsetY < 0) || (TOffsetZ < 0) ||
- (a_NBT.GetType(TOffsetX) != TAG_Int) ||
- (a_NBT.GetType(TOffsetY) != TAG_Int) ||
- (a_NBT.GetType(TOffsetZ) != TAG_Int)
- )
+ if ((TOffsetX < 0) || (TOffsetY < 0) || (TOffsetZ < 0) || (a_NBT.GetType(TOffsetX) != TAG_Int) ||
+ (a_NBT.GetType(TOffsetY) != TAG_Int) || (a_NBT.GetType(TOffsetZ) != TAG_Int))
{
// Not every schematic file has an offset, so we shoudn't give a warn message.
a_BlockArea.SetWEOffset(0, 0, 0);
@@ -141,8 +149,8 @@ void cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, co
if (a_NBT.GetDataLength(TBlockTypes) < NumTypeBytes)
{
LOG("BlockTypes truncated in the schematic file (exp %u, got %u bytes). Loading partial.",
- static_cast<unsigned>(NumTypeBytes), static_cast<unsigned>(a_NBT.GetDataLength(TBlockTypes))
- );
+ static_cast<unsigned>(NumTypeBytes),
+ static_cast<unsigned>(a_NBT.GetDataLength(TBlockTypes)));
NumTypeBytes = a_NBT.GetDataLength(TBlockTypes);
}
memcpy(a_BlockArea.GetBlockTypes(), a_NBT.GetData(TBlockTypes), NumTypeBytes);
@@ -153,8 +161,8 @@ void cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, co
if (a_NBT.GetDataLength(TBlockMetas) < NumMetaBytes)
{
LOG("BlockMetas truncated in the schematic file (exp %u, got %u bytes). Loading partial.",
- static_cast<unsigned>(NumMetaBytes), static_cast<unsigned>(a_NBT.GetDataLength(TBlockMetas))
- );
+ static_cast<unsigned>(NumMetaBytes),
+ static_cast<unsigned>(a_NBT.GetDataLength(TBlockMetas)));
NumMetaBytes = a_NBT.GetDataLength(TBlockMetas);
}
memcpy(a_BlockArea.GetBlockMetas(), a_NBT.GetData(TBlockMetas), NumMetaBytes);
@@ -168,13 +176,17 @@ void cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, co
ContiguousByteBuffer cSchematicFileSerializer::SaveToSchematicNBT(const cBlockArea & a_BlockArea)
{
cFastNBTWriter Writer("Schematic");
- Writer.AddShort("Width", static_cast<Int16>(a_BlockArea.m_Size.x));
+ Writer.AddShort("Width", static_cast<Int16>(a_BlockArea.m_Size.x));
Writer.AddShort("Height", static_cast<Int16>(a_BlockArea.m_Size.y));
Writer.AddShort("Length", static_cast<Int16>(a_BlockArea.m_Size.z));
Writer.AddString("Materials", "Alpha");
if (a_BlockArea.HasBlockTypes())
{
- Writer.AddByteArray("Blocks", reinterpret_cast<const char *>(a_BlockArea.GetBlockTypes()), a_BlockArea.GetBlockCount());
+ Writer.AddByteArray(
+ "Blocks",
+ reinterpret_cast<const char *>(a_BlockArea.GetBlockTypes()),
+ a_BlockArea.GetBlockCount()
+ );
}
else
{
@@ -183,7 +195,11 @@ ContiguousByteBuffer cSchematicFileSerializer::SaveToSchematicNBT(const cBlockAr
}
if (a_BlockArea.HasBlockMetas())
{
- Writer.AddByteArray("Data", reinterpret_cast<const char *>(a_BlockArea.GetBlockMetas()), a_BlockArea.GetBlockCount());
+ Writer.AddByteArray(
+ "Data",
+ reinterpret_cast<const char *>(a_BlockArea.GetBlockMetas()),
+ a_BlockArea.GetBlockCount()
+ );
}
else
{
diff --git a/src/WorldStorage/SchematicFileSerializer.h b/src/WorldStorage/SchematicFileSerializer.h
index d52f80da1..c8510ba6b 100644
--- a/src/WorldStorage/SchematicFileSerializer.h
+++ b/src/WorldStorage/SchematicFileSerializer.h
@@ -1,7 +1,8 @@
// SchematicFileSerializer.h
-// Declares the cSchematicFileSerializer class representing the interface to load and save cBlockArea to a .schematic file
+// Declares the cSchematicFileSerializer class representing the interface to load and save cBlockArea to a .schematic
+// file
@@ -25,8 +26,7 @@ class cParsedNBT;
class cSchematicFileSerializer
{
-public:
-
+ public:
/** Loads an area from a .schematic file. */
static void LoadFromSchematicFile(cBlockArea & a_BlockArea, const std::string & a_FileName);
@@ -39,8 +39,7 @@ public:
/** Saves the area into a string containing the .schematic file data. */
static Compression::Result SaveToSchematicString(const cBlockArea & a_BlockArea);
-private:
-
+ private:
/** Loads the area from a schematic file uncompressed and parsed into a NBT tree. */
static void LoadFromSchematicNBT(cBlockArea & a_BlockArea, const cParsedNBT & a_NBT);
diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp
index e6e639bcb..c2084ba63 100644
--- a/src/WorldStorage/ScoreboardSerializer.cpp
+++ b/src/WorldStorage/ScoreboardSerializer.cpp
@@ -13,7 +13,7 @@
-cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScoreboard * a_ScoreBoard):
+cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScoreboard * a_ScoreBoard) :
m_ScoreBoard(a_ScoreBoard)
{
auto DataPath = fmt::format(FMT_STRING("{}{}data"), a_WorldName, cFile::PathSeparator());
@@ -77,7 +77,9 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
a_Writer.BeginList("Objectives", TAG_Compound);
- for (cScoreboard::cObjectiveMap::const_iterator it = m_ScoreBoard->m_Objectives.begin(); it != m_ScoreBoard->m_Objectives.end(); ++it)
+ for (cScoreboard::cObjectiveMap::const_iterator it = m_ScoreBoard->m_Objectives.begin();
+ it != m_ScoreBoard->m_Objectives.end();
+ ++it)
{
const cObjective & Objective = it->second;
@@ -95,11 +97,14 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
a_Writer.BeginList("PlayerScores", TAG_Compound);
- for (cScoreboard::cObjectiveMap::const_iterator it = m_ScoreBoard->m_Objectives.begin(); it != m_ScoreBoard->m_Objectives.end(); ++it)
+ for (cScoreboard::cObjectiveMap::const_iterator it = m_ScoreBoard->m_Objectives.begin();
+ it != m_ScoreBoard->m_Objectives.end();
+ ++it)
{
const cObjective & Objective = it->second;
- for (cObjective::cScoreMap::const_iterator it2 = Objective.m_Scores.begin(); it2 != Objective.m_Scores.end(); ++it2)
+ for (cObjective::cScoreMap::const_iterator it2 = Objective.m_Scores.begin(); it2 != Objective.m_Scores.end();
+ ++it2)
{
a_Writer.BeginCompound("");
@@ -116,13 +121,14 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
a_Writer.BeginList("Teams", TAG_Compound);
- for (cScoreboard::cTeamMap::const_iterator it = m_ScoreBoard->m_Teams.begin(); it != m_ScoreBoard->m_Teams.end(); ++it)
+ for (cScoreboard::cTeamMap::const_iterator it = m_ScoreBoard->m_Teams.begin(); it != m_ScoreBoard->m_Teams.end();
+ ++it)
{
const cTeam & Team = it->second;
a_Writer.BeginCompound("");
- a_Writer.AddByte("AllowFriendlyFire", Team.AllowsFriendlyFire() ? 1 : 0);
+ a_Writer.AddByte("AllowFriendlyFire", Team.AllowsFriendlyFire() ? 1 : 0);
a_Writer.AddByte("SeeFriendlyInvisibles", Team.CanSeeFriendlyInvisible() ? 1 : 0);
a_Writer.AddString("DisplayName", Team.GetDisplayName());
@@ -341,11 +347,3 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
return true;
}
-
-
-
-
-
-
-
-
diff --git a/src/WorldStorage/ScoreboardSerializer.h b/src/WorldStorage/ScoreboardSerializer.h
index 8b3a2c8b6..c68d26c38 100644
--- a/src/WorldStorage/ScoreboardSerializer.h
+++ b/src/WorldStorage/ScoreboardSerializer.h
@@ -23,8 +23,7 @@ class cScoreboard;
class cScoreboardSerializer
{
-public:
-
+ public:
cScoreboardSerializer(const AString & a_WorldName, cScoreboard * a_ScoreBoard);
/** Try to load the scoreboard */
@@ -34,8 +33,7 @@ public:
bool Save(void);
-private:
-
+ private:
void SaveScoreboardToNBT(cFastNBTWriter & a_Writer);
bool LoadScoreboardFromNBT(const cParsedNBT & a_NBT);
@@ -43,10 +41,4 @@ private:
cScoreboard * m_ScoreBoard;
AString m_Path;
-
-
-} ;
-
-
-
-
+};
diff --git a/src/WorldStorage/StatisticsSerializer.cpp b/src/WorldStorage/StatisticsSerializer.cpp
index 5143e174d..2e68188a2 100644
--- a/src/WorldStorage/StatisticsSerializer.cpp
+++ b/src/WorldStorage/StatisticsSerializer.cpp
@@ -83,7 +83,11 @@ void StatisticsSerializer::Load(StatisticsManager & Manager, const std::string &
-void StatisticsSerializer::Save(const StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName)
+void StatisticsSerializer::Save(
+ const StatisticsManager & Manager,
+ const std::string & WorldPath,
+ std::string && FileName
+)
{
Json::Value Root;
diff --git a/src/WorldStorage/StatisticsSerializer.h b/src/WorldStorage/StatisticsSerializer.h
index 1ccc55dbd..5d6c50b83 100644
--- a/src/WorldStorage/StatisticsSerializer.h
+++ b/src/WorldStorage/StatisticsSerializer.h
@@ -14,7 +14,10 @@
struct StatisticsManager;
-namespace Json { class Value; }
+namespace Json
+{
+class Value;
+}
@@ -22,9 +25,9 @@ namespace Json { class Value; }
namespace StatisticsSerializer
{
- /* Try to load the player statistics. */
- void Load(StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName);
+/* Try to load the player statistics. */
+void Load(StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName);
- /* Try to save the player statistics. */
- void Save(const StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName);
-}
+/* Try to save the player statistics. */
+void Save(const StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName);
+} // namespace StatisticsSerializer
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 6b425c4dc..a45321a3f 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -80,9 +80,8 @@ Since only the header is actually in the memory, this number can be high, but st
////////////////////////////////////////////////////////////////////////////////
// cWSSAnvil:
-cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor):
- Super(a_World),
- m_Compressor(a_CompressionFactor)
+cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
+ Super(a_World), m_Compressor(a_CompressionFactor)
{
// Create a level.dat file for mapping tools, if it doesn't already exist:
auto fnam = fmt::format(FMT_STRING("{}{}level.dat"), a_World->GetDataPath(), cFile::PathSeparator());
@@ -170,30 +169,48 @@ bool cWSSAnvil::SaveChunk(const cChunkCoords & a_Chunk)
-void cWSSAnvil::ChunkLoadFailed(const cChunkCoords a_ChunkCoords, const AString & a_Reason, const ContiguousByteBufferView a_ChunkDataToSave)
+void cWSSAnvil::ChunkLoadFailed(
+ const cChunkCoords a_ChunkCoords,
+ const AString & a_Reason,
+ const ContiguousByteBufferView a_ChunkDataToSave
+)
{
// Construct the filename for offloading:
- auto OffloadFileName = fmt::format(FMT_STRING("{0}{1}region{1}badchunks"), m_World->GetDataPath(), cFile::PathSeparator());
+ auto OffloadFileName =
+ fmt::format(FMT_STRING("{0}{1}region{1}badchunks"), m_World->GetDataPath(), cFile::PathSeparator());
cFile::CreateFolder(OffloadFileName);
auto t = time(nullptr);
struct tm stm;
- #ifdef _MSC_VER
- localtime_s(&stm, &t);
- #else
- localtime_r(&t, &stm);
- #endif
+#ifdef _MSC_VER
+ localtime_s(&stm, &t);
+#else
+ localtime_r(&t, &stm);
+#endif
OffloadFileName.append(fmt::format(
FMT_STRING("{}ch.{}.{}.{}-{:02d}-{:02d}-{:02d}-{:02d}-{:02d}.dat"),
- cFile::PathSeparator(), a_ChunkCoords.m_ChunkX, a_ChunkCoords.m_ChunkZ,
- stm.tm_year + 1900, stm.tm_mon + 1, stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec
+ cFile::PathSeparator(),
+ a_ChunkCoords.m_ChunkX,
+ a_ChunkCoords.m_ChunkZ,
+ stm.tm_year + 1900,
+ stm.tm_mon + 1,
+ stm.tm_mday,
+ stm.tm_hour,
+ stm.tm_min,
+ stm.tm_sec
));
// Log the warning to console:
const int RegionX = FAST_FLOOR_DIV(a_ChunkCoords.m_ChunkX, 32);
const int RegionZ = FAST_FLOOR_DIV(a_ChunkCoords.m_ChunkZ, 32);
auto Info = fmt::format(
- FMT_STRING("Loading chunk {} for world {} from file r.{}.{}.mca failed: {} Offloading old chunk data to file {} and regenerating chunk."),
- a_ChunkCoords, m_World->GetName(), RegionX, RegionZ, a_Reason, OffloadFileName
+ FMT_STRING("Loading chunk {} for world {} from file r.{}.{}.mca failed: {} Offloading old chunk data to file "
+ "{} and regenerating chunk."),
+ a_ChunkCoords,
+ m_World->GetName(),
+ RegionX,
+ RegionZ,
+ a_Reason,
+ OffloadFileName
);
LOGWARNING("%s", Info);
@@ -210,7 +227,10 @@ void cWSSAnvil::ChunkLoadFailed(const cChunkCoords a_ChunkCoords, const AString
// Write a description file:
if (!f.Open(OffloadFileName + ".info", cFile::fmWrite))
{
- LOGWARNING("Cannot open file %s.info for writing! The information about the failed chunk will not be written.", OffloadFileName);
+ LOGWARNING(
+ "Cannot open file %s.info for writing! The information about the failed chunk will not be written.",
+ OffloadFileName
+ );
return;
}
f.Write(Info.c_str(), Info.size());
@@ -312,7 +332,9 @@ bool cWSSAnvil::LoadChunkFromData(const cChunkCoords & a_Chunk, const Contiguous
if (!NBT.IsValid())
{
// NBT Parsing failed:
- throw std::runtime_error(fmt::format("NBT parsing failed. {} at position {}.", NBT.GetErrorCode().message(), NBT.GetErrorPos()));
+ throw std::runtime_error(
+ fmt::format("NBT parsing failed. {} at position {}.", NBT.GetErrorCode().message(), NBT.GetErrorPos())
+ );
}
// Load the data from NBT:
@@ -342,7 +364,11 @@ Compression::Result cWSSAnvil::SaveChunkToData(const cChunkCoords & a_Chunk)
-bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT & a_NBT, const ContiguousByteBufferView a_RawChunkData)
+bool cWSSAnvil::LoadChunkFromNBT(
+ const cChunkCoords & a_Chunk,
+ const cParsedNBT & a_NBT,
+ const ContiguousByteBufferView a_RawChunkData
+)
{
struct SetChunkData Data(a_Chunk);
@@ -383,15 +409,22 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
return false;
}
- const auto
- BlockData = GetSectionData(a_NBT, Child, "Blocks", ChunkBlockData::SectionBlockCount),
- MetaData = GetSectionData(a_NBT, Child, "Data", ChunkBlockData::SectionMetaCount),
- BlockLightData = GetSectionData(a_NBT, Child, "BlockLight", ChunkLightData::SectionLightCount),
- SkyLightData = GetSectionData(a_NBT, Child, "SkyLight", ChunkLightData::SectionLightCount);
+ const auto BlockData = GetSectionData(a_NBT, Child, "Blocks", ChunkBlockData::SectionBlockCount),
+ MetaData = GetSectionData(a_NBT, Child, "Data", ChunkBlockData::SectionMetaCount),
+ BlockLightData = GetSectionData(a_NBT, Child, "BlockLight", ChunkLightData::SectionLightCount),
+ SkyLightData = GetSectionData(a_NBT, Child, "SkyLight", ChunkLightData::SectionLightCount);
if ((BlockData != nullptr) && (MetaData != nullptr) && (SkyLightData != nullptr) && (BlockLightData != nullptr))
{
- Data.BlockData.SetSection(*reinterpret_cast<const ChunkBlockData::SectionType *>(BlockData), *reinterpret_cast<const ChunkBlockData::SectionMetaType *>(MetaData), static_cast<size_t>(Y));
- Data.LightData.SetSection(*reinterpret_cast<const ChunkLightData::SectionType *>(BlockLightData), *reinterpret_cast<const ChunkLightData::SectionType *>(SkyLightData), static_cast<size_t>(Y));
+ Data.BlockData.SetSection(
+ *reinterpret_cast<const ChunkBlockData::SectionType *>(BlockData),
+ *reinterpret_cast<const ChunkBlockData::SectionMetaType *>(MetaData),
+ static_cast<size_t>(Y)
+ );
+ Data.LightData.SetSection(
+ *reinterpret_cast<const ChunkLightData::SectionType *>(BlockLightData),
+ *reinterpret_cast<const ChunkLightData::SectionType *>(SkyLightData),
+ static_cast<size_t>(Y)
+ );
}
else
{
@@ -414,7 +447,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
}
// Load the entities from NBT:
- LoadEntitiesFromNBT (Data.Entities, a_NBT, a_NBT.FindChildByName(Level, "Entities"));
+ LoadEntitiesFromNBT(Data.Entities, a_NBT, a_NBT.FindChildByName(Level, "Entities"));
LoadBlockEntitiesFromNBT(Data.BlockEntities, a_NBT, a_NBT.FindChildByName(Level, "TileEntities"), Data.BlockData);
Data.IsLightValid = (a_NBT.FindChildByName(Level, "MCSIsLightValid") > 0);
@@ -465,11 +498,8 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
bool cWSSAnvil::LoadBiomeMapFromNBT(cChunkDef::BiomeMap & a_BiomeMap, const cParsedNBT & a_NBT, const int a_TagIdx)
{
- if (
- (a_TagIdx < 0) ||
- (a_NBT.GetType(a_TagIdx) != TAG_ByteArray) ||
- (a_NBT.GetDataLength(a_TagIdx) != std::size(a_BiomeMap))
- )
+ if ((a_TagIdx < 0) || (a_NBT.GetType(a_TagIdx) != TAG_ByteArray) ||
+ (a_NBT.GetDataLength(a_TagIdx) != std::size(a_BiomeMap)))
{
return false;
}
@@ -495,11 +525,8 @@ bool cWSSAnvil::LoadBiomeMapFromNBT(cChunkDef::BiomeMap & a_BiomeMap, const cPar
bool cWSSAnvil::LoadHeightMapFromNBT(cChunkDef::HeightMap & a_HeightMap, const cParsedNBT & a_NBT, const int a_TagIdx)
{
- if (
- (a_TagIdx < 0) ||
- (a_NBT.GetType(a_TagIdx) != TAG_IntArray) ||
- (a_NBT.GetDataLength(a_TagIdx) != (4 * std::size(a_HeightMap)))
- )
+ if ((a_TagIdx < 0) || (a_NBT.GetType(a_TagIdx) != TAG_IntArray) ||
+ (a_NBT.GetDataLength(a_TagIdx) != (4 * std::size(a_HeightMap))))
{
return false;
}
@@ -563,7 +590,12 @@ void cWSSAnvil::LoadEntitiesFromNBT(cEntityList & a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntities & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, const ChunkBlockData & a_BlockData)
+void cWSSAnvil::LoadBlockEntitiesFromNBT(
+ cBlockEntities & a_BlockEntities,
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ const ChunkBlockData & a_BlockData
+)
{
if ((a_TagIdx < 0) || (a_NBT.GetType(a_TagIdx) != TAG_List))
{
@@ -618,7 +650,13 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntities & a_BlockEntities, const
-OwnedBlockEntity cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int a_Tag, Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+OwnedBlockEntity cWSSAnvil::LoadBlockEntityFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_Tag,
+ Vector3i a_Pos,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta
+)
{
ASSERT((a_Pos.y >= 0) && (a_Pos.y < cChunkDef::Height));
@@ -627,38 +665,43 @@ OwnedBlockEntity cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int
{
// Banners:
case E_BLOCK_STANDING_BANNER:
- case E_BLOCK_WALL_BANNER: return LoadBannerFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_WALL_BANNER: return LoadBannerFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
// Others:
- case E_BLOCK_BEACON: return LoadBeaconFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_BED: return LoadBedFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_BREWING_STAND: return LoadBrewingstandFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_CHEST: return LoadChestFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_COMMAND_BLOCK: return LoadCommandBlockFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_DISPENSER: return LoadDispenserFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_DROPPER: return LoadDropperFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_ENCHANTMENT_TABLE: return LoadEnchantingTableFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_ENDER_CHEST: return LoadEnderChestFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_END_PORTAL: return LoadEndPortalFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_FLOWER_POT: return LoadFlowerPotFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_FURNACE: return LoadFurnaceFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_HEAD: return LoadMobHeadFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_HOPPER: return LoadHopperFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_JUKEBOX: return LoadJukeboxFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_LIT_FURNACE: return LoadFurnaceFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_MOB_SPAWNER: return LoadMobSpawnerFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_NOTE_BLOCK: return LoadNoteBlockFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_SIGN_POST: return LoadSignFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_TRAPPED_CHEST: return LoadChestFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
- case E_BLOCK_WALLSIGN: return LoadSignFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_BEACON: return LoadBeaconFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_BED: return LoadBedFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_BREWING_STAND: return LoadBrewingstandFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_CHEST: return LoadChestFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_COMMAND_BLOCK: return LoadCommandBlockFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_DISPENSER: return LoadDispenserFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_DROPPER: return LoadDropperFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_ENCHANTMENT_TABLE:
+ return LoadEnchantingTableFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_ENDER_CHEST: return LoadEnderChestFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_END_PORTAL: return LoadEndPortalFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_FLOWER_POT: return LoadFlowerPotFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_FURNACE: return LoadFurnaceFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_HEAD: return LoadMobHeadFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_HOPPER: return LoadHopperFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_JUKEBOX: return LoadJukeboxFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_LIT_FURNACE: return LoadFurnaceFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_MOB_SPAWNER: return LoadMobSpawnerFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_NOTE_BLOCK: return LoadNoteBlockFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_SIGN_POST: return LoadSignFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_TRAPPED_CHEST: return LoadChestFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+ case E_BLOCK_WALLSIGN: return LoadSignFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
default:
{
// All the other blocktypes should have no entities assigned to them. Report an error:
// Get the "id" tag:
int TagID = a_NBT.FindChildByName(a_Tag, "id");
- FLOGINFO("WorldLoader({0}): Block entity mismatch: block type {1} ({2}), type \"{3}\", at {4}; the entity will be lost.",
+ FLOGINFO(
+ "WorldLoader({0}): Block entity mismatch: block type {1} ({2}), type \"{3}\", at {4}; the entity will "
+ "be lost.",
m_World->GetName(),
- ItemTypeToString(a_BlockType), a_BlockType, (TagID >= 0) ? a_NBT.GetStringView(TagID) : "unknown",
+ ItemTypeToString(a_BlockType),
+ a_BlockType,
+ (TagID >= 0) ? a_NBT.GetStringView(TagID) : "unknown",
a_Pos
);
return nullptr;
@@ -747,7 +790,8 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
{
// Lore table
a_Item.m_LoreTable.clear();
- for (int loretag = a_NBT.GetFirstChild(Lore); loretag >= 0; loretag = a_NBT.GetNextSibling(loretag)) // Loop through array of strings
+ for (int loretag = a_NBT.GetFirstChild(Lore); loretag >= 0;
+ loretag = a_NBT.GetNextSibling(loretag)) // Loop through array of strings
{
a_Item.m_LoreTable.push_back(a_NBT.GetString(loretag));
}
@@ -763,10 +807,16 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
}
// Load firework data:
- int FireworksTag = a_NBT.FindChildByName(TagTag, ((a_Item.m_ItemType == E_ITEM_FIREWORK_STAR) ? "Explosion" : "Fireworks"));
+ int FireworksTag =
+ a_NBT.FindChildByName(TagTag, ((a_Item.m_ItemType == E_ITEM_FIREWORK_STAR) ? "Explosion" : "Fireworks"));
if (FireworksTag > 0)
{
- cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, static_cast<ENUM_ITEM_TYPE>(a_Item.m_ItemType));
+ cFireworkItem::ParseFromNBT(
+ a_Item.m_FireworkItem,
+ a_NBT,
+ FireworksTag,
+ static_cast<ENUM_ITEM_TYPE>(a_Item.m_ItemType)
+ );
}
return true;
@@ -776,7 +826,12 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
-void cWSSAnvil::LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int a_SlotOffset)
+void cWSSAnvil::LoadItemGridFromNBT(
+ cItemGrid & a_ItemGrid,
+ const cParsedNBT & a_NBT,
+ int a_ItemsTagIdx,
+ int a_SlotOffset
+)
{
int NumSlots = a_ItemGrid.GetNumSlots();
for (int Child = a_NBT.GetFirstChild(a_ItemsTagIdx); Child != -1; Child = a_NBT.GetNextSibling(Child))
@@ -833,7 +888,12 @@ AString cWSSAnvil::DecodeSignLine(const AString & a_Line)
-bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, const AStringVector & a_ExpectedTypes, Vector3i a_Pos)
+bool cWSSAnvil::CheckBlockEntityType(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ const AStringVector & a_ExpectedTypes,
+ Vector3i a_Pos
+)
{
// Check if the given tag is a compound:
if (a_NBT.GetType(a_TagIdx) != TAG_Compound)
@@ -855,7 +915,7 @@ bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, con
}
// Compare the value:
- for (const auto & et: a_ExpectedTypes)
+ for (const auto & et : a_ExpectedTypes)
{
if (a_NBT.GetStringView(TagID) == et)
{
@@ -871,9 +931,11 @@ bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, con
expectedTypes.append(et);
expectedTypes.push_back('\"');
}
- FLOGWARNING("Block entity type mismatch: exp {0}, got \"{1}\". The block entity at {2} will lose all its properties.",
+ FLOGWARNING(
+ "Block entity type mismatch: exp {0}, got \"{1}\". The block entity at {2} will lose all its properties.",
expectedTypes.c_str() + 2, // Skip the first ", " that is extra in the string
- a_NBT.GetStringView(TagID), a_Pos
+ a_NBT.GetStringView(TagID),
+ a_Pos
);
return false;
}
@@ -882,9 +944,15 @@ bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, con
-OwnedBlockEntity cWSSAnvil::LoadBannerFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadBannerFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
- static const AStringVector expectedTypes({"Banner", "minecraft:standingbanner","minecraft:wallbanner"});
+ static const AStringVector expectedTypes({"Banner", "minecraft:standingbanner", "minecraft:wallbanner"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -913,7 +981,13 @@ OwnedBlockEntity cWSSAnvil::LoadBannerFromNBT(const cParsedNBT & a_NBT, int a_Ta
-OwnedBlockEntity cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadBeaconFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
static const AStringVector expectedTypes({"Beacon", "minecraft:beacon"});
@@ -956,10 +1030,16 @@ OwnedBlockEntity cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_Ta
-OwnedBlockEntity cWSSAnvil::LoadBedFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadBedFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Bed", "minecraft:bed" });
+ static const AStringVector expectedTypes({"Bed", "minecraft:bed"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -981,10 +1061,16 @@ OwnedBlockEntity cWSSAnvil::LoadBedFromNBT(const cParsedNBT & a_NBT, int a_TagId
-OwnedBlockEntity cWSSAnvil::LoadBrewingstandFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadBrewingstandFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Brewingstand", "minecraft:brewing_stand" });
+ static const AStringVector expectedTypes({"Brewingstand", "minecraft:brewing_stand"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -993,7 +1079,8 @@ OwnedBlockEntity cWSSAnvil::LoadBrewingstandFromNBT(const cParsedNBT & a_NBT, in
int Items = a_NBT.FindChildByName(a_TagIdx, "Items");
if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List))
{
- return nullptr; // Make it an empty brewingstand - the chunk loader will provide an empty cBrewingstandEntity for this
+ return nullptr; // Make it an empty brewingstand - the chunk loader will provide an empty cBrewingstandEntity
+ // for this
}
auto Brewingstand = std::make_unique<cBrewingstandEntity>(a_BlockType, a_BlockMeta, a_Pos, m_World);
@@ -1039,11 +1126,18 @@ OwnedBlockEntity cWSSAnvil::LoadBrewingstandFromNBT(const cParsedNBT & a_NBT, in
-OwnedBlockEntity cWSSAnvil::LoadChestFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadChestFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- // Note that older Cuberite code used "TrappedChest" for trapped chests; new code mimics vanilla and uses "Chest" throughout, but we allow migration here:
- static const AStringVector expectedTypes({ "Chest", "TrappedChest", "minecraft:chest" });
+ // Note that older Cuberite code used "TrappedChest" for trapped chests; new code mimics vanilla and uses "Chest"
+ // throughout, but we allow migration here:
+ static const AStringVector expectedTypes({"Chest", "TrappedChest", "minecraft:chest"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1063,10 +1157,16 @@ OwnedBlockEntity cWSSAnvil::LoadChestFromNBT(const cParsedNBT & a_NBT, int a_Tag
-OwnedBlockEntity cWSSAnvil::LoadCommandBlockFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadCommandBlockFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Control", "minecraft:command_block" });
+ static const AStringVector expectedTypes({"Control", "minecraft:command_block"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1101,10 +1201,16 @@ OwnedBlockEntity cWSSAnvil::LoadCommandBlockFromNBT(const cParsedNBT & a_NBT, in
-OwnedBlockEntity cWSSAnvil::LoadDispenserFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadDispenserFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Trap", "minecraft:dispenser" });
+ static const AStringVector expectedTypes({"Trap", "minecraft:dispenser"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1113,7 +1219,8 @@ OwnedBlockEntity cWSSAnvil::LoadDispenserFromNBT(const cParsedNBT & a_NBT, int a
int Items = a_NBT.FindChildByName(a_TagIdx, "Items");
if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List))
{
- return nullptr; // Make it an empty dispenser - the chunk loader will provide an empty cDispenserEntity for this
+ return nullptr; // Make it an empty dispenser - the chunk loader will provide an empty cDispenserEntity for
+ // this
}
auto Dispenser = std::make_unique<cDispenserEntity>(a_BlockType, a_BlockMeta, a_Pos, m_World);
LoadItemGridFromNBT(Dispenser->GetContents(), a_NBT, Items);
@@ -1124,10 +1231,16 @@ OwnedBlockEntity cWSSAnvil::LoadDispenserFromNBT(const cParsedNBT & a_NBT, int a
-OwnedBlockEntity cWSSAnvil::LoadDropperFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadDropperFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Dropper", "minecraft:dropper" });
+ static const AStringVector expectedTypes({"Dropper", "minecraft:dropper"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1147,10 +1260,16 @@ OwnedBlockEntity cWSSAnvil::LoadDropperFromNBT(const cParsedNBT & a_NBT, int a_T
-OwnedBlockEntity cWSSAnvil::LoadEnchantingTableFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadEnchantingTableFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "EnchantingTable", "minecraft:enchanting_table" });
+ static const AStringVector expectedTypes({"EnchantingTable", "minecraft:enchanting_table"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1172,10 +1291,16 @@ OwnedBlockEntity cWSSAnvil::LoadEnchantingTableFromNBT(const cParsedNBT & a_NBT,
-OwnedBlockEntity cWSSAnvil::LoadEnderChestFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadEnderChestFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "EnderChest", "minecraft:ender_chest" });
+ static const AStringVector expectedTypes({"EnderChest", "minecraft:ender_chest"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1187,10 +1312,16 @@ OwnedBlockEntity cWSSAnvil::LoadEnderChestFromNBT(const cParsedNBT & a_NBT, int
-OwnedBlockEntity cWSSAnvil::LoadEndPortalFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadEndPortalFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "EndPortal", "minecraft:end_portal" });
+ static const AStringVector expectedTypes({"EndPortal", "minecraft:end_portal"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1202,10 +1333,16 @@ OwnedBlockEntity cWSSAnvil::LoadEndPortalFromNBT(const cParsedNBT & a_NBT, int a
-OwnedBlockEntity cWSSAnvil::LoadFlowerPotFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadFlowerPotFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "FlowerPot", "minecraft:flower_pot" });
+ static const AStringVector expectedTypes({"FlowerPot", "minecraft:flower_pot"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1241,10 +1378,16 @@ OwnedBlockEntity cWSSAnvil::LoadFlowerPotFromNBT(const cParsedNBT & a_NBT, int a
-OwnedBlockEntity cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadFurnaceFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Furnace", "minecraft:furnace" });
+ static const AStringVector expectedTypes({"Furnace", "minecraft:furnace"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1301,10 +1444,16 @@ OwnedBlockEntity cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_T
-OwnedBlockEntity cWSSAnvil::LoadHopperFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadHopperFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Hopper", "minecraft:hopper" });
+ static const AStringVector expectedTypes({"Hopper", "minecraft:hopper"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1324,10 +1473,16 @@ OwnedBlockEntity cWSSAnvil::LoadHopperFromNBT(const cParsedNBT & a_NBT, int a_Ta
-OwnedBlockEntity cWSSAnvil::LoadJukeboxFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadJukeboxFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "RecordPlayer", "minecraft:jukebox" });
+ static const AStringVector expectedTypes({"RecordPlayer", "minecraft:jukebox"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1346,10 +1501,16 @@ OwnedBlockEntity cWSSAnvil::LoadJukeboxFromNBT(const cParsedNBT & a_NBT, int a_T
-OwnedBlockEntity cWSSAnvil::LoadMobSpawnerFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadMobSpawnerFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "MobSpawner", "minecraft:mob_spawner" });
+ static const AStringVector expectedTypes({"MobSpawner", "minecraft:mob_spawner"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1430,10 +1591,16 @@ OwnedBlockEntity cWSSAnvil::LoadMobSpawnerFromNBT(const cParsedNBT & a_NBT, int
-OwnedBlockEntity cWSSAnvil::LoadMobHeadFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadMobHeadFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Skull", "minecraft:skull" });
+ static const AStringVector expectedTypes({"Skull", "minecraft:skull"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1472,9 +1639,9 @@ OwnedBlockEntity cWSSAnvil::LoadMobHeadFromNBT(const cParsedNBT & a_NBT, int a_T
}
int textureLine = a_NBT.GetFirstChild( // The first texture of
- a_NBT.FindChildByName( // The texture list of
- a_NBT.FindChildByName( // The Properties compound of
- ownerLine, // The Owner compound
+ a_NBT.FindChildByName( // The texture list of
+ a_NBT.FindChildByName( // The Properties compound of
+ ownerLine, // The Owner compound
"Properties"
),
"textures"
@@ -1504,10 +1671,16 @@ OwnedBlockEntity cWSSAnvil::LoadMobHeadFromNBT(const cParsedNBT & a_NBT, int a_T
-OwnedBlockEntity cWSSAnvil::LoadNoteBlockFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadNoteBlockFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Music", "minecraft:noteblock" });
+ static const AStringVector expectedTypes({"Music", "minecraft:noteblock"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1526,10 +1699,16 @@ OwnedBlockEntity cWSSAnvil::LoadNoteBlockFromNBT(const cParsedNBT & a_NBT, int a
-OwnedBlockEntity cWSSAnvil::LoadSignFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+OwnedBlockEntity cWSSAnvil::LoadSignFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+)
{
// Check if the data has a proper type:
- static const AStringVector expectedTypes({ "Sign", "minecraft:sign" });
+ static const AStringVector expectedTypes({"Sign", "minecraft:sign"});
if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
{
return nullptr;
@@ -1568,55 +1747,59 @@ OwnedBlockEntity cWSSAnvil::LoadSignFromNBT(const cParsedNBT & a_NBT, int a_TagI
-void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const std::string_view a_EntityName)
+void cWSSAnvil::LoadEntityFromNBT(
+ cEntityList & a_Entities,
+ const cParsedNBT & a_NBT,
+ int a_EntityTagIdx,
+ const std::string_view a_EntityName
+)
{
typedef void (cWSSAnvil::*EntityLoaderFunc)(cEntityList &, const cParsedNBT &, int a_EntityTagIdx);
typedef std::map<std::string_view, EntityLoaderFunc> EntityLoaderMap;
- static const EntityLoaderMap EntityTypeToFunction
- {
- { "Boat", &cWSSAnvil::LoadBoatFromNBT },
- { "minecraft:boat", &cWSSAnvil::LoadBoatFromNBT },
- { "EnderCrystal", &cWSSAnvil::LoadEnderCrystalFromNBT },
- { "minecraft:ender_crystal", &cWSSAnvil::LoadEnderCrystalFromNBT },
- { "FallingBlock", &cWSSAnvil::LoadFallingBlockFromNBT },
- { "minecraft:falling_block", &cWSSAnvil::LoadFallingBlockFromNBT },
- { "Minecart", &cWSSAnvil::LoadOldMinecartFromNBT },
- { "MinecartChest", &cWSSAnvil::LoadMinecartCFromNBT },
- { "minecraft:chest_minecart", &cWSSAnvil::LoadMinecartCFromNBT },
- { "MinecartFurnace", &cWSSAnvil::LoadMinecartFFromNBT },
- { "minecraft:furnace_minecart", &cWSSAnvil::LoadMinecartFFromNBT },
- { "MinecartTNT", &cWSSAnvil::LoadMinecartTFromNBT },
- { "minecraft:tnt_minecart", &cWSSAnvil::LoadMinecartTFromNBT },
- { "MinecartHopper", &cWSSAnvil::LoadMinecartHFromNBT },
- { "minecraft:hopper_minecart", &cWSSAnvil::LoadMinecartHFromNBT },
- { "MinecartRideable", &cWSSAnvil::LoadMinecartRFromNBT },
- { "minecraft:minecart", &cWSSAnvil::LoadMinecartRFromNBT },
- { "Item", &cWSSAnvil::LoadPickupFromNBT },
- { "minecraft:item", &cWSSAnvil::LoadPickupFromNBT },
- { "Painting", &cWSSAnvil::LoadPaintingFromNBT },
- { "minecraft:painting", &cWSSAnvil::LoadPaintingFromNBT },
- { "PrimedTnt", &cWSSAnvil::LoadTNTFromNBT },
- { "minecraft:tnt", &cWSSAnvil::LoadTNTFromNBT },
- { "XPOrb", &cWSSAnvil::LoadExpOrbFromNBT },
- { "minecraft:xp_orb", &cWSSAnvil::LoadExpOrbFromNBT },
- { "ItemFrame", &cWSSAnvil::LoadItemFrameFromNBT },
- { "minecraft:item_frame", &cWSSAnvil::LoadItemFrameFromNBT },
- { "LeashKnot", &cWSSAnvil::LoadLeashKnotFromNBT },
- { "minecraft:leash_knot", &cWSSAnvil::LoadLeashKnotFromNBT },
- { "Arrow", &cWSSAnvil::LoadArrowFromNBT },
- { "minecraft:arrow", &cWSSAnvil::LoadArrowFromNBT },
- { "SplashPotion", &cWSSAnvil::LoadSplashPotionFromNBT },
- { "minecraft:potion", &cWSSAnvil::LoadSplashPotionFromNBT },
- { "Snowball", &cWSSAnvil::LoadSnowballFromNBT },
- { "minecraft:snowball", &cWSSAnvil::LoadSnowballFromNBT },
- { "Egg", &cWSSAnvil::LoadEggFromNBT },
- { "minecraft:egg", &cWSSAnvil::LoadEggFromNBT },
- { "Fireball", &cWSSAnvil::LoadFireballFromNBT },
- { "minecraft:fireball", &cWSSAnvil::LoadFireballFromNBT },
- { "SmallFireball", &cWSSAnvil::LoadFireChargeFromNBT },
- { "minecraft:small_fireball", &cWSSAnvil::LoadFireChargeFromNBT },
- { "ThrownEnderpearl", &cWSSAnvil::LoadThrownEnderpearlFromNBT },
- { "minecraft:ender_pearl", &cWSSAnvil::LoadThrownEnderpearlFromNBT }
+ static const EntityLoaderMap EntityTypeToFunction {
+ {"Boat", &cWSSAnvil::LoadBoatFromNBT},
+ {"minecraft:boat", &cWSSAnvil::LoadBoatFromNBT},
+ {"EnderCrystal", &cWSSAnvil::LoadEnderCrystalFromNBT},
+ {"minecraft:ender_crystal", &cWSSAnvil::LoadEnderCrystalFromNBT},
+ {"FallingBlock", &cWSSAnvil::LoadFallingBlockFromNBT},
+ {"minecraft:falling_block", &cWSSAnvil::LoadFallingBlockFromNBT},
+ {"Minecart", &cWSSAnvil::LoadOldMinecartFromNBT},
+ {"MinecartChest", &cWSSAnvil::LoadMinecartCFromNBT},
+ {"minecraft:chest_minecart", &cWSSAnvil::LoadMinecartCFromNBT},
+ {"MinecartFurnace", &cWSSAnvil::LoadMinecartFFromNBT},
+ {"minecraft:furnace_minecart", &cWSSAnvil::LoadMinecartFFromNBT},
+ {"MinecartTNT", &cWSSAnvil::LoadMinecartTFromNBT},
+ {"minecraft:tnt_minecart", &cWSSAnvil::LoadMinecartTFromNBT},
+ {"MinecartHopper", &cWSSAnvil::LoadMinecartHFromNBT},
+ {"minecraft:hopper_minecart", &cWSSAnvil::LoadMinecartHFromNBT},
+ {"MinecartRideable", &cWSSAnvil::LoadMinecartRFromNBT},
+ {"minecraft:minecart", &cWSSAnvil::LoadMinecartRFromNBT},
+ {"Item", &cWSSAnvil::LoadPickupFromNBT},
+ {"minecraft:item", &cWSSAnvil::LoadPickupFromNBT},
+ {"Painting", &cWSSAnvil::LoadPaintingFromNBT},
+ {"minecraft:painting", &cWSSAnvil::LoadPaintingFromNBT},
+ {"PrimedTnt", &cWSSAnvil::LoadTNTFromNBT},
+ {"minecraft:tnt", &cWSSAnvil::LoadTNTFromNBT},
+ {"XPOrb", &cWSSAnvil::LoadExpOrbFromNBT},
+ {"minecraft:xp_orb", &cWSSAnvil::LoadExpOrbFromNBT},
+ {"ItemFrame", &cWSSAnvil::LoadItemFrameFromNBT},
+ {"minecraft:item_frame", &cWSSAnvil::LoadItemFrameFromNBT},
+ {"LeashKnot", &cWSSAnvil::LoadLeashKnotFromNBT},
+ {"minecraft:leash_knot", &cWSSAnvil::LoadLeashKnotFromNBT},
+ {"Arrow", &cWSSAnvil::LoadArrowFromNBT},
+ {"minecraft:arrow", &cWSSAnvil::LoadArrowFromNBT},
+ {"SplashPotion", &cWSSAnvil::LoadSplashPotionFromNBT},
+ {"minecraft:potion", &cWSSAnvil::LoadSplashPotionFromNBT},
+ {"Snowball", &cWSSAnvil::LoadSnowballFromNBT},
+ {"minecraft:snowball", &cWSSAnvil::LoadSnowballFromNBT},
+ {"Egg", &cWSSAnvil::LoadEggFromNBT},
+ {"minecraft:egg", &cWSSAnvil::LoadEggFromNBT},
+ {"Fireball", &cWSSAnvil::LoadFireballFromNBT},
+ {"minecraft:fireball", &cWSSAnvil::LoadFireballFromNBT},
+ {"SmallFireball", &cWSSAnvil::LoadFireChargeFromNBT},
+ {"minecraft:small_fireball", &cWSSAnvil::LoadFireChargeFromNBT},
+ {"ThrownEnderpearl", &cWSSAnvil::LoadThrownEnderpearlFromNBT},
+ {"minecraft:ender_pearl", &cWSSAnvil::LoadThrownEnderpearlFromNBT}
};
// TODO: flatten monster\projectile into one entity type enum
@@ -1724,11 +1907,11 @@ void cWSSAnvil::LoadOldMinecartFromNBT(cEntityList & a_Entities, const cParsedNB
int MinecartType = a_NBT.GetInt(TypeTag);
switch (MinecartType)
{
- case 0: LoadMinecartRFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Rideable minecart
- case 1: LoadMinecartCFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with chest
- case 2: LoadMinecartFFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with furnace
- case 3: LoadMinecartTFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with TNT
- case 4: LoadMinecartHFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with Hopper
+ case 0: LoadMinecartRFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Rideable minecart
+ case 1: LoadMinecartCFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with chest
+ case 2: LoadMinecartFFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with furnace
+ case 3: LoadMinecartTFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with TNT
+ case 4: LoadMinecartHFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with Hopper
default: LOGWARNING("cWSSAnvil::LoadOldMinecartFromNBT: Unhandled minecart type (%d)", MinecartType); break;
}
}
@@ -2136,7 +2319,9 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int PlayerIdx = a_NBT.FindChildByName(a_TagIdx, "player");
if ((PlayerIdx > 0) && (a_NBT.GetType(PlayerIdx) == TAG_Byte))
{
- Arrow->SetPickupState((a_NBT.GetByte(PlayerIdx) == 0) ? cArrowEntity::psNoPickup : cArrowEntity::psInSurvivalOrCreative);
+ Arrow->SetPickupState(
+ (a_NBT.GetByte(PlayerIdx) == 0) ? cArrowEntity::psNoPickup : cArrowEntity::psInSurvivalOrCreative
+ );
}
}
@@ -2154,20 +2339,24 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
if ((InBlockXIdx > 0) && (InBlockYIdx > 0) && (InBlockZIdx > 0))
{
eTagType typeX = a_NBT.GetType(InBlockXIdx);
- if ((typeX == a_NBT.GetType(InBlockYIdx)) && (typeX == a_NBT.GetType(InBlockZIdx)))
+ if ((typeX == a_NBT.GetType(InBlockYIdx)) && (typeX == a_NBT.GetType(InBlockZIdx)))
{
switch (typeX)
{
case TAG_Int:
{
// Old MCS code used this, keep reading it for compatibility reasons:
- Arrow->SetBlockHit(Vector3i(a_NBT.GetInt(InBlockXIdx), a_NBT.GetInt(InBlockYIdx), a_NBT.GetInt(InBlockZIdx)));
+ Arrow->SetBlockHit(
+ Vector3i(a_NBT.GetInt(InBlockXIdx), a_NBT.GetInt(InBlockYIdx), a_NBT.GetInt(InBlockZIdx))
+ );
break;
}
case TAG_Short:
{
// Vanilla uses this
- Arrow->SetBlockHit(Vector3i(a_NBT.GetShort(InBlockXIdx), a_NBT.GetShort(InBlockYIdx), a_NBT.GetShort(InBlockZIdx)));
+ Arrow->SetBlockHit(
+ Vector3i(a_NBT.GetShort(InBlockXIdx), a_NBT.GetShort(InBlockYIdx), a_NBT.GetShort(InBlockZIdx))
+ );
break;
}
default:
@@ -2195,12 +2384,14 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
return;
}
- int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration");
- int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
+ int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration");
+ int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier");
SplashPotion->SetEntityEffectType(static_cast<cEntityEffect::eType>(a_NBT.FindChildByName(a_TagIdx, "EffectType")));
- SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, static_cast<Int16>(EffectIntensity), EffectDistanceModifier));
+ SplashPotion->SetEntityEffect(
+ cEntityEffect(EffectDuration, static_cast<Int16>(EffectIntensity), EffectDistanceModifier)
+ );
SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
// Store the new splash potion in the entities list:
@@ -2331,7 +2522,7 @@ void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
-void cWSSAnvil::LoadCatFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadCatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2380,7 +2571,7 @@ void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadCodFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadCodFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2438,7 +2629,7 @@ void cWSSAnvil::LoadDolphinFromNBT(cEntityList & a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadDonkeyFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadDonkeyFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2447,7 +2638,7 @@ void cWSSAnvil::LoadDonkeyFromNBT(cEntityList &a_Entities, const cParsedNBT &a_N
-void cWSSAnvil::LoadDrownedFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadDrownedFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2456,7 +2647,7 @@ void cWSSAnvil::LoadDrownedFromNBT(cEntityList &a_Entities, const cParsedNBT &a_
-void cWSSAnvil::LoadElderGuardianFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadElderGuardianFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2505,7 +2696,7 @@ void cWSSAnvil::LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadEndermiteFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadEndermiteFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2514,7 +2705,7 @@ void cWSSAnvil::LoadEndermiteFromNBT(cEntityList &a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadEvokerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadEvokerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2523,7 +2714,7 @@ void cWSSAnvil::LoadEvokerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_N
-void cWSSAnvil::LoadFoxFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadFoxFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2594,7 +2785,7 @@ void cWSSAnvil::LoadGuardianFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Type");
+ int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Type");
int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color");
int StyleIdx = a_NBT.FindChildByName(a_TagIdx, "Style");
if ((TypeIdx < 0) || (ColorIdx < 0) || (StyleIdx < 0))
@@ -2618,15 +2809,15 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
return;
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -2638,7 +2829,7 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
-void cWSSAnvil::LoadHoglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadHoglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2647,7 +2838,7 @@ void cWSSAnvil::LoadHoglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_N
-void cWSSAnvil::LoadHuskFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadHuskFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2656,7 +2847,7 @@ void cWSSAnvil::LoadHuskFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT
-void cWSSAnvil::LoadIllusionerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadIllusionerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2685,7 +2876,7 @@ void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT
-void cWSSAnvil::LoadLlamaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadLlamaFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2743,7 +2934,7 @@ void cWSSAnvil::LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT
-void cWSSAnvil::LoadMuleFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadMuleFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2772,7 +2963,7 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
Monster->SetIsTame(true);
}
- int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "CatType");
+ int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "CatType");
if (TypeIdx > 0)
{
int Type = a_NBT.GetInt(TypeIdx);
@@ -2786,15 +2977,15 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
Monster->SetIsSitting(Sitting);
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -2806,7 +2997,7 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
-void cWSSAnvil::LoadPandaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadPandaFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2815,7 +3006,7 @@ void cWSSAnvil::LoadPandaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NB
-void cWSSAnvil::LoadParrotFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadParrotFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2824,7 +3015,7 @@ void cWSSAnvil::LoadParrotFromNBT(cEntityList &a_Entities, const cParsedNBT &a_N
-void cWSSAnvil::LoadPhantomFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadPhantomFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2846,15 +3037,15 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
return;
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -2866,7 +3057,7 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
-void cWSSAnvil::LoadPiglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadPiglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2875,7 +3066,7 @@ void cWSSAnvil::LoadPiglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_N
-void cWSSAnvil::LoadPiglinBruteFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadPiglinBruteFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2884,7 +3075,7 @@ void cWSSAnvil::LoadPiglinBruteFromNBT(cEntityList &a_Entities, const cParsedNBT
-void cWSSAnvil::LoadPillagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadPillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2893,7 +3084,7 @@ void cWSSAnvil::LoadPillagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a
-void cWSSAnvil::LoadPolarBearFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadPolarBearFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2902,7 +3093,7 @@ void cWSSAnvil::LoadPolarBearFromNBT(cEntityList &a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadPufferfishFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadPufferfishFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2913,7 +3104,7 @@ void cWSSAnvil::LoadPufferfishFromNBT(cEntityList &a_Entities, const cParsedNBT
void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "RabbitType");
+ int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "RabbitType");
int MoreCarrotTicksIdx = a_NBT.FindChildByName(a_TagIdx, "MoreCarrotTicks");
if ((TypeIdx < 0) || (MoreCarrotTicksIdx < 0))
@@ -2935,15 +3126,15 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a
return;
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -2955,7 +3146,7 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a
-void cWSSAnvil::LoadRavagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadRavagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2964,7 +3155,7 @@ void cWSSAnvil::LoadRavagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_
-void cWSSAnvil::LoadSalmonFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadSalmonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -2999,15 +3190,15 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
Monster->SetSheared(a_NBT.GetByte(ShearedIdx) != 0);
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -3019,7 +3210,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
-void cWSSAnvil::LoadShulkerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadShulkerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3081,7 +3272,7 @@ void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadSkeletonHorseFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadSkeletonHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3179,7 +3370,7 @@ void cWSSAnvil::LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
-void cWSSAnvil::LoadStrayFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadStrayFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3188,7 +3379,7 @@ void cWSSAnvil::LoadStrayFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NB
-void cWSSAnvil::LoadStriderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadStriderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3197,7 +3388,7 @@ void cWSSAnvil::LoadStriderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_
-void cWSSAnvil::LoadTraderLlamaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadTraderLlamaFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3206,7 +3397,7 @@ void cWSSAnvil::LoadTraderLlamaFromNBT(cEntityList &a_Entities, const cParsedNBT
-void cWSSAnvil::LoadTropicalFishFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadTropicalFishFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3215,7 +3406,7 @@ void cWSSAnvil::LoadTropicalFishFromNBT(cEntityList &a_Entities, const cParsedNB
-void cWSSAnvil::LoadTurtleFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadTurtleFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3224,7 +3415,7 @@ void cWSSAnvil::LoadTurtleFromNBT(cEntityList &a_Entities, const cParsedNBT &a_N
-void cWSSAnvil::LoadVexFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadVexFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3254,15 +3445,15 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
return;
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -3281,7 +3472,7 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
-void cWSSAnvil::LoadVindicatorFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadVindicatorFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3290,7 +3481,7 @@ void cWSSAnvil::LoadVindicatorFromNBT(cEntityList &a_Entities, const cParsedNBT
-void cWSSAnvil::LoadWanderingTraderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadWanderingTraderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3421,15 +3612,15 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
}
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -3441,7 +3632,7 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
-void cWSSAnvil::LoadZoglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadZoglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3463,7 +3654,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
return;
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
@@ -3471,7 +3662,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
- default: Age = 0; break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -3483,7 +3674,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
-void cWSSAnvil::LoadZombieHorseFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadZombieHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// TODO
}
@@ -3505,15 +3696,15 @@ void cWSSAnvil::LoadZombifiedPiglinFromNBT(cEntityList & a_Entities, const cPars
return;
}
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
- default: Age = 0; break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
+ default: Age = 0; break;
}
Monster->SetAge(Age);
}
@@ -3548,14 +3739,14 @@ void cWSSAnvil::LoadZombieVillagerFromNBT(cEntityList & a_Entities, const cParse
// TODO: Conversion time
- int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
if (AgeableIdx > 0)
{
int Age;
switch (a_NBT.GetType(AgeableIdx))
{
case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break;
- case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break;
+ case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break;
default: Age = 0; break;
}
Monster->SetAge(Age);
@@ -3614,7 +3805,7 @@ std::pair<AString, cUUID> cWSSAnvil::LoadEntityOwner(const cParsedNBT & a_NBT, i
}
}
- return { OwnerName, OwnerUUID };
+ return {OwnerName, OwnerUUID};
}
@@ -3654,7 +3845,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N
// stored either as a float Health tag (HealF prior to 1.9) or
// as a short Health tag. The float tags should be preferred.
int Health = a_NBT.FindChildByName(a_TagIdx, "Health");
- int HealF = a_NBT.FindChildByName(a_TagIdx, "HealF");
+ int HealF = a_NBT.FindChildByName(a_TagIdx, "HealF");
if (Health > 0 && a_NBT.GetType(Health) == TAG_Float)
{
@@ -3814,7 +4005,8 @@ bool cWSSAnvil::LoadDoublesListFromNBT(double * a_Doubles, int a_NumDoubles, con
return false;
}
int idx = 0;
- for (int Tag = a_NBT.GetFirstChild(a_TagIdx); (Tag > 0) && (idx < a_NumDoubles); Tag = a_NBT.GetNextSibling(Tag), ++idx)
+ for (int Tag = a_NBT.GetFirstChild(a_TagIdx); (Tag > 0) && (idx < a_NumDoubles);
+ Tag = a_NBT.GetNextSibling(Tag), ++idx)
{
a_Doubles[idx] = a_NBT.GetDouble(Tag);
} // for Tag - PosTag[]
@@ -3832,7 +4024,8 @@ bool cWSSAnvil::LoadFloatsListFromNBT(float * a_Floats, int a_NumFloats, const c
return false;
}
int idx = 0;
- for (int Tag = a_NBT.GetFirstChild(a_TagIdx); (Tag > 0) && (idx < a_NumFloats); Tag = a_NBT.GetNextSibling(Tag), ++idx)
+ for (int Tag = a_NBT.GetFirstChild(a_TagIdx); (Tag > 0) && (idx < a_NumFloats);
+ Tag = a_NBT.GetNextSibling(Tag), ++idx)
{
a_Floats[idx] = a_NBT.GetFloat(Tag);
} // for Tag - PosTag[]
@@ -3862,7 +4055,7 @@ bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, Vec
}
a_AbsPos.Set(
Clamp(a_NBT.GetInt(x), -40000000, 40000000), // World is limited to 30M blocks in XZ, we clamp to 40M
- Clamp(a_NBT.GetInt(y), -10000, 10000), // Y is limited to 0 .. 255, we clamp to 10K
+ Clamp(a_NBT.GetInt(y), -10000, 10000), // Y is limited to 0 .. 255, we clamp to 10K
Clamp(a_NBT.GetInt(z), -40000000, 40000000)
);
return true;
@@ -3876,10 +4069,7 @@ bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, Vec
// cWSSAnvil::cMCAFile:
cWSSAnvil::cMCAFile::cMCAFile(cWSSAnvil & a_ParentSchema, const AString & a_FileName, int a_RegionX, int a_RegionZ) :
- m_ParentSchema(a_ParentSchema),
- m_RegionX(a_RegionX),
- m_RegionZ(a_RegionZ),
- m_FileName(a_FileName)
+ m_ParentSchema(a_ParentSchema), m_RegionX(a_RegionX), m_RegionZ(a_RegionZ), m_FileName(a_FileName)
{
}
@@ -3933,12 +4123,14 @@ bool cWSSAnvil::cMCAFile::OpenFile(bool a_IsForReading)
if (writeOutNeeded)
{
m_File.Seek(0);
- if (
- (m_File.Write(m_Header, sizeof(m_Header)) != sizeof(m_Header)) || // Write chunk offsets
+ if ((m_File.Write(m_Header, sizeof(m_Header)) != sizeof(m_Header)) || // Write chunk offsets
(m_File.Write(m_TimeStamps, sizeof(m_TimeStamps)) != sizeof(m_TimeStamps)) // Write chunk timestamps
)
{
- LOGWARNING("Cannot process MCA header in file \"%s\", chunks in that file will be lost", m_FileName.c_str());
+ LOGWARNING(
+ "Cannot process MCA header in file \"%s\", chunks in that file will be lost",
+ m_FileName.c_str()
+ );
m_File.Close();
return false;
}
@@ -4008,7 +4200,11 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, ContiguousB
if (CompressionType != 2)
{
// Chunk is in an unknown compression
- m_ParentSchema.ChunkLoadFailed(a_Chunk, fmt::format(FMT_STRING("Unknown chunk compression: {}"), CompressionType), a_Data);
+ m_ParentSchema.ChunkLoadFailed(
+ a_Chunk,
+ fmt::format(FMT_STRING("Unknown chunk compression: {}"), CompressionType),
+ a_Data
+ );
return false;
}
return true;
@@ -4018,7 +4214,12 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, ContiguousB
-const std::byte * cWSSAnvil::GetSectionData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, size_t a_Length)
+const std::byte * cWSSAnvil::GetSectionData(
+ const cParsedNBT & a_NBT,
+ int a_Tag,
+ const AString & a_ChildName,
+ size_t a_Length
+)
{
int Child = a_NBT.FindChildByName(a_Tag, a_ChildName);
if ((Child >= 0) && (a_NBT.GetType(Child) == TAG_ByteArray) && (a_NBT.GetDataLength(Child) == a_Length))
@@ -4036,7 +4237,12 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const Conti
{
if (!OpenFile(false))
{
- LOGWARNING("Cannot save chunk [%d, %d], opening file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], opening file \"%s\" failed",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ GetFileName().c_str()
+ );
return false;
}
@@ -4058,18 +4264,33 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const Conti
UInt32 ChunkSize = htonl(static_cast<UInt32>(a_Data.size() + 1));
if (m_File.Write(&ChunkSize, 4) != 4)
{
- LOGWARNING("Cannot save chunk [%d, %d], writing(1) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], writing(1) data to file \"%s\" failed",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ GetFileName().c_str()
+ );
return false;
}
char CompressionType = 2;
if (m_File.Write(&CompressionType, 1) != 1)
{
- LOGWARNING("Cannot save chunk [%d, %d], writing(2) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], writing(2) data to file \"%s\" failed",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ GetFileName().c_str()
+ );
return false;
}
if (m_File.Write(a_Data.data(), a_Data.size()) != static_cast<int>(a_Data.size()))
{
- LOGWARNING("Cannot save chunk [%d, %d], writing(3) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], writing(3) data to file \"%s\" failed",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ GetFileName().c_str()
+ );
return false;
}
@@ -4082,11 +4303,16 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const Conti
}
// Store the header:
- ChunkSize = (static_cast<UInt32>(a_Data.size()) + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size up to nearest 4KB sector, make it a sector number
+ ChunkSize = (static_cast<UInt32>(a_Data.size()) + MCA_CHUNK_HEADER_LENGTH + 4095) /
+ 4096; // Round data size up to nearest 4KB sector, make it a sector number
if (ChunkSize > 255)
{
- LOGWARNING("Cannot save chunk [%d, %d], the data is too large (%u KiB, maximum is 1024 KiB). Remove some entities and retry.",
- a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, static_cast<unsigned>(ChunkSize * 4)
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], the data is too large (%u KiB, maximum is 1024 KiB). Remove some entities and "
+ "retry.",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ static_cast<unsigned>(ChunkSize * 4)
);
return false;
}
@@ -4095,21 +4321,36 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const Conti
m_Header[LocalX + 32 * LocalZ] = htonl(static_cast<UInt32>((ChunkSector << 8) | ChunkSize));
// Set the modification time
- m_TimeStamps[LocalX + 32 * LocalZ] = htonl(static_cast<UInt32>(time(nullptr)));
+ m_TimeStamps[LocalX + 32 * LocalZ] = htonl(static_cast<UInt32>(time(nullptr)));
if (m_File.Seek(0) < 0)
{
- LOGWARNING("Cannot save chunk [%d, %d], seeking in file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], seeking in file \"%s\" failed",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ GetFileName().c_str()
+ );
return false;
}
if (m_File.Write(m_Header, sizeof(m_Header)) != sizeof(m_Header))
{
- LOGWARNING("Cannot save chunk [%d, %d], writing header to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], writing header to file \"%s\" failed",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ GetFileName().c_str()
+ );
return false;
}
if (m_File.Write(m_TimeStamps, sizeof(m_TimeStamps)) != sizeof(m_TimeStamps))
{
- LOGWARNING("Cannot save chunk [%d, %d], writing timestamps to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
+ LOGWARNING(
+ "Cannot save chunk [%d, %d], writing timestamps to file \"%s\" failed",
+ a_Chunk.m_ChunkX,
+ a_Chunk.m_ChunkZ,
+ GetFileName().c_str()
+ );
return false;
}
@@ -4135,7 +4376,8 @@ unsigned cWSSAnvil::cMCAFile::FindFreeLocation(int a_LocalX, int a_LocalZ, const
for (size_t i = 0; i < ARRAYCOUNT(m_Header); i++)
{
ChunkLocation = ntohl(m_Header[i]);
- ChunkLocation = ChunkLocation + ((ChunkLocation & 0xff) << 8); // Add the number of sectors used; don't care about the 4th byte
+ ChunkLocation = ChunkLocation +
+ ((ChunkLocation & 0xff) << 8); // Add the number of sectors used; don't care about the 4th byte
if (MaxLocation < ChunkLocation)
{
MaxLocation = ChunkLocation;
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index e0c9a9320..88d1a6bd4 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -23,18 +23,15 @@ class ChunkBlockData;
/** Implements the Anvil world storage schema. */
-class cWSSAnvil:
- public cWSSchema
+class cWSSAnvil : public cWSSchema
{
using Super = cWSSchema;
-public:
-
+ public:
cWSSAnvil(cWorld * a_World, int a_CompressionFactor);
virtual ~cWSSAnvil() override;
-protected:
-
+ protected:
enum
{
/** Maximum number of chunks in an MCA file - also the count of the header items */
@@ -45,29 +42,27 @@ protected:
/** There are 5 bytes of header in front of each chunk */
MCA_CHUNK_HEADER_LENGTH = 5,
- } ;
+ };
class cMCAFile
{
- public:
-
+ public:
cMCAFile(cWSSAnvil & a_ParentSchema, const AString & a_FileName, int a_RegionX, int a_RegionZ);
- bool GetChunkData (const cChunkCoords & a_Chunk, ContiguousByteBuffer & a_Data);
- bool SetChunkData (const cChunkCoords & a_Chunk, ContiguousByteBufferView a_Data);
-
- int GetRegionX () const {return m_RegionX; }
- int GetRegionZ () const {return m_RegionZ; }
- const AString & GetFileName() const {return m_FileName; }
+ bool GetChunkData(const cChunkCoords & a_Chunk, ContiguousByteBuffer & a_Data);
+ bool SetChunkData(const cChunkCoords & a_Chunk, ContiguousByteBufferView a_Data);
- protected:
+ int GetRegionX() const { return m_RegionX; }
+ int GetRegionZ() const { return m_RegionZ; }
+ const AString & GetFileName() const { return m_FileName; }
+ protected:
cWSSAnvil & m_ParentSchema;
- int m_RegionX;
- int m_RegionZ;
- cFile m_File;
+ int m_RegionX;
+ int m_RegionZ;
+ cFile m_File;
AString m_FileName;
// The header, copied from the file so we don't have to seek to it all the time
@@ -80,9 +75,10 @@ protected:
/** Finds a free location large enough to hold a_Data. Returns the sector number. */
unsigned FindFreeLocation(int a_LocalX, int a_LocalZ, size_t a_DataSize);
- /** Opens a MCA file either for a Read operation (fails if doesn't exist) or for a Write operation (creates new if not found) */
+ /** Opens a MCA file either for a Read operation (fails if doesn't exist) or for a Write operation (creates new
+ * if not found) */
bool OpenFile(bool a_IsForReading);
- } ;
+ };
/** Protects m_Files against multithreaded access. */
cCriticalSection m_CS;
@@ -95,7 +91,11 @@ protected:
Compression::Compressor m_Compressor;
/** Reports that the specified chunk failed to load and saves the chunk data to an external file. */
- void ChunkLoadFailed(const cChunkCoords a_ChunkCoords, const AString & a_Reason, ContiguousByteBufferView a_ChunkDataToSave);
+ void ChunkLoadFailed(
+ const cChunkCoords a_ChunkCoords,
+ const AString & a_Reason,
+ ContiguousByteBufferView a_ChunkDataToSave
+ );
/** Gets chunk data from the correct file; locks file CS as needed */
bool GetChunkData(const cChunkCoords & a_Chunk, ContiguousByteBuffer & a_Data);
@@ -114,7 +114,11 @@ protected:
/** Loads the chunk from NBT data (no locking needed).
a_RawChunkData is the raw (compressed) chunk data, used for offloading when chunk loading fails. */
- bool LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT & a_NBT, ContiguousByteBufferView a_RawChunkData);
+ bool LoadChunkFromNBT(
+ const cChunkCoords & a_Chunk,
+ const cParsedNBT & a_NBT,
+ ContiguousByteBufferView a_RawChunkData
+ );
/** Loads the chunk's biome map into a_BiomeMap if biomes present and valid; returns false otherwise. */
bool LoadBiomeMapFromNBT(cChunkDef::BiomeMap & a_BiomeMap, const cParsedNBT & a_NBT, int a_TagIdx);
@@ -126,11 +130,22 @@ protected:
void LoadEntitiesFromNBT(cEntityList & a_Entitites, const cParsedNBT & a_NBT, int a_Tag);
/** Loads the chunk's BlockEntities from NBT data (a_Tag is the Level\\TileEntities list tag; may be -1) */
- void LoadBlockEntitiesFromNBT(cBlockEntities & a_BlockEntitites, const cParsedNBT & a_NBT, int a_Tag, const ChunkBlockData & a_BlockData);
+ void LoadBlockEntitiesFromNBT(
+ cBlockEntities & a_BlockEntitites,
+ const cParsedNBT & a_NBT,
+ int a_Tag,
+ const ChunkBlockData & a_BlockData
+ );
/** Loads the data for a block entity from the specified NBT tag.
Returns the loaded block entity, or nullptr upon failure. */
- OwnedBlockEntity LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int a_Tag, Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ OwnedBlockEntity LoadBlockEntityFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_Tag,
+ Vector3i a_Pos,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta
+ );
/** Loads a cItem contents from the specified NBT tag; returns true if successful. Doesn't load the Slot tag */
bool LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_TagIdx);
@@ -145,128 +160,251 @@ protected:
This function extracts the text from either version. */
AString DecodeSignLine(const AString & a_Line);
- /** Returns true iff the "id" child tag inside the specified tag equals (case-sensitive) any of the specified expected types.
- Logs a warning to the console on mismatch.
- The coordinates are used only for the log message. */
- bool CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, const AStringVector & a_ExpectedTypes, Vector3i a_Pos);
-
- OwnedBlockEntity LoadBannerFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadBeaconFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadBedFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadBrewingstandFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadChestFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadCommandBlockFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadDispenserFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadDropperFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadEnchantingTableFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadEnderChestFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadEndPortalFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadFlowerPotFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadFurnaceFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadHopperFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadJukeboxFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadMobHeadFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadMobSpawnerFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadNoteBlockFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
- OwnedBlockEntity LoadSignFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
-
- void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, std::string_view a_EntityName);
-
- void LoadBoatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEnderCrystalFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadFallingBlockFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPickupFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadTNTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadExpOrbFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadHangingFromNBT (cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadItemFrameFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadLeashKnotFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPaintingFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
-
- void LoadOldMinecartFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMinecartCFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMinecartFFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMinecartTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMinecartHFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
-
- void LoadArrowFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSplashPotionFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSnowballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEggFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadFireballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadFireChargeFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ /** Returns true iff the "id" child tag inside the specified tag equals (case-sensitive) any of the specified
+ expected types. Logs a warning to the console on mismatch. The coordinates are used only for the log message. */
+ bool CheckBlockEntityType(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ const AStringVector & a_ExpectedTypes,
+ Vector3i a_Pos
+ );
+
+ OwnedBlockEntity LoadBannerFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadBeaconFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadBedFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadBrewingstandFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadChestFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadCommandBlockFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadDispenserFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadDropperFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadEnchantingTableFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadEnderChestFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadEndPortalFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadFlowerPotFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadFurnaceFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadHopperFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadJukeboxFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadMobHeadFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadMobSpawnerFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadNoteBlockFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+ OwnedBlockEntity LoadSignFromNBT(
+ const cParsedNBT & a_NBT,
+ int a_TagIdx,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
+ Vector3i a_Pos
+ );
+
+ void LoadEntityFromNBT(
+ cEntityList & a_Entities,
+ const cParsedNBT & a_NBT,
+ int a_EntityTagIdx,
+ std::string_view a_EntityName
+ );
+
+ void LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadEnderCrystalFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadHangingFromNBT(cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadLeashKnotFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPaintingFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+
+ void LoadOldMinecartFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMinecartCFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMinecartTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMinecartHFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+
+ void LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadEggFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadFireballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadFireChargeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadThrownEnderpearlFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadBatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadBlazeFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadCatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadCaveSpiderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadChickenFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadCodFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadCowFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadCreeperFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadDolphinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadDonkeyFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadDrownedFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadElderGuardianFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEnderDragonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEndermanFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEndermiteFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEvokerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadFoxFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadGhastFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadGiantFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadGuardianFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadHorseFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadHoglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadHuskFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadIllusionerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadIronGolemFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadLlamaFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMagmaCubeFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMooshroomFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadMuleFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadOcelotFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPandaFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadParrotFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPhantomFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPigFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPiglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPiglinBruteFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPillagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPolarBearFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadPufferfishFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadRabbitFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadRavagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSalmonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSheepFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadShulkerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSilverfishFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSkeletonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSkeletonHorseFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSlimeFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSnowGolemFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSpiderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadSquidFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadStrayFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadStriderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadTraderLlamaFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadTropicalFishFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadTurtleFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadVexFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadVillagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadVindicatorFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadWanderingTraderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadWitchFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadWitherFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadWitherSkeletonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadWolfFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadZoglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadZombieFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadZombieHorseFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadZombifiedPiglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadZombieVillagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadBatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadCatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadCodFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadDolphinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadDonkeyFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadDrownedFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadElderGuardianFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadEndermiteFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadEvokerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadFoxFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadGhastFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadGiantFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadGuardianFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadHoglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadHuskFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadIllusionerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadLlamaFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadMuleFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPandaFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadParrotFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPhantomFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPiglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPiglinBruteFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPolarBearFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadPufferfishFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadRavagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSalmonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadShulkerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSilverfishFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSkeletonHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSnowGolemFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadStrayFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadStriderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadTraderLlamaFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadTropicalFishFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadTurtleFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadVexFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadVindicatorFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadWanderingTraderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadWitchFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadWitherSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadZoglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadZombieHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadZombifiedPiglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadZombieVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
/** Loads the owner name and UUID from the entity at the specified NBT tag.
Returns a pair of {name, uuid}. If the entity is not owned, name is an empty string and uuid is nil. */
@@ -284,20 +422,23 @@ protected:
/** Loads projectile common data from the NBT compound; returns true if successful */
bool LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIx);
- /** Loads an array of doubles of the specified length from the specified NBT list tag a_TagIdx; returns true if successful */
+ /** Loads an array of doubles of the specified length from the specified NBT list tag a_TagIdx; returns true if
+ * successful */
bool LoadDoublesListFromNBT(double * a_Doubles, int a_NumDoubles, const cParsedNBT & a_NBT, int a_TagIdx);
- /** Loads an array of floats of the specified length from the specified NBT list tag a_TagIdx; returns true if successful */
+ /** Loads an array of floats of the specified length from the specified NBT list tag a_TagIdx; returns true if
+ * successful */
bool LoadFloatsListFromNBT(float * a_Floats, int a_NumFloats, const cParsedNBT & a_NBT, int a_TagIdx);
/** Helper function for extracting the X, Y, and Z int subtags of a NBT compound; returns true if successful */
bool GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, Vector3i & a_AbsPos);
- /** Gets the correct MCA file either from cache or from disk, manages the m_MCAFiles cache; assumes m_CS is locked */
+ /** Gets the correct MCA file either from cache or from disk, manages the m_MCAFiles cache; assumes m_CS is locked
+ */
std::shared_ptr<cMCAFile> LoadMCAFile(const cChunkCoords & a_Chunk);
// cWSSchema overrides:
virtual bool LoadChunk(const cChunkCoords & a_Chunk) override;
virtual bool SaveChunk(const cChunkCoords & a_Chunk) override;
- virtual const AString GetName() const override {return "anvil"; }
-} ;
+ virtual const AString GetName() const override { return "anvil"; }
+};
diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp
index 2f566a083..ad7c2dece 100644
--- a/src/WorldStorage/WorldStorage.cpp
+++ b/src/WorldStorage/WorldStorage.cpp
@@ -17,18 +17,20 @@
/** Example storage schema - forgets all chunks */
-class cWSSForgetful :
- public cWSSchema
+class cWSSForgetful : public cWSSchema
{
-public:
- cWSSForgetful(cWorld * a_World) : cWSSchema(a_World) {}
+ public:
+ cWSSForgetful(cWorld * a_World) :
+ cWSSchema(a_World)
+ {
+ }
-protected:
+ protected:
// cWSSchema overrides:
- virtual bool LoadChunk(const cChunkCoords & a_Chunk) override {return false; }
- virtual bool SaveChunk(const cChunkCoords & a_Chunk) override {return true; }
- virtual const AString GetName(void) const override {return "forgetful"; }
-} ;
+ virtual bool LoadChunk(const cChunkCoords & a_Chunk) override { return false; }
+ virtual bool SaveChunk(const cChunkCoords & a_Chunk) override { return true; }
+ virtual const AString GetName(void) const override { return "forgetful"; }
+};
@@ -38,9 +40,7 @@ protected:
// cWorldStorage:
cWorldStorage::cWorldStorage(void) :
- Super("World Storage Executor"),
- m_World(nullptr),
- m_SaveSchema(nullptr)
+ Super("World Storage Executor"), m_World(nullptr), m_SaveSchema(nullptr)
{
}
@@ -144,7 +144,7 @@ void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkZ)
ASSERT((a_ChunkZ > -0x08000000) && (a_ChunkZ < 0x08000000));
ASSERT(m_World->IsChunkQueued(a_ChunkX, a_ChunkZ));
- m_LoadQueue.EnqueueItem({ a_ChunkX, a_ChunkZ });
+ m_LoadQueue.EnqueueItem({a_ChunkX, a_ChunkZ});
m_Event.Set();
}
@@ -156,7 +156,7 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkZ)
{
ASSERT(m_World->IsChunkValid(a_ChunkX, a_ChunkZ));
- m_SaveQueue.EnqueueItem({ a_ChunkX, a_ChunkZ });
+ m_SaveQueue.EnqueueItem({a_ChunkX, a_ChunkZ});
m_Event.Set();
}
@@ -167,7 +167,7 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkZ)
void cWorldStorage::InitSchemas(int a_StorageCompressionFactor)
{
// The first schema added is considered the default
- m_Schemas.push_back(new cWSSAnvil (m_World, a_StorageCompressionFactor));
+ m_Schemas.push_back(new cWSSAnvil(m_World, a_StorageCompressionFactor));
m_Schemas.push_back(new cWSSForgetful(m_World));
// Add new schemas here
@@ -186,8 +186,10 @@ void cWorldStorage::InitSchemas(int a_StorageCompressionFactor)
} // for itr - m_Schemas[]
// Unknown schema selected, let the admin know:
- LOGWARNING("Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:",
- m_StorageSchemaName.c_str(), m_SaveSchema->GetName().c_str()
+ LOGWARNING(
+ "Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:",
+ m_StorageSchemaName.c_str(),
+ m_SaveSchema->GetName().c_str()
);
for (cWSSchemaList::iterator itr = m_Schemas.begin(); itr != m_Schemas.end(); ++itr)
{
@@ -216,7 +218,8 @@ void cWorldStorage::Execute(void)
Success = LoadOneChunk();
Success |= SaveOneChunk();
- } while (Success);
+ }
+ while (Success);
}
}
@@ -297,8 +300,3 @@ bool cWorldStorage::LoadChunk(int a_ChunkX, int a_ChunkZ)
return false;
}
-
-
-
-
-
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index 114abb651..7051273b6 100644
--- a/src/WorldStorage/WorldStorage.h
+++ b/src/WorldStorage/WorldStorage.h
@@ -29,18 +29,20 @@ class cWorld;
/** Interface that all the world storage schemas need to implement */
class cWSSchema abstract
{
-public:
- cWSSchema(cWorld * a_World) : m_World(a_World) {}
+ public:
+ cWSSchema(cWorld * a_World) :
+ m_World(a_World)
+ {
+ }
virtual ~cWSSchema() {} // Force the descendants' destructors to be virtual
virtual bool LoadChunk(const cChunkCoords & a_Chunk) = 0;
virtual bool SaveChunk(const cChunkCoords & a_Chunk) = 0;
virtual const AString GetName(void) const = 0;
-protected:
-
+ protected:
cWorld * m_World;
-} ;
+};
typedef std::list<cWSSchema *> cWSSchemaList;
@@ -49,13 +51,11 @@ typedef std::list<cWSSchema *> cWSSchemaList;
/** The actual world storage class */
-class cWorldStorage:
- public cIsThread
+class cWorldStorage : public cIsThread
{
using Super = cIsThread;
-public:
-
+ public:
cWorldStorage();
virtual ~cWorldStorage() override;
@@ -75,10 +75,9 @@ public:
size_t GetLoadQueueLength(void);
size_t GetSaveQueueLength(void);
-protected:
-
+ protected:
cWorld * m_World;
- AString m_StorageSchemaName;
+ AString m_StorageSchemaName;
cQueue<cChunkCoords> m_LoadQueue;
cQueue<cChunkCoords> m_SaveQueue;
@@ -105,8 +104,4 @@ protected:
/** Saves one chunk from the queue (if any queued); returns true if there was a chunk in the queue to save */
bool SaveOneChunk(void);
-} ;
-
-
-
-
+};