Fixed caves crash with non-be biome source (issue #148)

This commit is contained in:
paulevsGitch 2021-04-29 01:08:57 +03:00
parent 16b02e15bf
commit 9999abf945
3 changed files with 21 additions and 7 deletions

View file

@ -112,7 +112,9 @@ public class EndBiomes {
public static final EndCaveBiome EMPTY_AURORA_CAVE = registerCaveBiome(new EmptyAuroraCaveBiome()); public static final EndCaveBiome EMPTY_AURORA_CAVE = registerCaveBiome(new EmptyAuroraCaveBiome());
public static final EndCaveBiome LUSH_AURORA_CAVE = registerCaveBiome(new LushAuroraCaveBiome()); public static final EndCaveBiome LUSH_AURORA_CAVE = registerCaveBiome(new LushAuroraCaveBiome());
public static void register() {} public static void register() {
CAVE_BIOMES.rebuild();
}
public static void mutateRegistry(Registry<Biome> biomeRegistry) { public static void mutateRegistry(Registry<Biome> biomeRegistry) {
EndBiomes.biomeRegistry = biomeRegistry; EndBiomes.biomeRegistry = biomeRegistry;
@ -408,6 +410,15 @@ public class EndBiomes {
return ID_MAP.getOrDefault(biomeID, END); return ID_MAP.getOrDefault(biomeID, END);
} }
public static Biome getActualBiome(EndBiome biome) {
Biome actual = biome.getActualBiome();
if (actual == null) {
biome.updateActualBiomes(biomeRegistry);
actual = biome.getActualBiome();
}
return actual;
}
public static List<EndBiome> getModBiomes() { public static List<EndBiome> getModBiomes() {
List<EndBiome> result = Lists.newArrayList(); List<EndBiome> result = Lists.newArrayList();
result.addAll(EndBiomes.LAND_BIOMES.getBiomes()); result.addAll(EndBiomes.LAND_BIOMES.getBiomes());

View file

@ -117,7 +117,8 @@ public abstract class EndCaveFeature extends DefaultFeature {
private void setBiome(WorldGenLevel world, BlockPos pos, EndCaveBiome biome) { private void setBiome(WorldGenLevel world, BlockPos pos, EndCaveBiome biome) {
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomes(); IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomes();
if (array != null) { if (array != null) {
array.be_setBiome(biome.getActualBiome(), pos); Biome bio = EndBiomes.getActualBiome(biome);
array.be_setBiome(bio, pos);
} }
} }

View file

@ -89,12 +89,13 @@ public class BetterEndBiomeSource extends BiomeSource {
mapVoid.clearCache(); mapVoid.clearCache();
} }
EndBiome endBiome = null;
if (GeneratorOptions.useNewGenerator()) { if (GeneratorOptions.useNewGenerator()) {
if (TerrainGenerator.isLand(biomeX, biomeZ)) { if (TerrainGenerator.isLand(biomeX, biomeZ)) {
return mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome(); endBiome = mapLand.getBiome(biomeX << 2, biomeZ << 2);
} }
else { else {
return mapVoid.getBiome(biomeX << 2, biomeZ << 2).getActualBiome(); endBiome = mapVoid.getBiome(biomeX << 2, biomeZ << 2);
} }
} }
else { else {
@ -104,9 +105,10 @@ public class BetterEndBiomeSource extends BiomeSource {
return barrens; return barrens;
} }
EndBiome endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2) : mapLand.getBiome(biomeX << 2, biomeZ << 2); endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2) : mapLand.getBiome(biomeX << 2, biomeZ << 2);
return endBiome.getActualBiome();
} }
return EndBiomes.getActualBiome(endBiome);
} }
public Biome getLandBiome(int biomeX, int biomeY, int biomeZ) { public Biome getLandBiome(int biomeX, int biomeY, int biomeZ) {
@ -124,7 +126,7 @@ public class BetterEndBiomeSource extends BiomeSource {
return this.centerBiome; return this.centerBiome;
} }
} }
return mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome(); return EndBiomes.getActualBiome(mapLand.getBiome(biomeX << 2, biomeZ << 2));
} }
@Override @Override