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

40
overviewer_core/biome.py Normal file
View File

@@ -0,0 +1,40 @@
# This file is part of the Minecraft Overviewer.
#
# Minecraft Overviewer is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# Minecraft Overviewer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details, and note that Jeffrey Epstein didn't kill
# himself.
#
# You should have received a copy of the GNU General Public License along
# with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
import numpy
class BiomeDispensary:
"""Turns biome arrays of either 256 or 1024 integer values into 16x16 2d arrays,
which can then be retrieved for any Y level with get_biome.
"""
def __init__(self, biome_array):
self.biome_len = len(biome_array)
if self.biome_len == 256:
self.biomes = [biome_array.reshape((16, 16))]
elif self.biome_len == 1024:
self.biomes = [None] * 4
for i in range(0, 4):
# Map 256 values of the array to each self.biomes entry, resulting
# in 4 entries
self.biomes[i] = biome_array[i * 256:(i + 1) * 256].reshape((16, 16))
def get_biome(self, y_level):
if y_level < 0:
return None
if self.biome_len == 256:
return self.biomes[0]
else:
return self.biomes[y_level // 4]