Bounds check biomes length before using.

Missed the diff by Mojang that added this, apparently some
ancient code created zero-length biomes.
This commit is contained in:
Spottedleaf 2021-12-17 06:38:18 -08:00
parent 62a868c3e4
commit 8671893fb5

View file

@ -16107,25 +16107,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final MapType<String>[] ret = new MapType[wantExtendedHeight ? 24 : 16];
+
+ final int[] biomes = level.getInts("Biomes");
+ if (biomes == null) {
+ final ListType palette = Types.NBT.createEmptyList();
+ palette.addString("minecraft:plains");
+
+ for (int i = 0; i < ret.length; ++i) {
+ ret[i] = wrapPalette(palette.copy()); // copy palette so that later possible modifications don't trash all sections
+ }
+
+ return ret;
+ }
+
+ final boolean isExtended = biomes.length == 1536; // magic value for 24 sections of biomes (24 * 4^3)
+ isAlreadyExtended.setValue(isExtended);
+
+ if (isExtended) {
+ if (biomes != null && biomes.length == 1536) { // magic value for 24 sections of biomes (24 * 4^3)
+ isAlreadyExtended.setValue(true);
+ for (int sectionIndex = 0; sectionIndex < 24; ++sectionIndex) {
+ ret[sectionIndex] = createBiomeSection(biomes, sectionIndex * 64, -1); // -1 is all 1s
+ }
+ } else {
+ } else if (biomes != null && biomes.length == 1024) { // magic value for 24 sections of biomes (16 * 4^3)
+ for (int sectionY = 0; sectionY < 16; ++sectionY) {
+ ret[sectionY - minSection] = createBiomeSection(biomes, sectionY * 64, -1); // -1 is all 1s
+ }
@ -16143,6 +16131,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ ret[sectionIndex] = topCopy.copy(); // copy palette so that later possible modifications don't trash all sections
+ }
+ }
+ } else {
+ final ListType palette = Types.NBT.createEmptyList();
+ palette.addString("minecraft:plains");
+
+ for (int i = 0; i < ret.length; ++i) {
+ ret[i] = wrapPalette(palette.copy()); // copy palette so that later possible modifications don't trash all sections
+ }
+ }
+
+ return ret;