Merge branch 'main' of github.com:paulevsGitch/BCLib into main

This commit is contained in:
Frank 2022-01-03 18:52:20 +01:00
commit 11c116618a
4 changed files with 40 additions and 27 deletions

View file

@ -4,11 +4,13 @@ import net.minecraft.nbt.CompoundTag;
import ru.bclib.api.datafixer.DataFixerAPI; import ru.bclib.api.datafixer.DataFixerAPI;
import ru.bclib.api.datafixer.ForcedLevelPatch; import ru.bclib.api.datafixer.ForcedLevelPatch;
import ru.bclib.api.datafixer.MigrationProfile; import ru.bclib.api.datafixer.MigrationProfile;
import ru.bclib.config.Configs;
import ru.bclib.world.generator.GeneratorOptions; import ru.bclib.world.generator.GeneratorOptions;
public final class BCLibPatch { public final class BCLibPatch {
public static void register(){ 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); DataFixerAPI.registerPatch(BiomeSourcePatch::new);
} }
} }
@ -29,20 +31,24 @@ final class BiomeSourcePatch extends ForcedLevelPatch{
long seed = worldGenSettings.getLong("seed"); long seed = worldGenSettings.getLong("seed");
boolean result = false; boolean result = false;
if (!dimensions.contains("minecraft:the_nether") || !isBCLibEntry(dimensions.getCompound("minecraft:the_nether"))) { if (GeneratorOptions.fixNetherBiomeSource()) {
CompoundTag dimRoot = new CompoundTag(); if (!dimensions.contains("minecraft:the_nether") || !isBCLibEntry(dimensions.getCompound("minecraft:the_nether"))) {
dimRoot.put("generator", makeNetherGenerator(seed)); CompoundTag dimRoot = new CompoundTag();
dimRoot.putString("type", "minecraft:the_nether"); dimRoot.put("generator", makeNetherGenerator(seed));
dimensions.put("minecraft:the_nether", dimRoot); dimRoot.putString("type", "minecraft:the_nether");
result = true; dimensions.put("minecraft:the_nether", dimRoot);
result = true;
}
} }
if (!dimensions.contains("minecraft:the_end") || !isBCLibEntry(dimensions.getCompound("minecraft:the_end"))) { if (GeneratorOptions.fixEndBiomeSource()) {
CompoundTag dimRoot = new CompoundTag(); if (!dimensions.contains("minecraft:the_end") || !isBCLibEntry(dimensions.getCompound("minecraft:the_end"))) {
dimRoot.put("generator", makeEndGenerator(seed)); CompoundTag dimRoot = new CompoundTag();
dimRoot.putString("type", "minecraft:the_end"); dimRoot.put("generator", makeEndGenerator(seed));
dimensions.put("minecraft:the_end", dimRoot); dimRoot.putString("type", "minecraft:the_end");
result = true; dimensions.put("minecraft:the_end", dimRoot);
result = true;
}
} }
return result; return result;

View file

@ -283,8 +283,7 @@ public class DataFixerAPI {
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private static void showLevelFixErrorScreen(State state, Listener onContinue){ private static void showLevelFixErrorScreen(State state, Listener onContinue){
Minecraft.getInstance() Minecraft.getInstance().setScreen(new LevelFixErrorScreen(Minecraft.getInstance().screen, state.getErrorMessages(), onContinue));
.setScreen(new LevelFixErrorScreen(Minecraft.getInstance().screen, state.getErrorMessages(), onContinue));
} }
private static MigrationProfile loadProfileIfNeeded(File levelBaseDir){ private static MigrationProfile loadProfileIfNeeded(File levelBaseDir){

View file

@ -1,19 +1,22 @@
package ru.bclib.config; package ru.bclib.config;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.world.generator.GeneratorOptions;
public class MainConfig extends NamedPathConfig { public class MainConfig extends NamedPathConfig {
public static final ConfigToken<Boolean> APPLY_PATCHES = ConfigToken.Boolean(true, "applyPatches", Configs.MAIN_PATCH_CATEGORY); public static final ConfigToken<Boolean> APPLY_PATCHES = ConfigToken.Boolean(true, "applyPatches", Configs.MAIN_PATCH_CATEGORY);
@ConfigUI(leftPadding = 8) @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 boolean applyPatches() {
return get(APPLY_PATCHES);
}
public MainConfig() { public MainConfig() {
super(BCLib.MOD_ID, "main", true, true); super(BCLib.MOD_ID, "main", true, true);
} }
public boolean applyPatches() {
return get(APPLY_PATCHES);
}
public boolean repairBiomes() {
return get(REPAIR_BIOMES);
}
} }

View file

@ -20,7 +20,8 @@ public class GeneratorOptions {
private static boolean useOldBiomeGenerator = false; private static boolean useOldBiomeGenerator = false;
private static boolean verticalBiomes = true; private static boolean verticalBiomes = true;
private static long farEndBiomesSqr = 1000000; private static long farEndBiomesSqr = 1000000;
private static boolean fixBiomeSource = true; private static boolean fixEndBiomeSource = true;
private static boolean fixNetherBiomeSource = true;
public static void init() { public static void init() {
biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256); biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256);
@ -33,8 +34,8 @@ public class GeneratorOptions {
addEndBiomesByCategory = Configs.GENERATOR_CONFIG.getBoolean("options", "addEndBiomesByCategory", false); addEndBiomesByCategory = Configs.GENERATOR_CONFIG.getBoolean("options", "addEndBiomesByCategory", false);
useOldBiomeGenerator = Configs.GENERATOR_CONFIG.useOldGenerator(); useOldBiomeGenerator = Configs.GENERATOR_CONFIG.useOldGenerator();
verticalBiomes = Configs.GENERATOR_CONFIG.getBoolean("options", "verticalBiomesInTallNether", true); verticalBiomes = Configs.GENERATOR_CONFIG.getBoolean("options", "verticalBiomesInTallNether", true);
fixEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixEndBiomeSource", true);
fixBiomeSource = Configs.MAIN_CONFIG.get(MainConfig.REPAIR_BIOMES); fixNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixNetherBiomeSource", true);
} }
public static int getBiomeSizeNether() { public static int getBiomeSizeNether() {
@ -105,7 +106,11 @@ public class GeneratorOptions {
return verticalBiomes; return verticalBiomes;
} }
public static boolean fixBiomeSource() { public static boolean fixEndBiomeSource() {
return fixBiomeSource; return fixEndBiomeSource;
}
public static boolean fixNetherBiomeSource() {
return fixNetherBiomeSource;
} }
} }