0

Fix biomes for Minecraft 1.15

Fixes #1650.

Mojang changed the biomes code so that it now can have different
biomes for different Y levels. We need to adjust our logic accordingly,
which is done through some small BiomeDispensary class where we shove
a numpy'd Mojang array in and can then read out the biomes for each level.

Biome data is now stored per-section, which needed some changes on the C
side of things. I didn't change anything in the biome overlay code so
I wouldn't be surprised if it's broken now, but for the time being I'd
rather have 1.15 fixed than some obscure overlay.

Tested to work with 1.14 and 1.15 data. No new biomes have been added
to the code yet.
This commit is contained in:
Nicolas F
2019-12-10 23:12:16 +01:00
parent 9607636d49
commit 268938a706
4 changed files with 57 additions and 14 deletions

View File

@@ -26,6 +26,7 @@ import numpy
from . import nbt
from . import cache
from .biome import BiomeDispensary
"""
This module has routines for extracting information about available worlds
@@ -1370,13 +1371,15 @@ class RegionSet(object):
biomes = numpy.frombuffer(biomes, dtype=numpy.uint8)
else:
biomes = numpy.asarray(biomes)
biomes = biomes.reshape((16,16))
#biomes = biomes.reshape((16,16))
biome_giver = BiomeDispensary(biomes)
else:
# Worlds converted by Jeb's program may be missing the Biomes key.
# Additionally, 19w09a worlds have an empty array as biomes key
# in some cases.
biomes = numpy.zeros((16, 16), dtype=numpy.uint8)
chunk_data['Biomes'] = biomes
#biomes = numpy.zeros((16, 16), dtype=numpy.uint8)
biome_giver = BiomeDispensary(numpy.zeros(256, dtype=numpy.uint8))
#chunk_data['Biomes'] = biomes
unrecognized_block_types = {}
for section in chunk_data['Sections']:
@@ -1384,6 +1387,7 @@ class RegionSet(object):
# Turn the skylight array into a 16x16x16 matrix. The array comes
# packed 2 elements per byte, so we need to expand it.
try:
section['Biomes'] = biome_giver.get_biome(section["Y"])
if 'SkyLight' in section:
skylight = numpy.frombuffer(section['SkyLight'], dtype=numpy.uint8)
skylight = skylight.reshape((16,16,8))
@@ -1607,6 +1611,9 @@ class RotatedRegionSet(RegionSetWrapper):
for section in chunk_data['Sections']:
section = dict(section)
newsections.append(section)
biomes = numpy.swapaxes(section['Biomes'], 0, 1)
biomes = numpy.rot90(biomes, self.north_dir)
section['Biomes'] = numpy.swapaxes(biomes, 0, 1)
for arrayname in ['Blocks', 'Data', 'SkyLight', 'BlockLight']:
array = section[arrayname]
# Since the anvil change, arrays are arranged with axes Y,Z,X
@@ -1619,9 +1626,6 @@ class RotatedRegionSet(RegionSetWrapper):
chunk_data['Sections'] = newsections
# same as above, for biomes (Z/X indexed)
biomes = numpy.swapaxes(chunk_data['Biomes'], 0, 1)
biomes = numpy.rot90(biomes, self.north_dir)
chunk_data['Biomes'] = numpy.swapaxes(biomes, 0, 1)
return chunk_data
def get_chunk_mtime(self, x, z):