Skip to content

Commit

Permalink
Fix biome palette errors when loading worlds generated with WorldPain…
Browse files Browse the repository at this point in the history
…ter.
  • Loading branch information
leMaik committed Jul 28, 2023
1 parent 002542c commit 5169ac2
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public ArrayBiomePalette(@NotNull List<Biome> palette) {

@Override
public Biome get(int id) {
assert id >= 0 && id < palette.size() : "id " + id + " out of bounds for palette";

if (id < 0 || id >= palette.size()) {
// this should not happen but is very common with WorldPainter generated worlds
return Biomes.biomesPrePalette[1];
}
return this.palette.get(id);
}

Expand All @@ -34,12 +36,12 @@ public int put(@NotNull Biome biome) {
assert biome != null;

for (int i = 0, len = this.palette.size(); i <= len; i++) {
if(i == palette.size()) { //biome must not be in palette, so add it
if (i == palette.size()) { //biome must not be in palette, so add it
this.palette.add(biome);
return i;
}

if(this.palette.get(i) == biome) { //found biome in palette, return it
if (this.palette.get(i) == biome) { //found biome in palette, return it
return i;
}
}
Expand Down

0 comments on commit 5169ac2

Please sign in to comment.