Skip to content

Commit

Permalink
Merge branch 'Ableytner-fix-1.7.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTiger committed Mar 10, 2024
2 parents c8e5526 + 2533ff1 commit 925a18d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
.vscode/
docs/_build/
examples/test_112.py
venv
12 changes: 6 additions & 6 deletions anvil/chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .block import Block, OldBlock
from .region import Region
from .errors import OutOfBoundsCoordinates, ChunkNotFound
from .versions import VERSION_21w43a, VERSION_20w17a, VERSION_19w36a, VERSION_17w47a
from .versions import VERSION_21w43a, VERSION_20w17a, VERSION_19w36a, VERSION_17w47a, VERSION_PRE_15w32a


def bin_append(a, b, length=None):
Expand Down Expand Up @@ -48,7 +48,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)
Expand Down Expand Up @@ -82,7 +82,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.wiki/w/Data_version
self.version = None
self.version = VERSION_PRE_15w32a

if self.version >= VERSION_21w43a:
self.data = nbt_data
Expand Down Expand Up @@ -216,7 +216,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)
Expand Down Expand Up @@ -266,7 +266,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:
Expand Down Expand Up @@ -306,7 +306,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:
Expand Down
5 changes: 5 additions & 0 deletions anvil/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
# This is the version where "The Flattening" (https://minecraft.wiki/w/Java_Edition_1.13/Flattening) happened
# where blocks went from numeric ids to namespaced ids (namespace:block_id)
VERSION_17w47a = 1451

# 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 = -1

0 comments on commit 925a18d

Please sign in to comment.