Skip to content

Commit

Permalink
Added support for chunk format version 3458
Browse files Browse the repository at this point in the history
Disabled SNAPSHOT option as it was redundant
  • Loading branch information
spoutn1k committed Jul 25, 2023
1 parent ed00dac commit 1c21ac9
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 41 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ PROJECT(mcmap LANGUAGES CXX VERSION 3.0.1)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

OPTION(DEBUG_BUILD "Debug build" OFF)
OPTION(SNAPSHOT "Support snapshot versions" OFF)

IF(STATIC_BUILD)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
Expand Down Expand Up @@ -63,10 +62,6 @@ ELSE()
ADD_COMPILE_OPTIONS(-O3)
ENDIF()

IF(SNAPSHOT)
ADD_DEFINITIONS(-DSNAPSHOT_SUPPORT)
ENDIF()

IF(WIN32)
# 100M stack + 3.5G heap on windows
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:104857600 /HEAP:3758096384")
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,6 @@ cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DSTATIC_BUILD=1^

You can also download and set up [Ubuntu on windows](https://ubuntu.com/tutorials/tutorial-ubuntu-on-windows#1-overview) then the steps are the same as Linux/Ubuntu.

### Snapshot support

Snapshots are unsupported by default. One can enable support by using the `SNAPSHOT` `CMake` option. In linux/macOS:
```
git clone https://github.com/spoutn1k/mcmap
mkdir -p mcmap/build && cd mcmap/build
cmake .. -DSNAPSHOT=1
make -j
```

On Windows, this will depend on the software you are using to compile `mcmap`.

## Troubleshooting

### Compilation fails
Expand Down
5 changes: 1 addition & 4 deletions src/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ namespace mcmap {

namespace versions {
std::map<int, std::function<bool(const nbt::NBT &)>> assert = {
{3465, assert_versions::v3465}, {2844, assert_versions::v2844},
#ifdef SNAPSHOT_SUPPORT
{2840, assert_versions::v2840},
#endif
{3458, assert_versions::v3458}, {2844, assert_versions::v2844},
{1976, assert_versions::v1976}, {1628, assert_versions::v1628},
{0, assert_versions::catchall},
};
Expand Down
14 changes: 2 additions & 12 deletions src/chunk_format_versions/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace mcmap {
namespace versions {
namespace assert_versions {
bool v3465(const nbt::NBT &chunk) {
// Snapshot 21w43a
bool v3458(const nbt::NBT &chunk) {
// Minecraft 1.20-pre5, randomly changing things
return chunk.contains("sections") // No sections mean no blocks
&& chunk.contains("Status") // Ensure the status is `minecraft:full`
&& chunk["Status"].get<nbt::NBT::tag_string_t>() == "minecraft:full";
Expand All @@ -17,16 +17,6 @@ bool v2844(const nbt::NBT &chunk) {
&& chunk["Status"].get<nbt::NBT::tag_string_t>() == "full";
}

#ifdef SNAPSHOT_SUPPORT
bool v2840(const nbt::NBT &chunk) {
// Snapshot 21w42a
return chunk.contains("Level") && // Level data is required
chunk["Level"].contains("Sections") // No sections mean no blocks
&& chunk["Level"].contains("Status") // Ensure the status is `full`
&& chunk["Level"]["Status"].get<nbt::NBT::tag_string_t>() == "full";
}
#endif

bool v1976(const nbt::NBT &chunk) {
// From 1.14 onwards
return chunk.contains("Level") // Level data is required
Expand Down
6 changes: 1 addition & 5 deletions src/chunk_format_versions/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
namespace mcmap {
namespace versions {
namespace assert_versions {
bool v3465(const nbt::NBT &chunk);
bool v3458(const nbt::NBT &chunk);

bool v2844(const nbt::NBT &chunk);

#ifdef SNAPSHOT_SUPPORT
bool v2840(const nbt::NBT &chunk);
#endif

bool v1976(const nbt::NBT &chunk);

bool v1628(const nbt::NBT &chunk);
Expand Down
3 changes: 0 additions & 3 deletions src/mcmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ std::map<std::string, std::string> compilation_options() {
#endif
#ifdef DEBUG_BUILD
{"Debug", "Enabled"},
#endif
#ifdef SNAPSHOT_SUPPORT
{"Snapshot compatibility", "Enabled"},
#endif
};

Expand Down

0 comments on commit 1c21ac9

Please sign in to comment.