Generator options init fix

This commit is contained in:
paulevsGitch 2021-08-14 00:18:21 +03:00
parent c2015848b0
commit 015d60aee1
5 changed files with 53 additions and 54 deletions

View file

@ -6,6 +6,7 @@ import net.minecraft.core.Registry;
import net.minecraft.resources.RegistryLookupCodec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.TheEndBiomeSource;
@ -42,6 +43,19 @@ public class BCLibEndBiomeSource extends BiomeSource {
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
super(getBiomes(biomeRegistry));
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();
this.possibleBiomes.forEach(biome -> {
ResourceLocation key = biomeRegistry.getKey(biome);
BCLBiome bclBiome = BiomeAPI.getBiome(key);
bclBiome.updateActualBiomes(biomeRegistry);
if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key)) {
BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome);
}
});
BiomeAPI.END_LAND_BIOME_PICKER.rebuild();
BiomeAPI.END_VOID_BIOME_PICKER.rebuild();
this.mapLand = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_BIOME_PICKER);
this.mapVoid = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER);
this.centerBiome = biomeRegistry.getOrThrow(Biomes.THE_END);
@ -58,22 +72,11 @@ public class BCLibEndBiomeSource extends BiomeSource {
}
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();
biomeRegistry.forEach(biome -> {
ResourceLocation key = biomeRegistry.getKey(biome);
BCLBiome bclBiome = BiomeAPI.getBiome(key);
bclBiome.updateActualBiomes(biomeRegistry);
if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key)) {
BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome);
}
});
BiomeAPI.END_LAND_BIOME_PICKER.rebuild();
BiomeAPI.END_VOID_BIOME_PICKER.rebuild();
return biomeRegistry.stream().filter(biome -> {
ResourceLocation key = biomeRegistry.getKey(biome);
return BiomeAPI.END_LAND_BIOME_PICKER.contains(key) || BiomeAPI.END_VOID_BIOME_PICKER.contains(key);
return BiomeAPI.END_LAND_BIOME_PICKER.contains(key) ||
BiomeAPI.END_VOID_BIOME_PICKER.contains(key) ||
(BiomeAPI.isDatapackBiome(key) && biome.getBiomeCategory() == BiomeCategory.THEEND);
}).toList();
}
@ -84,7 +87,7 @@ public class BCLibEndBiomeSource extends BiomeSource {
long check = GeneratorOptions.isFarEndBiomes() ? 65536L : 625L;
long dist = i + j;
if ((biomeX & 31) == 0 && (biomeZ & 31) == 0) {
if ((biomeX & 63) == 0 && (biomeZ & 63) == 0) {
mapLand.clearCache();
mapVoid.clearCache();
}

View file

@ -6,19 +6,13 @@ import net.minecraft.core.Registry;
import net.minecraft.resources.RegistryLookupCodec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.TheEndBiomeSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
import ru.bclib.BCLib;
import ru.bclib.api.BiomeAPI;
import ru.bclib.noise.OpenSimplexNoise;
import ru.bclib.world.biomes.BCLBiome;
import java.awt.Point;
import java.util.List;
import java.util.function.Function;
public class BCLibNetherBiomeSource extends BiomeSource {
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
@ -35,17 +29,8 @@ public class BCLibNetherBiomeSource extends BiomeSource {
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
super(getBiomes(biomeRegistry));
this.biomeMap = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.NETHER_BIOME_PICKER);
this.biomeRegistry = biomeRegistry;
this.seed = seed;
WorldgenRandom chunkRandom = new WorldgenRandom(seed);
chunkRandom.consumeCount(17292);
}
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
biomeRegistry.forEach(biome -> {
this.possibleBiomes.forEach(biome -> {
ResourceLocation key = biomeRegistry.getKey(biome);
BCLBiome bclBiome = BiomeAPI.getBiome(key);
bclBiome.updateActualBiomes(biomeRegistry);
@ -55,18 +40,24 @@ public class BCLibNetherBiomeSource extends BiomeSource {
});
BiomeAPI.NETHER_BIOME_PICKER.rebuild();
return biomeRegistry.stream().filter(biome -> BiomeAPI.NETHER_BIOME_PICKER.contains(biomeRegistry.getKey(biome))).toList();
this.biomeMap = new BiomeMap(seed, GeneratorOptions.getBiomeSizeNether(), BiomeAPI.NETHER_BIOME_PICKER);
this.biomeRegistry = biomeRegistry;
this.seed = seed;
}
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
return biomeRegistry.stream().filter(biome -> {
ResourceLocation key = biomeRegistry.getKey(biome);
return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) ||
(BiomeAPI.isDatapackBiome(key) && biome.getBiomeCategory() == BiomeCategory.NETHER);
}).toList();
}
@Override
public Biome getNoiseBiome(int biomeX, int biomeY, int biomeZ) {
long i = (long) biomeX * (long) biomeX;
long j = (long) biomeZ * (long) biomeZ;
if ((biomeX & 31) == 0 && (biomeZ & 31) == 0) {
if ((biomeX & 63) == 0 && (biomeZ & 63) == 0) {
biomeMap.clearCache();
}
return biomeMap.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
}