NBT: Fix reading primitives from compound tag

This commit is contained in:
DankParrot 2020-08-06 19:02:04 -07:00
parent ae99701d00
commit cc597c3240
2 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,6 @@
#include "NBT.h"
#include "cNBT/nbt.h"
#include "cNBT/list.h"
#include <cstring>
#include <sstream>

View File

@ -188,9 +188,15 @@ namespace NBT
}
template <typename T>
const T CompoundTag::Get(const char *name) const
const T CompoundTag::Get(const char* name) const
{
nbt_node *result = Internal::FindByName(m_node, name);
return T(result);
nbt_node* result = Internal::FindByName(m_node, name);
if constexpr (std::is_base_of<Tag, T>::value) {
return T(result);
}
else {
// DataTag<T> can be auto converted to T
return DataTag<T>(result);
}
}
}