From cc597c324010e4427aef81a37cf12bb6f6a77e77 Mon Sep 17 00:00:00 2001 From: DankParrot Date: Thu, 6 Aug 2020 19:02:04 -0700 Subject: [PATCH] NBT: Fix reading primitives from compound tag --- src/nbt/NBT.cpp | 1 - src/nbt/NBT.h | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nbt/NBT.cpp b/src/nbt/NBT.cpp index 554d061..218faef 100644 --- a/src/nbt/NBT.cpp +++ b/src/nbt/NBT.cpp @@ -1,7 +1,6 @@ #include "NBT.h" #include "cNBT/nbt.h" -#include "cNBT/list.h" #include #include diff --git a/src/nbt/NBT.h b/src/nbt/NBT.h index d49bff7..298593d 100644 --- a/src/nbt/NBT.h +++ b/src/nbt/NBT.h @@ -188,9 +188,15 @@ namespace NBT } template - 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::value) { + return T(result); + } + else { + // DataTag can be auto converted to T + return DataTag(result); + } } } \ No newline at end of file