From d52e22a8cd84e2c41d9e6f8774ac095e2f6f6baa Mon Sep 17 00:00:00 2001 From: Ableytner Date: Wed, 21 Feb 2024 18:54:53 +0100 Subject: [PATCH 1/5] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 365044d..6954c3b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ NBT==1.5.1 -frozendict==1.2 +frozendict==2.0.2 From 4b5730ebdc61c75853e621f0cfb378c3ae7ee4c4 Mon Sep 17 00:00:00 2001 From: Ableytner Date: Wed, 21 Feb 2024 23:29:29 +0100 Subject: [PATCH 2/5] fix older mc versions --- anvil/chunk.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/anvil/chunk.py b/anvil/chunk.py index 2938f9e..bd2ed49 100644 --- a/anvil/chunk.py +++ b/anvil/chunk.py @@ -21,6 +21,10 @@ # where blocks went from numeric ids to namespaced ids (namespace:block_id) _VERSION_17w47a = 1451 +# This represents Versions before 1.9 snapshot 15w32a, so world does not have a Data Version. +# https://minecraft.fandom.com/wiki/Data_version +_VERSION_PRE_15w32a = 100 + def bin_append(a, b, length=None): """ @@ -97,7 +101,7 @@ def __init__(self, nbt_data: nbt.NBTFile): except KeyError: # Version is pre-1.9 snapshot 15w32a, so world does not have a Data Version. # See https://minecraft.fandom.com/wiki/Data_version - self.version = None + self.version = _VERSION_PRE_15w32a if self.version >= _VERSION_21w43a: self.data = nbt_data From 3729c7c9bd6213c639f32b72a0da60bb3551266c Mon Sep 17 00:00:00 2001 From: Ableytner Date: Fri, 23 Feb 2024 16:45:53 +0100 Subject: [PATCH 3/5] add venv to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bb9f8b6..7c1f481 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/ .vscode/ docs/_build/ examples/test_112.py +venv From a68dbfd15d3f50b3515eeb13e2929a62ad032a9b Mon Sep 17 00:00:00 2001 From: Ableytner Date: Mon, 4 Mar 2024 17:56:49 +0100 Subject: [PATCH 4/5] update fandom links --- anvil/chunk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anvil/chunk.py b/anvil/chunk.py index 90790e6..6da5a94 100644 --- a/anvil/chunk.py +++ b/anvil/chunk.py @@ -22,7 +22,7 @@ _VERSION_17w47a = 1451 # This represents Versions before 1.9 snapshot 15w32a, so world does not have a Data Version. -# https://minecraft.fandom.com/wiki/Data_version +# https://minecraft.wiki/w/Data_version _VERSION_PRE_15w32a = 100 @@ -235,7 +235,7 @@ def get_biome(self, x: int, y: int, z: int) -> Biome: # Each biome index refers to a column stored Z then X. index = z * 16 + x else: - # https://minecraft.fandom.com/wiki/Java_Edition_19w36a + # https://minecraft.wiki/w/Java_Edition_19w36a # Get index on the biome list with the order YZX # Each biome index refers to a 4x4 areas here so we do integer division by 4 index = (y // 4) * 4 * 4 + (z // 4) * 4 + (x // 4) From 2533ff1459238132c51dbebb2642b4acfd6e3e15 Mon Sep 17 00:00:00 2001 From: 0xTiger Date: Sun, 10 Mar 2024 11:56:34 +0000 Subject: [PATCH 5/5] refactor: use -1 as _VERSION_PRE_15w32a and remove None checks from version --- anvil/chunk.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/anvil/chunk.py b/anvil/chunk.py index 6da5a94..0eb73ca 100644 --- a/anvil/chunk.py +++ b/anvil/chunk.py @@ -21,9 +21,10 @@ # where blocks went from numeric ids to namespaced ids (namespace:block_id) _VERSION_17w47a = 1451 -# This represents Versions before 1.9 snapshot 15w32a, so world does not have a Data Version. +# This represents Versions before 1.9 snapshot 15w32a, +# these snapshots do not have a Data Version so we use -1 since -1 is less than any valid data version. # https://minecraft.wiki/w/Data_version -_VERSION_PRE_15w32a = 100 +_VERSION_PRE_15w32a = -1 def bin_append(a, b, length=None): @@ -67,7 +68,7 @@ def _states_from_section(section: nbt.TAG_Compound) -> list: def _section_height_range(version: Optional[int]) -> range: - if version is not None and version > _VERSION_17w47a: + if version > _VERSION_17w47a: return range(-4, 20) else: return range(16) @@ -285,7 +286,7 @@ def get_block( # global Y to section Y y %= 16 - if self.version is None or self.version < _VERSION_17w47a: + if self.version < _VERSION_17w47a: # Explained in depth here https://minecraft.wiki/w/index.php?title=Chunk_format&oldid=1153403#Block_format if section is None or "Blocks" not in section: @@ -325,7 +326,7 @@ def get_block( # Get index on the block list with the order YZX index = y * 16 * 16 + z * 16 + x # in 20w17a and newer blocks cannot occupy more than one element on the BlockStates array - stretches = self.version is None or self.version < _VERSION_20w17a + stretches = self.version < _VERSION_20w17a # get location in the BlockStates array via the index if stretches: