Generator options init fix
This commit is contained in:
parent
c2015848b0
commit
015d60aee1
5 changed files with 53 additions and 54 deletions
|
@ -18,6 +18,7 @@ import ru.bclib.registry.BaseRegistry;
|
|||
import ru.bclib.util.Logger;
|
||||
import ru.bclib.world.generator.BCLibEndBiomeSource;
|
||||
import ru.bclib.world.generator.BCLibNetherBiomeSource;
|
||||
import ru.bclib.world.generator.GeneratorOptions;
|
||||
import ru.bclib.world.surface.BCLSurfaceBuilders;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -29,6 +30,7 @@ public class BCLib implements ModInitializer {
|
|||
@Override
|
||||
public void onInitialize() {
|
||||
BaseRegistry.register();
|
||||
GeneratorOptions.init();
|
||||
BaseBlockEntities.register();
|
||||
BCLSurfaceBuilders.register();
|
||||
BCLibEndBiomeSource.register();
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biome.ClimateParameters;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.interfaces.BiomeListProvider;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
@ -40,18 +41,18 @@ public class BiomeAPI {
|
|||
private static final Map<Biome, BCLBiome> CLIENT = Maps.newHashMap();
|
||||
private static Registry<Biome> biomeRegistry;
|
||||
|
||||
public static final BCLBiome NETHER_WASTES_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("nether_wastes")));
|
||||
public static final BCLBiome CRIMSON_FOREST_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("crimson_forest")));
|
||||
public static final BCLBiome WARPED_FOREST_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("warped_forest")));
|
||||
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("soul_sand_valley")));
|
||||
public static final BCLBiome BASALT_DELTAS_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("basalt_deltas")));
|
||||
public static final BCLBiome NETHER_WASTES_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("nether_wastes")));
|
||||
public static final BCLBiome CRIMSON_FOREST_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("crimson_forest")));
|
||||
public static final BCLBiome WARPED_FOREST_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("warped_forest")));
|
||||
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("soul_sand_valley")));
|
||||
public static final BCLBiome BASALT_DELTAS_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("basalt_deltas")));
|
||||
|
||||
public static final BCLBiome THE_END = registerEndLandBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("the_end")));
|
||||
public static final BCLBiome END_MIDLANDS = registerSubBiome(THE_END, BuiltinRegistries.BIOME.get(new ResourceLocation("end_midlands")), 0.5F);
|
||||
public static final BCLBiome END_HIGHLANDS = registerSubBiome(THE_END, BuiltinRegistries.BIOME.get(new ResourceLocation("end_highlands")), 0.5F);
|
||||
public static final BCLBiome THE_END = registerEndLandBiome(getFromRegistry(new ResourceLocation("the_end")));
|
||||
public static final BCLBiome END_MIDLANDS = registerSubBiome(THE_END, getFromRegistry(new ResourceLocation("end_midlands")), 0.5F);
|
||||
public static final BCLBiome END_HIGHLANDS = registerSubBiome(THE_END, getFromRegistry(new ResourceLocation("end_highlands")), 0.5F);
|
||||
|
||||
public static final BCLBiome END_BARRENS = registerEndVoidBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("end_barrens")));
|
||||
public static final BCLBiome SMALL_END_ISLANDS = registerEndVoidBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("small_end_islands")));
|
||||
public static final BCLBiome END_BARRENS = registerEndVoidBiome(getFromRegistry(new ResourceLocation("end_barrens")));
|
||||
public static final BCLBiome SMALL_END_ISLANDS = registerEndVoidBiome(getFromRegistry(new ResourceLocation("small_end_islands")));
|
||||
|
||||
/**
|
||||
* Initialize registry for current server.
|
||||
|
@ -282,12 +283,13 @@ public class BiomeAPI {
|
|||
return ID_MAP.getOrDefault(biomeID, EMPTY_BIOME);
|
||||
}
|
||||
|
||||
/**
|
||||
/** Use inner biome field instead.
|
||||
* Get actual {@link Biome} from given {@link BCLBiome}. If it is null it will request it from current {@link Registry}.
|
||||
*
|
||||
* @param biome - {@link BCLBiome}.
|
||||
* @return {@link Biome}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static Biome getActualBiome(BCLBiome biome) {
|
||||
Biome actual = biome.getActualBiome();
|
||||
if (actual == null) {
|
||||
|
@ -327,11 +329,12 @@ public class BiomeAPI {
|
|||
return biomeList == null ? Collections.emptyList() : biomeList.getBiomes();
|
||||
}
|
||||
|
||||
public static boolean isNetherBiome(ResourceLocation biomeID) {
|
||||
return NETHER_BIOME_PICKER.contains(biomeID);
|
||||
@Nullable
|
||||
public static Biome getFromRegistry(ResourceLocation biomeID) {
|
||||
return BuiltinRegistries.BIOME.get(biomeID);
|
||||
}
|
||||
|
||||
public static boolean isEndBiome(ResourceLocation biomeID) {
|
||||
return END_LAND_BIOME_PICKER.contains(biomeID) || END_VOID_BIOME_PICKER.contains(biomeID);
|
||||
public static boolean isDatapackBiome(ResourceLocation biomeID) {
|
||||
return getFromRegistry(biomeID) == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class DimensionTypeMixin {
|
|||
info.setReturnValue(new NoiseBasedChunkGenerator(
|
||||
new BCLibNetherBiomeSource(biomeRegistry, seed),
|
||||
seed,
|
||||
() -> chunkGeneratorSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END)
|
||||
() -> chunkGeneratorSettingsRegistry.getOrThrow(NoiseGeneratorSettings.NETHER)
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue