diff --git a/src/mc/nbt/CompoundTagVariant.h b/src/mc/nbt/CompoundTagVariant.h index 34e779314f..9c06d7c25e 100644 --- a/src/mc/nbt/CompoundTagVariant.h +++ b/src/mc/nbt/CompoundTagVariant.h @@ -105,7 +105,7 @@ class CompoundTagVariant { [[nodiscard]] bool hold() const noexcept { return std::holds_alternative(mTagStorage); } - + // consistency with json [[nodiscard]] bool is_array() const noexcept { return hold(); } [[nodiscard]] bool is_binary() const noexcept { return hold() || hold(); } [[nodiscard]] bool is_boolean() const noexcept { return hold(); } @@ -114,9 +114,9 @@ class CompoundTagVariant { [[nodiscard]] bool is_number_integer() const noexcept { return hold() || hold() || hold() || hold(); } - [[nodiscard]] bool is_number() const noexcept { return is_number_float() || is_number_integer(); } [[nodiscard]] bool is_object() const noexcept { return hold(); } [[nodiscard]] bool is_string() const noexcept { return hold(); } + [[nodiscard]] bool is_number() const noexcept { return is_number_float() || is_number_integer(); } [[nodiscard]] bool is_primitive() const noexcept { return is_null() || is_string() || is_number() || is_binary(); } [[nodiscard]] bool is_structured() const noexcept { return is_array() || is_object(); } @@ -183,7 +183,7 @@ class CompoundTagVariant { } [[nodiscard]] CompoundTagVariant& operator[](std::string const& index) { - if (hold()) { + if (is_null()) { mTagStorage = CompoundTag{}; } if (!hold()) { @@ -213,7 +213,7 @@ class CompoundTagVariant { } void push_back(CompoundTagVariant val) { - if (hold()) { + if (is_null()) { mTagStorage = ListTag{}; } if (!hold()) {