Reformated

This commit is contained in:
Frank 2022-06-08 20:57:21 +02:00
parent 079b51e3f6
commit 852e5a6abc
385 changed files with 6924 additions and 5656 deletions

View file

@ -1,24 +1,28 @@
package org.betterx.bclib.presets;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.api.v2.tag.TagType;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.FlatLevelGeneratorPresetTags;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorPreset;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.api.v2.tag.TagType;
public class FlatLevelPresets {
public static TagType.Simple<FlatLevelGeneratorPreset> FLAT_LEVEL_PRESETS =
TagAPI.registerType(Registry.FLAT_LEVEL_GENERATOR_PRESET_REGISTRY,
"tags/worldgen/flat_level_generator_preset",
(b) -> null);
TagAPI.registerType(
Registry.FLAT_LEVEL_GENERATOR_PRESET_REGISTRY,
"tags/worldgen/flat_level_generator_preset",
(b) -> null
);
public static ResourceKey<FlatLevelGeneratorPreset> register(ResourceLocation loc) {
ResourceKey<FlatLevelGeneratorPreset> key = ResourceKey.create(Registry.FLAT_LEVEL_GENERATOR_PRESET_REGISTRY,
loc);
ResourceKey<FlatLevelGeneratorPreset> key = ResourceKey.create(
Registry.FLAT_LEVEL_GENERATOR_PRESET_REGISTRY,
loc
);
FLAT_LEVEL_PRESETS.addUntyped(FlatLevelGeneratorPresetTags.VISIBLE, key.location());
return key;
}

View file

@ -1,5 +1,9 @@
package org.betterx.bclib.presets.worldgen;
import org.betterx.bclib.mixin.common.WorldPresetAccessor;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.resources.RegistryFileCodec;
@ -7,10 +11,6 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import org.betterx.bclib.mixin.common.WorldPresetAccessor;
import java.util.Map;
public class BCLWorldPreset extends WorldPreset {
@ -37,7 +37,8 @@ public class BCLWorldPreset extends WorldPreset {
public static final Codec<Holder<WorldPreset>> CODEC = RegistryFileCodec.create(
Registry.WORLD_PRESET_REGISTRY,
(Codec<WorldPreset>) ((Object) DIRECT_CODEC));
(Codec<WorldPreset>) ((Object) DIRECT_CODEC)
);
public BCLWorldPreset(Map<ResourceKey<LevelStem>, LevelStem> map, int sortOrder, WorldPresetSettings settings) {
super(map);
@ -46,7 +47,7 @@ public class BCLWorldPreset extends WorldPreset {
}
private Map<ResourceKey<LevelStem>, LevelStem> getDimensions() {
return WorldPresetAccessor.class.cast(this).bcl_getDimensions();
return ((WorldPresetAccessor) this).bcl_getDimensions();
}
}

View file

@ -1,5 +1,17 @@
package org.betterx.bclib.presets.worldgen;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleUtil;
import org.betterx.bclib.interfaces.ChunkGeneratorAccessor;
import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
@ -12,18 +24,6 @@ import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleUtil;
import org.betterx.bclib.interfaces.ChunkGeneratorAccessor;
import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@ -63,16 +63,21 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
return CODEC;
}
public BCLWorldPreset buildPreset(LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext) {
public BCLWorldPreset buildPreset(
LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext
) {
return new BCLWorldPreset(buildDimensionMap(overworldStem, netherContext, endContext), 1000, this);
}
public Map<ResourceKey<LevelStem>, LevelStem> buildDimensionMap(LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext) {
return Map.of(LevelStem.OVERWORLD,
public Map<ResourceKey<LevelStem>, LevelStem> buildDimensionMap(
LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext
) {
return Map.of(
LevelStem.OVERWORLD,
overworldStem,
LevelStem.NETHER,
createNetherStem(netherContext),
@ -109,10 +114,13 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
return biomeSource;
}
public Holder<NoiseGeneratorSettings> fixNoiseSettings(Holder<NoiseGeneratorSettings> settings,
BiomeSource biomeSource) {
public Holder<NoiseGeneratorSettings> fixNoiseSettings(
Holder<NoiseGeneratorSettings> settings,
BiomeSource biomeSource
) {
NoiseGeneratorSettings old = settings.value();
NoiseGeneratorSettings noise = new NoiseGeneratorSettings(old.noiseSettings(),
NoiseGeneratorSettings noise = new NoiseGeneratorSettings(
old.noiseSettings(),
old.defaultBlock(),
old.defaultFluid(),
old.noiseRouter(),
@ -122,7 +130,8 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
old.disableMobGeneration(),
old.aquifersEnabled(),
old.oreVeinsEnabled(),
old.useLegacyRandomSource());
old.useLegacyRandomSource()
);
return Holder.direct(noise);
@ -138,9 +147,11 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
* @param settings
* @return
*/
public WorldGenSettings fixSettingsInCurrentWorld(RegistryAccess access, ResourceKey<LevelStem> dimensionKey,
ResourceKey<DimensionType> dimensionTypeKey,
WorldGenSettings settings) {
public WorldGenSettings fixSettingsInCurrentWorld(
RegistryAccess access, ResourceKey<LevelStem> dimensionKey,
ResourceKey<DimensionType> dimensionTypeKey,
WorldGenSettings settings
) {
Optional<Holder<LevelStem>> loadedStem = settings.dimensions().getHolder(dimensionKey);
final ChunkGenerator loadedChunkGenerator = loadedStem.map(h -> h.value().generator()).orElse(null);
final int loaderVersion = LevelGenUtil.getBiomeVersionForGenerator(loadedStem
@ -171,7 +182,8 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
final Set<Holder<Biome>> biomes = loadedChunkGenerator.getBiomeSource().possibleBiomes();
final BiomeSource bs = fixBiomeSource(referenceGenerator.getBiomeSource(), biomes);
InternalBiomeAPI.applyModifications(bs, dimensionKey);
referenceGenerator = new BCLChunkGenerator(generator.bclib_getStructureSetsRegistry(),
referenceGenerator = new BCLChunkGenerator(
generator.bclib_getStructureSetsRegistry(),
noiseProvider.bclib_getNoises(),
bs,
fixNoiseSettings(noiseProvider.bclib_getNoiseGeneratorSettingHolders(), bs)
@ -179,11 +191,13 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
}
}
return LevelGenUtil.replaceGenerator(dimensionKey,
return LevelGenUtil.replaceGenerator(
dimensionKey,
dimensionTypeKey,
access,
settings,
referenceGenerator);
referenceGenerator
);
} else {
BCLChunkGenerator.injectNoiseSettings(dimensionKey, loadedChunkGenerator);
}

View file

@ -1,5 +1,11 @@
package org.betterx.bclib.presets.worldgen;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.api.v2.tag.TagType;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
@ -9,11 +15,6 @@ import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import com.google.common.collect.Maps;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.api.v2.tag.TagType;
import java.util.Map;
import java.util.Optional;
@ -23,23 +24,29 @@ public class BCLWorldPresets {
public static final TagType.Simple<WorldPreset> WORLD_PRESETS =
TagAPI.registerType(BuiltinRegistries.WORLD_PRESET, "tags/worldgen/world_preset");
private static Map<ResourceKey<WorldPreset>, PresetBuilder> BUILDERS = Maps.newHashMap();
private static Map<ResourceKey<WorldPreset>, WorldPresetSettings> SETTINGS = Maps.newHashMap();
private static final Map<ResourceKey<WorldPreset>, WorldPresetSettings> SETTINGS = Maps.newHashMap();
public static final ResourceKey<WorldPreset> BCL_WORLD =
register(BCLib.makeID("normal"),
register(
BCLib.makeID("normal"),
(overworldStem, netherContext, endContext) ->
new BCLWorldPresetSettings(BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION).buildPreset(
overworldStem,
netherContext,
endContext),
true);
endContext
),
true
);
public static Optional<ResourceKey<WorldPreset>> DEFAULT = Optional.of(BCL_WORLD);
public static final ResourceKey<WorldPreset> BCL_WORLD_17 = register(BCLib.makeID("legacy_17"),
public static final ResourceKey<WorldPreset> BCL_WORLD_17 = register(
BCLib.makeID("legacy_17"),
(overworldStem, netherContext, endContext) ->
new BCLWorldPresetSettings(BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE).buildPreset(
overworldStem,
netherContext,
endContext),
false);
endContext
),
false
);
/**
* Registers a custom WorldPreset (with custom rules and behaviour)
@ -67,9 +74,11 @@ public class BCLWorldPresets {
}
public static ResourceKey<WorldPreset> register(ResourceLocation loc,
PresetBuilder builder,
boolean visibleInUI) {
public static ResourceKey<WorldPreset> register(
ResourceLocation loc,
PresetBuilder builder,
boolean visibleInUI
) {
ResourceKey<WorldPreset> key = register(loc, visibleInUI);
if (BUILDERS == null) {
@ -81,10 +90,12 @@ public class BCLWorldPresets {
return key;
}
public static void bootstrapPresets(Registry<WorldPreset> presets,
LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext) {
public static void bootstrapPresets(
Registry<WorldPreset> presets,
LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext
) {
for (Map.Entry<ResourceKey<WorldPreset>, PresetBuilder> e : BUILDERS.entrySet()) {
BCLWorldPreset preset = e.getValue().create(overworldStem, netherContext, endContext);
@ -100,8 +111,10 @@ public class BCLWorldPresets {
@FunctionalInterface
public interface PresetBuilder {
BCLWorldPreset create(LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext);
BCLWorldPreset create(
LevelStem overworldStem,
LevelGenUtil.Context netherContext,
LevelGenUtil.Context endContext
);
}
}

View file

@ -1,5 +1,9 @@
package org.betterx.bclib.presets.worldgen;
import org.betterx.bclib.BCLib;
import com.mojang.serialization.Codec;
import com.mojang.serialization.Lifecycle;
import net.minecraft.core.MappedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
@ -7,10 +11,6 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import com.mojang.serialization.Codec;
import com.mojang.serialization.Lifecycle;
import org.betterx.bclib.BCLib;
import java.util.function.Function;
public abstract class WorldPresetSettings {
@ -34,8 +34,10 @@ public abstract class WorldPresetSettings {
return new MappedRegistry<>(resourceKey, Lifecycle.stable(), null);
}
public static Codec<? extends WorldPresetSettings> register(ResourceLocation loc,
Codec<? extends WorldPresetSettings> codec) {
public static Codec<? extends WorldPresetSettings> register(
ResourceLocation loc,
Codec<? extends WorldPresetSettings> codec
) {
return Registry.register(WORLD_PRESET_SETTINGS, loc, codec);
}