diff --git a/src/NBT/ByteArrayTag.hpp b/src/NBT/ByteArrayTag.hpp index 0d58dc8..95e9ddb 100644 --- a/src/NBT/ByteArrayTag.hpp +++ b/src/NBT/ByteArrayTag.hpp @@ -37,7 +37,7 @@ namespace NBT { class ByteArrayTag : public Tag { private: uint32_t len; - const uint8_t *value; + const uint8_t *ptr; public: static const MakeType Type; @@ -45,7 +45,7 @@ public: ByteArrayTag(Buffer *buffer) { len = buffer->get32(); - value = buffer->get(len); + ptr = buffer->get(len); } virtual const TagType & getType() const { @@ -58,7 +58,7 @@ public: std::string inner = indent + " "; for (size_t i = 0; i < len; i++) { - uint8_t v = value[i]; + uint8_t v = ptr[i]; os << inner << (unsigned)v << " / " @@ -74,8 +74,12 @@ public: return len; } - const uint8_t * getValue() const { - return value; + const uint8_t * getPointer() const { + return ptr; + } + + uint8_t getValue(size_t i) const { + return ptr[i]; } }; diff --git a/src/NBT/LongArrayTag.hpp b/src/NBT/LongArrayTag.hpp index 545798f..2e24d5a 100644 --- a/src/NBT/LongArrayTag.hpp +++ b/src/NBT/LongArrayTag.hpp @@ -77,6 +77,10 @@ public: const uint8_t * getPointer() const { return ptr; } + + uint64_t getValue(size_t i) const { + return Buffer::parse64(&ptr[8*i]); + } }; } diff --git a/src/World/Chunk.hpp b/src/World/Chunk.hpp index 8451cbe..77299ec 100644 --- a/src/World/Chunk.hpp +++ b/src/World/Chunk.hpp @@ -58,7 +58,7 @@ private: uint8_t getBiomeAt(size_t x, size_t z) const { if (biomeBytes) - return biomeBytes->getValue()[z*SIZE + x]; + return biomeBytes->getValue(z*SIZE + x); else return biomeInts->getValue(z*SIZE + x); } diff --git a/src/World/Section.hpp b/src/World/Section.hpp index 4ba1c89..58c3799 100644 --- a/src/World/Section.hpp +++ b/src/World/Section.hpp @@ -78,7 +78,7 @@ public: if (!blockLight) return 0; - return getHalf(blockLight->getValue(), x, y, z); + return getHalf(blockLight->getPointer(), x, y, z); } static std::unique_ptr
makeSection(const std::shared_ptr §ion, uint32_t dataVersion); @@ -91,11 +91,11 @@ private: uint8_t getBlockAt(size_t x, size_t y, size_t z) const { - return blocks->getValue()[getIndex(x, y, z)]; + return blocks->getValue(getIndex(x, y, z)); } uint8_t getDataAt(size_t x, size_t y, size_t z) const { - return getHalf(data->getValue(), x, y, z); + return getHalf(data->getPointer(), x, y, z); } public: