Merge branch 'main' of github.com:paulevsGitch/BCLib into main
This commit is contained in:
commit
11c116618a
4 changed files with 40 additions and 27 deletions
|
@ -4,11 +4,13 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import ru.bclib.api.datafixer.DataFixerAPI;
|
||||
import ru.bclib.api.datafixer.ForcedLevelPatch;
|
||||
import ru.bclib.api.datafixer.MigrationProfile;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.world.generator.GeneratorOptions;
|
||||
|
||||
public final class BCLibPatch {
|
||||
public static void register() {
|
||||
if (GeneratorOptions.fixBiomeSource()) {
|
||||
// TODO separate values in config on client side (config screen)
|
||||
if (Configs.MAIN_CONFIG.repairBiomes() && (GeneratorOptions.fixEndBiomeSource() || GeneratorOptions.fixNetherBiomeSource())) {
|
||||
DataFixerAPI.registerPatch(BiomeSourcePatch::new);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +31,7 @@ final class BiomeSourcePatch extends ForcedLevelPatch{
|
|||
long seed = worldGenSettings.getLong("seed");
|
||||
boolean result = false;
|
||||
|
||||
if (GeneratorOptions.fixNetherBiomeSource()) {
|
||||
if (!dimensions.contains("minecraft:the_nether") || !isBCLibEntry(dimensions.getCompound("minecraft:the_nether"))) {
|
||||
CompoundTag dimRoot = new CompoundTag();
|
||||
dimRoot.put("generator", makeNetherGenerator(seed));
|
||||
|
@ -36,7 +39,9 @@ final class BiomeSourcePatch extends ForcedLevelPatch{
|
|||
dimensions.put("minecraft:the_nether", dimRoot);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (GeneratorOptions.fixEndBiomeSource()) {
|
||||
if (!dimensions.contains("minecraft:the_end") || !isBCLibEntry(dimensions.getCompound("minecraft:the_end"))) {
|
||||
CompoundTag dimRoot = new CompoundTag();
|
||||
dimRoot.put("generator", makeEndGenerator(seed));
|
||||
|
@ -44,6 +49,7 @@ final class BiomeSourcePatch extends ForcedLevelPatch{
|
|||
dimensions.put("minecraft:the_end", dimRoot);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -283,8 +283,7 @@ public class DataFixerAPI {
|
|||
}
|
||||
@Environment(EnvType.CLIENT)
|
||||
private static void showLevelFixErrorScreen(State state, Listener onContinue){
|
||||
Minecraft.getInstance()
|
||||
.setScreen(new LevelFixErrorScreen(Minecraft.getInstance().screen, state.getErrorMessages(), onContinue));
|
||||
Minecraft.getInstance().setScreen(new LevelFixErrorScreen(Minecraft.getInstance().screen, state.getErrorMessages(), onContinue));
|
||||
}
|
||||
|
||||
private static MigrationProfile loadProfileIfNeeded(File levelBaseDir){
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.world.generator.GeneratorOptions;
|
||||
|
||||
public class MainConfig extends NamedPathConfig {
|
||||
public static final ConfigToken<Boolean> APPLY_PATCHES = ConfigToken.Boolean(true, "applyPatches", Configs.MAIN_PATCH_CATEGORY);
|
||||
|
||||
@ConfigUI(leftPadding = 8)
|
||||
public static final ConfigToken<Boolean> REPAIR_BIOMES = DependendConfigToken.Boolean(true, "fixBiomeSource", Configs.MAIN_PATCH_CATEGORY, (config) -> config.get(MainConfig.APPLY_PATCHES));
|
||||
public static final ConfigToken<Boolean> REPAIR_BIOMES = DependendConfigToken.Boolean(true, "repairBiomesOnLoad", Configs.MAIN_PATCH_CATEGORY, (config) -> config.get(APPLY_PATCHES));
|
||||
|
||||
public MainConfig() {
|
||||
super(BCLib.MOD_ID, "main", true, true);
|
||||
}
|
||||
|
||||
public boolean applyPatches() {
|
||||
return get(APPLY_PATCHES);
|
||||
}
|
||||
|
||||
public MainConfig() {
|
||||
super(BCLib.MOD_ID, "main", true, true);
|
||||
public boolean repairBiomes() {
|
||||
return get(REPAIR_BIOMES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ public class GeneratorOptions {
|
|||
private static boolean useOldBiomeGenerator = false;
|
||||
private static boolean verticalBiomes = true;
|
||||
private static long farEndBiomesSqr = 1000000;
|
||||
private static boolean fixBiomeSource = true;
|
||||
private static boolean fixEndBiomeSource = true;
|
||||
private static boolean fixNetherBiomeSource = true;
|
||||
|
||||
public static void init() {
|
||||
biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256);
|
||||
|
@ -33,8 +34,8 @@ public class GeneratorOptions {
|
|||
addEndBiomesByCategory = Configs.GENERATOR_CONFIG.getBoolean("options", "addEndBiomesByCategory", false);
|
||||
useOldBiomeGenerator = Configs.GENERATOR_CONFIG.useOldGenerator();
|
||||
verticalBiomes = Configs.GENERATOR_CONFIG.getBoolean("options", "verticalBiomesInTallNether", true);
|
||||
|
||||
fixBiomeSource = Configs.MAIN_CONFIG.get(MainConfig.REPAIR_BIOMES);
|
||||
fixEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixEndBiomeSource", true);
|
||||
fixNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixNetherBiomeSource", true);
|
||||
}
|
||||
|
||||
public static int getBiomeSizeNether() {
|
||||
|
@ -105,7 +106,11 @@ public class GeneratorOptions {
|
|||
return verticalBiomes;
|
||||
}
|
||||
|
||||
public static boolean fixBiomeSource() {
|
||||
return fixBiomeSource;
|
||||
public static boolean fixEndBiomeSource() {
|
||||
return fixEndBiomeSource;
|
||||
}
|
||||
|
||||
public static boolean fixNetherBiomeSource() {
|
||||
return fixNetherBiomeSource;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue