diff --git a/src/main/generated/data/bclib/worldgen/noise_settings/amplified_nether.json b/src/main/generated/data/bclib/worldgen/noise_settings/amplified_nether.json deleted file mode 100644 index af1d8561..00000000 --- a/src/main/generated/data/bclib/worldgen/noise_settings/amplified_nether.json +++ /dev/null @@ -1,737 +0,0 @@ -{ - "aquifers_enabled": false, - "default_block": { - "Name": "minecraft:netherrack" - }, - "default_fluid": { - "Name": "minecraft:lava", - "Properties": { - "level": "0" - } - }, - "disable_mob_generation": false, - "legacy_random_source": true, - "noise": { - "height": 256, - "min_y": 0, - "size_horizontal": 1, - "size_vertical": 4 - }, - "noise_router": { - "barrier": 0.0, - "continents": 0.0, - "depth": 0.0, - "erosion": 0.0, - "final_density": { - "type": "minecraft:squeeze", - "argument": { - "type": "minecraft:mul", - "argument1": 0.64, - "argument2": { - "type": "minecraft:interpolated", - "argument": { - "type": "minecraft:blend_density", - "argument": { - "type": "minecraft:add", - "argument1": 2.5, - "argument2": { - "type": "minecraft:mul", - "argument1": { - "type": "minecraft:y_clamped_gradient", - "from_value": 0.0, - "from_y": -8, - "to_value": 1.0, - "to_y": 24 - }, - "argument2": { - "type": "minecraft:add", - "argument1": -2.5, - "argument2": { - "type": "minecraft:add", - "argument1": 0.9375, - "argument2": { - "type": "minecraft:mul", - "argument1": { - "type": "minecraft:y_clamped_gradient", - "from_value": 1.0, - "from_y": 232, - "to_value": 0.0, - "to_y": 256 - }, - "argument2": { - "type": "minecraft:add", - "argument1": -0.9375, - "argument2": "minecraft:nether/base_3d_noise" - } - } - } - } - } - } - } - } - } - }, - "fluid_level_floodedness": 0.0, - "fluid_level_spread": 0.0, - "initial_density_without_jaggedness": 0.0, - "lava": 0.0, - "ridges": 0.0, - "temperature": { - "type": "minecraft:shifted_noise", - "noise": "minecraft:temperature", - "shift_x": "minecraft:shift_x", - "shift_y": 0.0, - "shift_z": "minecraft:shift_z", - "xz_scale": 0.25, - "y_scale": 0.0 - }, - "vegetation": { - "type": "minecraft:shifted_noise", - "noise": "minecraft:vegetation", - "shift_x": "minecraft:shift_x", - "shift_y": 0.0, - "shift_z": "minecraft:shift_z", - "xz_scale": 0.25, - "y_scale": 0.0 - }, - "vein_gap": 0.0, - "vein_ridged": 0.0, - "vein_toggle": 0.0 - }, - "ore_veins_enabled": false, - "sea_level": 32, - "spawn_target": [], - "surface_rule": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:vertical_gradient", - "false_at_and_above": { - "above_bottom": 5 - }, - "random_name": "minecraft:bedrock_floor", - "true_at_and_below": { - "above_bottom": 0 - } - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:bedrock" - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:vertical_gradient", - "false_at_and_above": { - "below_top": 0 - }, - "random_name": "minecraft:bedrock_roof", - "true_at_and_below": { - "below_top": 5 - } - } - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:bedrock" - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": false, - "anchor": { - "below_top": 5 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:netherrack" - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:biome", - "biome_is": [ - "minecraft:basalt_deltas" - ] - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:stone_depth", - "add_surface_depth": true, - "offset": 0, - "secondary_depth_range": 0, - "surface_type": "ceiling" - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:basalt", - "Properties": { - "axis": "y" - } - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:stone_depth", - "add_surface_depth": true, - "offset": 0, - "secondary_depth_range": 0, - "surface_type": "floor" - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": -0.012, - "noise": "minecraft:patch" - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": true, - "anchor": { - "absolute": 30 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:y_above", - "add_stone_depth": true, - "anchor": { - "absolute": 35 - }, - "surface_depth_multiplier": 0 - } - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:gravel" - } - } - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": 0.0, - "noise": "minecraft:nether_state_selector" - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:basalt", - "Properties": { - "axis": "y" - } - } - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:blackstone" - } - } - ] - } - } - ] - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:biome", - "biome_is": [ - "minecraft:soul_sand_valley" - ] - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:stone_depth", - "add_surface_depth": true, - "offset": 0, - "secondary_depth_range": 0, - "surface_type": "ceiling" - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": 0.0, - "noise": "minecraft:nether_state_selector" - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:soul_sand" - } - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:soul_soil" - } - } - ] - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:stone_depth", - "add_surface_depth": true, - "offset": 0, - "secondary_depth_range": 0, - "surface_type": "floor" - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": -0.012, - "noise": "minecraft:patch" - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": true, - "anchor": { - "absolute": 30 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:y_above", - "add_stone_depth": true, - "anchor": { - "absolute": 35 - }, - "surface_depth_multiplier": 0 - } - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:gravel" - } - } - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": 0.0, - "noise": "minecraft:nether_state_selector" - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:soul_sand" - } - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:soul_soil" - } - } - ] - } - } - ] - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:stone_depth", - "add_surface_depth": false, - "offset": 0, - "secondary_depth_range": 0, - "surface_type": "floor" - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:y_above", - "add_stone_depth": false, - "anchor": { - "absolute": 32 - }, - "surface_depth_multiplier": 0 - } - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:hole" - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:lava", - "Properties": { - "level": "0" - } - } - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:biome", - "biome_is": [ - "minecraft:warped_forest" - ] - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": 0.54, - "noise": "minecraft:netherrack" - } - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": false, - "anchor": { - "absolute": 31 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": 1.17, - "noise": "minecraft:nether_wart" - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:warped_wart_block" - } - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:warped_nylium" - } - } - ] - } - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:biome", - "biome_is": [ - "minecraft:crimson_forest" - ] - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": 0.54, - "noise": "minecraft:netherrack" - } - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": false, - "anchor": { - "absolute": 31 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": 1.17, - "noise": "minecraft:nether_wart" - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:nether_wart_block" - } - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:crimson_nylium" - } - } - ] - } - } - } - } - ] - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:biome", - "biome_is": [ - "minecraft:nether_wastes" - ] - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:stone_depth", - "add_surface_depth": true, - "offset": 0, - "secondary_depth_range": 0, - "surface_type": "floor" - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": -0.012, - "noise": "minecraft:soul_sand_layer" - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:hole" - } - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": true, - "anchor": { - "absolute": 30 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:y_above", - "add_stone_depth": true, - "anchor": { - "absolute": 35 - }, - "surface_depth_multiplier": 0 - } - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:soul_sand" - } - } - } - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:netherrack" - } - } - ] - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:stone_depth", - "add_surface_depth": false, - "offset": 0, - "secondary_depth_range": 0, - "surface_type": "floor" - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": false, - "anchor": { - "absolute": 31 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:y_above", - "add_stone_depth": true, - "anchor": { - "absolute": 35 - }, - "surface_depth_multiplier": 0 - } - }, - "then_run": { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:noise_threshold", - "max_threshold": 1.7976931348623157E308, - "min_threshold": -0.012, - "noise": "minecraft:gravel_layer" - }, - "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:y_above", - "add_stone_depth": false, - "anchor": { - "absolute": 32 - }, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:gravel" - } - } - }, - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:not", - "invert": { - "type": "minecraft:hole" - } - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:gravel" - } - } - } - ] - } - } - } - } - } - ] - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:netherrack" - } - } - ] - } -} \ No newline at end of file diff --git a/src/main/java/org/betterx/bclib/api/v2/generator/BCLChunkGenerator.java b/src/main/java/org/betterx/bclib/api/v2/generator/BCLChunkGenerator.java deleted file mode 100644 index b297c2e7..00000000 --- a/src/main/java/org/betterx/bclib/api/v2/generator/BCLChunkGenerator.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.betterx.bclib.api.v2.generator; - -import org.betterx.bclib.BCLib; -import org.betterx.bclib.api.v2.levelgen.LevelGenUtil; -import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider; -import org.betterx.bclib.mixin.common.ChunkGeneratorAccessor; -import org.betterx.worlds.together.WorldsTogether; -import org.betterx.worlds.together.biomesource.MergeableBiomeSource; -import org.betterx.worlds.together.biomesource.ReloadableBiomeSource; -import org.betterx.worlds.together.chunkgenerator.EnforceableChunkGenerator; -import org.betterx.worlds.together.chunkgenerator.InjectableSurfaceRules; -import org.betterx.worlds.together.chunkgenerator.RestorableBiomeSource; -import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings; - -import com.mojang.datafixers.DSL; -import com.mojang.datafixers.types.templates.TypeTemplate; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.Holder; -import net.minecraft.core.HolderGetter; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.Registries; -import net.minecraft.data.worldgen.BootstapContext; -import net.minecraft.data.worldgen.SurfaceRuleData; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.biome.BiomeGenerationSettings; -import net.minecraft.world.level.biome.BiomeSource; -import net.minecraft.world.level.biome.FeatureSorter; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.dimension.DimensionType; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.levelgen.*; - -import com.google.common.base.Suppliers; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Supplier; - -public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements RestorableBiomeSource, InjectableSurfaceRules, EnforceableChunkGenerator { - - public static final Codec CODEC = RecordCodecBuilder - .create((RecordCodecBuilder.Instance builderInstance) -> { - - RecordCodecBuilder biomeSourceCodec = BiomeSource.CODEC - .fieldOf("biome_source") - .forGetter((BCLChunkGenerator generator) -> generator.biomeSource); - - RecordCodecBuilder> settingsCodec = NoiseGeneratorSettings.CODEC - .fieldOf("settings") - .forGetter((BCLChunkGenerator generator) -> generator.generatorSettings()); - - - return builderInstance.group(biomeSourceCodec, settingsCodec) - .apply(builderInstance, builderInstance.stable(BCLChunkGenerator::new)); - }); - protected static final NoiseSettings NETHER_NOISE_SETTINGS_AMPLIFIED = NoiseSettings.create(0, 256, 1, 4); - public static final ResourceKey AMPLIFIED_NETHER = ResourceKey.create( - Registries.NOISE_SETTINGS, - BCLib.makeID("amplified_nether") - ); - - public final BiomeSource initialBiomeSource; - - public BCLChunkGenerator( - BiomeSource biomeSource, - Holder holder - ) { - super(biomeSource, holder); - initialBiomeSource = biomeSource; - if (biomeSource instanceof BiomeSourceWithNoiseRelatedSettings bcl && holder.isBound()) { - bcl.onLoadGeneratorSettings(holder.value()); - } - - if (WorldsTogether.RUNS_TERRABLENDER) { - BCLib.LOGGER.info("Make sure features are loaded from terrablender:" + biomeSource.getClass().getName()); - - //terrablender is invalidating the feature initialization - //we redo it at this point, otherwise we will get blank biomes - rebuildFeaturesPerStep(biomeSource); - } - } - - private void rebuildFeaturesPerStep(BiomeSource biomeSource) { - if (this instanceof ChunkGeneratorAccessor acc) { - Function, BiomeGenerationSettings> function = (Holder hh) -> hh.value() - .getGenerationSettings(); - - acc.bcl_setFeaturesPerStep(Suppliers.memoize(() -> FeatureSorter.buildFeaturesPerStep( - List.copyOf(biomeSource.possibleBiomes()), - (hh) -> function.apply(hh).features(), - true - ))); - } - } - - /** - * Other Mods like TerraBlender might inject new BiomeSources. We undo that change after the world setup did run. - * - * @param dimensionKey The Dimension where this ChunkGenerator is used from - */ - @Override - public void restoreInitialBiomeSource(ResourceKey dimensionKey) { - if (initialBiomeSource != getBiomeSource()) { - if (this instanceof ChunkGeneratorAccessor acc) { - if (initialBiomeSource instanceof MergeableBiomeSource bs) { - acc.bcl_setBiomeSource(bs.mergeWithBiomeSource(getBiomeSource())); - } else if (initialBiomeSource instanceof ReloadableBiomeSource bs) { - bs.reloadBiomes(); - } - - rebuildFeaturesPerStep(getBiomeSource()); - } - } - } - - - @Override - protected Codec codec() { - return CODEC; - } - - @Override - public String toString() { - return "BCLib - Chunk Generator (" + Integer.toHexString(hashCode()) + ")"; - } - - // This method is injected by Terrablender. - // We make sure terrablender does not rewrite the feature-set for our ChunkGenerator by overwriting the - // Mixin-Method with an empty implementation - public void appendFeaturesPerStep() { - } - - @Override - public Registry enforceGeneratorInWorldGenSettings( - RegistryAccess access, - ResourceKey dimensionKey, - ResourceKey dimensionTypeKey, - ChunkGenerator loadedChunkGenerator, - Registry dimensionRegistry - ) { - BCLib.LOGGER.info("Enforcing Correct Generator for " + dimensionKey.location().toString() + "."); - - ChunkGenerator referenceGenerator = this; - if (loadedChunkGenerator instanceof org.betterx.bclib.interfaces.ChunkGeneratorAccessor generator) { - if (loadedChunkGenerator instanceof NoiseGeneratorSettingsProvider noiseProvider) { - if (referenceGenerator instanceof NoiseGeneratorSettingsProvider referenceProvider) { - final BiomeSource bs; - if (referenceGenerator.getBiomeSource() instanceof MergeableBiomeSource mbs) { - bs = mbs.mergeWithBiomeSource(loadedChunkGenerator.getBiomeSource()); - } else { - bs = referenceGenerator.getBiomeSource(); - } - - referenceProvider.bclib_getNoiseGeneratorSettingHolders(); - referenceGenerator = new BCLChunkGenerator( - bs, - noiseProvider.bclib_getNoiseGeneratorSettingHolders() - ); - } - } - } - - return LevelGenUtil.replaceGenerator( - dimensionKey, - dimensionTypeKey, - access, - dimensionRegistry, - referenceGenerator - ); - } - - - public static NoiseGeneratorSettings amplifiedNether(BootstapContext bootstapContext) { - HolderGetter densityGetter = bootstapContext.lookup(Registries.DENSITY_FUNCTION); - return new NoiseGeneratorSettings( - NETHER_NOISE_SETTINGS_AMPLIFIED, - Blocks.NETHERRACK.defaultBlockState(), - Blocks.LAVA.defaultBlockState(), - NoiseRouterData.noNewCaves( - densityGetter, - bootstapContext.lookup(Registries.NOISE), - NoiseRouterData.slideNetherLike(densityGetter, 0, 256) - ), - SurfaceRuleData.nether(), - List.of(), - 32, - false, - false, - false, - true - ); - } - - public static Map> addGeneratorDSL(Map> map) { - if (map.containsKey("minecraft:flat")) { - Map> nMap = new HashMap<>(map); - nMap.put("bclib:betterx", DSL::remainder); - return nMap; - } - return map; - } -} diff --git a/src/main/java/org/betterx/bclib/api/v2/levelgen/LevelGenUtil.java b/src/main/java/org/betterx/bclib/api/v2/levelgen/LevelGenUtil.java deleted file mode 100644 index 5fba12ad..00000000 --- a/src/main/java/org/betterx/bclib/api/v2/levelgen/LevelGenUtil.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.betterx.bclib.api.v2.levelgen; - -import org.betterx.bclib.api.v2.generator.BCLChunkGenerator; -import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource; -import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource; -import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig; -import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig; -import org.betterx.worlds.together.levelgen.WorldGenUtil; - -import com.mojang.serialization.Lifecycle; -import net.minecraft.core.Holder; -import net.minecraft.core.MappedRegistry; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.dimension.DimensionType; -import net.minecraft.world.level.dimension.LevelStem; - -import java.util.Map; -import org.jetbrains.annotations.NotNull; - -public class LevelGenUtil { - private static final String TAG_VERSION = "version"; - private static final String TAG_BN_GEN_VERSION = "generator_version"; - - @NotNull - public static LevelStem getBCLNetherLevelStem(WorldGenUtil.Context context, BCLNetherBiomeSourceConfig config) { - BCLibNetherBiomeSource netherSource = new BCLibNetherBiomeSource(config); - - return new LevelStem( - context.dimension, - new BCLChunkGenerator( - netherSource, - context.generatorSettings - ) - ); - } - - public static LevelStem getBCLEndLevelStem(WorldGenUtil.Context context, BCLEndBiomeSourceConfig config) { - BCLibEndBiomeSource endSource = new BCLibEndBiomeSource(config); - return new LevelStem( - context.dimension, - new BCLChunkGenerator( - endSource, - context.generatorSettings - ) - ); - } - - - public static Registry replaceGenerator( - ResourceKey dimensionKey, - ResourceKey dimensionTypeKey, - RegistryAccess registryAccess, - Registry dimensionRegistry, - ChunkGenerator generator - ) { - Registry dimensionTypeRegistry = registryAccess.registryOrThrow(Registries.DIMENSION_TYPE); - Registry newDimensions = withDimension( - dimensionKey, - dimensionTypeKey, - dimensionTypeRegistry, - dimensionRegistry, - generator - ); - return newDimensions; - } - - public static Registry withDimension( - ResourceKey dimensionKey, - ResourceKey dimensionTypeKey, - Registry dimensionTypeRegistry, - Registry inputDimensions, - ChunkGenerator generator - ) { - - LevelStem levelStem = inputDimensions.get(dimensionKey); - Holder dimensionType = levelStem == null - ? dimensionTypeRegistry.getHolderOrThrow(dimensionTypeKey) - : levelStem.type(); - return withDimension(dimensionKey, inputDimensions, new LevelStem(dimensionType, generator)); - } - - public static Registry withDimension( - ResourceKey dimensionKey, - Registry inputDimensions, - LevelStem levelStem - ) { - MappedRegistry writableRegistry = new MappedRegistry<>( - Registries.LEVEL_STEM, - Lifecycle.experimental() - ); - writableRegistry.register( - dimensionKey, - levelStem, - Lifecycle.stable() - ); - for (Map.Entry, LevelStem> entry : inputDimensions.entrySet()) { - ResourceKey resourceKey = entry.getKey(); - if (resourceKey == dimensionKey) continue; - writableRegistry.register( - resourceKey, - entry.getValue(), - inputDimensions.lifecycle(entry.getValue()) - ); - } - return writableRegistry; - } -} diff --git a/src/main/java/org/betterx/bclib/api/v2/levelgen/biomes/BCLBiomeBuilder.java b/src/main/java/org/betterx/bclib/api/v2/levelgen/biomes/BCLBiomeBuilder.java index 0ff99334..bb3385f5 100644 --- a/src/main/java/org/betterx/bclib/api/v2/levelgen/biomes/BCLBiomeBuilder.java +++ b/src/main/java/org/betterx/bclib/api/v2/levelgen/biomes/BCLBiomeBuilder.java @@ -8,7 +8,6 @@ import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor; import org.betterx.bclib.util.CollectionsUtil; import org.betterx.bclib.util.Pair; import org.betterx.ui.ColorUtil; -import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry; import org.betterx.worlds.together.tag.v3.TagManager; import net.minecraft.core.Holder; @@ -953,7 +952,6 @@ public class BCLBiomeBuilder { final T bclBiome = biomeConstructor.apply(ResourceKey.create(Registries.BIOME, biomeID), settings); tags.forEach(tagKey -> TagManager.BIOMES.add(tagKey, bclBiome.getBiomeKey())); - SurfaceRuleRegistry.registerRule(biomeID, surfaceRule, biomeID); bclBiome.addClimateParameters(parameters); if (biomeType != null) bclBiome._setIntendedType(biomeType); diff --git a/src/main/java/org/betterx/bclib/commands/DumpDatapack.java b/src/main/java/org/betterx/bclib/commands/DumpDatapack.java index 258298fe..b9552ff9 100644 --- a/src/main/java/org/betterx/bclib/commands/DumpDatapack.java +++ b/src/main/java/org/betterx/bclib/commands/DumpDatapack.java @@ -5,8 +5,6 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry; import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData; import org.betterx.bclib.blocks.BaseStairsBlock; -import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule; -import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry; import com.mojang.brigadier.Command; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -169,10 +167,7 @@ public class DumpDatapack { new Dumper<>((DimensionType v) -> DimensionType.DIRECT_CODEC) ); DUMPERS.put(BCLBiomeRegistry.BCL_BIOMES_REGISTRY.location(), new Dumper<>((BCLBiome v) -> v.codec().codec())); - DUMPERS.put( - SurfaceRuleRegistry.SURFACE_RULES_REGISTRY.location(), - new Dumper<>((AssignedSurfaceRule v) -> AssignedSurfaceRule.CODEC) - ); + DUMPERS.put( Registries.CONFIGURED_CARVER.location(), new Dumper<>((ConfiguredWorldCarver v) -> ConfiguredWorldCarver.DIRECT_CODEC) diff --git a/src/main/java/org/betterx/bclib/interfaces/NoiseGeneratorSettingsProvider.java b/src/main/java/org/betterx/bclib/interfaces/NoiseGeneratorSettingsProvider.java deleted file mode 100644 index 6a407e42..00000000 --- a/src/main/java/org/betterx/bclib/interfaces/NoiseGeneratorSettingsProvider.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.betterx.bclib.interfaces; - -import net.minecraft.core.Holder; -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; - -public interface NoiseGeneratorSettingsProvider { - NoiseGeneratorSettings bclib_getNoiseGeneratorSettings(); - Holder bclib_getNoiseGeneratorSettingHolders(); -} diff --git a/src/main/java/org/betterx/bclib/mixin/common/ChunkGeneratorAccessor.java b/src/main/java/org/betterx/bclib/mixin/common/ChunkGeneratorAccessor.java deleted file mode 100644 index 39a8e25e..00000000 --- a/src/main/java/org/betterx/bclib/mixin/common/ChunkGeneratorAccessor.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.betterx.bclib.mixin.common; - -import net.minecraft.world.level.biome.BiomeSource; -import net.minecraft.world.level.biome.FeatureSorter; -import net.minecraft.world.level.chunk.ChunkGenerator; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; -import java.util.function.Supplier; - -@Mixin(ChunkGenerator.class) -public interface ChunkGeneratorAccessor { - @Accessor("biomeSource") - @Mutable - void bcl_setBiomeSource(BiomeSource biomeSource); - - @Accessor("featuresPerStep") - @Mutable - void bcl_setFeaturesPerStep(Supplier> supplier); -} diff --git a/src/main/java/org/betterx/bclib/mixin/common/ChunkGeneratorsMixin.java b/src/main/java/org/betterx/bclib/mixin/common/ChunkGeneratorsMixin.java deleted file mode 100644 index f7602586..00000000 --- a/src/main/java/org/betterx/bclib/mixin/common/ChunkGeneratorsMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.betterx.bclib.mixin.common; - -import org.betterx.bclib.BCLib; -import org.betterx.bclib.api.v2.generator.BCLChunkGenerator; - -import com.mojang.serialization.Codec; -import net.minecraft.core.Registry; -import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.chunk.ChunkGenerators; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ChunkGenerators.class) -public class ChunkGeneratorsMixin { - @Inject(method = "bootstrap", at = @At(value = "HEAD")) - private static void bcl_bootstrap( - Registry> registry, - CallbackInfoReturnable> cir - ) { - Registry.register(registry, BCLib.makeID("betterx"), BCLChunkGenerator.CODEC); - } -} diff --git a/src/main/java/org/betterx/bclib/mixin/common/MissingDimensionFixMixin.java b/src/main/java/org/betterx/bclib/mixin/common/MissingDimensionFixMixin.java deleted file mode 100644 index e1cdcef1..00000000 --- a/src/main/java/org/betterx/bclib/mixin/common/MissingDimensionFixMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.betterx.bclib.mixin.common; - -import com.mojang.datafixers.DSL; -import net.minecraft.util.datafix.fixes.MissingDimensionFix; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -import java.util.HashMap; -import java.util.Map; - -@Mixin(MissingDimensionFix.class) -public class MissingDimensionFixMixin { - @ModifyArg(method = "makeRule", at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/DSL;taggedChoiceType(Ljava/lang/String;Lcom/mojang/datafixers/types/Type;Ljava/util/Map;)Lcom/mojang/datafixers/types/Type;")) - Map bcl_addGenerator(Map map) { - - if (map.containsKey("minecraft:flat")) { - Map nMap = new HashMap<>(map); - nMap.put("bclib:betterx", DSL.remainderType()); - return nMap; - } - return map; - } -} diff --git a/src/main/java/org/betterx/bclib/mixin/common/NoiseBasedChunkGeneratorMixin.java b/src/main/java/org/betterx/bclib/mixin/common/NoiseBasedChunkGeneratorMixin.java deleted file mode 100644 index 348ff2d3..00000000 --- a/src/main/java/org/betterx/bclib/mixin/common/NoiseBasedChunkGeneratorMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.betterx.bclib.mixin.common; - -import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider; -import org.betterx.bclib.interfaces.SurfaceProvider; - -import net.minecraft.core.Holder; -import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(NoiseBasedChunkGenerator.class) -public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider, NoiseGeneratorSettingsProvider { - @Final - @Shadow - protected Holder settings; - - - @Override - public NoiseGeneratorSettings bclib_getNoiseGeneratorSettings() { - return settings.value(); - } - - @Override - public Holder bclib_getNoiseGeneratorSettingHolders() { - return settings; - } -} diff --git a/src/main/java/org/betterx/bclib/mixin/common/V2551Mixin.java b/src/main/java/org/betterx/bclib/mixin/common/V2551Mixin.java deleted file mode 100644 index 52668135..00000000 --- a/src/main/java/org/betterx/bclib/mixin/common/V2551Mixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.betterx.bclib.mixin.common; - - -import org.betterx.bclib.api.v2.generator.BCLChunkGenerator; - -import com.mojang.datafixers.types.templates.TypeTemplate; -import net.minecraft.util.datafix.schemas.V2551; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -import java.util.Map; -import java.util.function.Supplier; - -@Mixin(V2551.class) -public class V2551Mixin { - @ModifyArg(method = "method_28297", at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/DSL;taggedChoiceLazy(Ljava/lang/String;Lcom/mojang/datafixers/types/Type;Ljava/util/Map;)Lcom/mojang/datafixers/types/templates/TaggedChoice;")) - private static Map> bcl_addGenerator(Map> map) { - return BCLChunkGenerator.addGeneratorDSL(map); - } -} - diff --git a/src/main/java/org/betterx/bclib/mixin/common/V2832Mixin.java b/src/main/java/org/betterx/bclib/mixin/common/V2832Mixin.java deleted file mode 100644 index 09c83fc9..00000000 --- a/src/main/java/org/betterx/bclib/mixin/common/V2832Mixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.betterx.bclib.mixin.common; - -import org.betterx.bclib.api.v2.generator.BCLChunkGenerator; - -import com.mojang.datafixers.types.templates.TypeTemplate; -import net.minecraft.util.datafix.schemas.V2832; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -import java.util.Map; -import java.util.function.Supplier; - -@Mixin(V2832.class) -public class V2832Mixin { - @ModifyArg(method = "method_38837", at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/DSL;taggedChoiceLazy(Ljava/lang/String;Lcom/mojang/datafixers/types/Type;Ljava/util/Map;)Lcom/mojang/datafixers/types/templates/TaggedChoice;")) - private static Map> bcl_addGenerator(Map> map) { - return BCLChunkGenerator.addGeneratorDSL(map); - } -} diff --git a/src/main/java/org/betterx/datagen/bclib/BCLRegistrySupplier.java b/src/main/java/org/betterx/datagen/bclib/BCLRegistrySupplier.java index f3db410a..2fefa16a 100644 --- a/src/main/java/org/betterx/datagen/bclib/BCLRegistrySupplier.java +++ b/src/main/java/org/betterx/datagen/bclib/BCLRegistrySupplier.java @@ -9,15 +9,11 @@ import org.betterx.datagen.bclib.tests.TestConfiguredFeatures; import org.betterx.datagen.bclib.tests.TestPlacedFeatures; import org.betterx.datagen.bclib.tests.TestStructure; import org.betterx.datagen.bclib.worldgen.BiomeDatagenProvider; -import org.betterx.datagen.bclib.worldgen.NoiseTypesDataProvider; import org.betterx.datagen.bclib.worldgen.VanillaBCLBiomesDataProvider; import org.betterx.worlds.together.WorldsTogether; -import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule; -import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry; import net.minecraft.core.registries.Registries; import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.structure.Structure; @@ -45,7 +41,6 @@ public class BCLRegistrySupplier extends RegistrySupplier { BiomeData.CODEC, VanillaBCLBiomesDataProvider::bootstrap ); - registries.addUnfiltered(SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, AssignedSurfaceRule.CODEC); if (BCLib.ADD_TEST_DATA) { registries.add(Registries.STRUCTURE, Structure.DIRECT_CODEC, TestStructure::bootstrap); @@ -61,12 +56,6 @@ public class BCLRegistrySupplier extends RegistrySupplier { registries.add(Registries.BIOME, Biome.DIRECT_CODEC, BiomeDatagenProvider::bootstrap); } - registries.add( - Registries.NOISE_SETTINGS, - NoiseGeneratorSettings.DIRECT_CODEC, - NoiseTypesDataProvider::bootstrap - ); - return registries; } } diff --git a/src/main/java/org/betterx/datagen/bclib/worldgen/NoiseTypesDataProvider.java b/src/main/java/org/betterx/datagen/bclib/worldgen/NoiseTypesDataProvider.java deleted file mode 100644 index 049dc206..00000000 --- a/src/main/java/org/betterx/datagen/bclib/worldgen/NoiseTypesDataProvider.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.betterx.datagen.bclib.worldgen; - -import org.betterx.bclib.api.v2.generator.BCLChunkGenerator; - -import net.minecraft.data.worldgen.BootstapContext; -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; - -public class NoiseTypesDataProvider { - public static void bootstrap(BootstapContext bootstrapContext) { - bootstrapContext.register( - BCLChunkGenerator.AMPLIFIED_NETHER, - BCLChunkGenerator.amplifiedNether(bootstrapContext) - ); - } - -} diff --git a/src/main/java/org/betterx/worlds/together/WorldsTogether.java b/src/main/java/org/betterx/worlds/together/WorldsTogether.java index b35162be..790b5548 100644 --- a/src/main/java/org/betterx/worlds/together/WorldsTogether.java +++ b/src/main/java/org/betterx/worlds/together/WorldsTogether.java @@ -1,6 +1,5 @@ package org.betterx.worlds.together; -import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry; import org.betterx.worlds.together.tag.v3.TagManager; import org.betterx.worlds.together.util.Logger; import org.betterx.worlds.together.world.WorldConfig; @@ -24,8 +23,6 @@ public class WorldsTogether { public static void onInitialize() { TagManager.ensureStaticallyLoaded(); - SurfaceRuleRegistry.ensureStaticallyLoaded(); - WorldConfig.registerModCache(WorldsTogether.MOD_ID); } diff --git a/src/main/java/org/betterx/worlds/together/chunkgenerator/ChunkGeneratorUtils.java b/src/main/java/org/betterx/worlds/together/chunkgenerator/ChunkGeneratorUtils.java deleted file mode 100644 index 16b71593..00000000 --- a/src/main/java/org/betterx/worlds/together/chunkgenerator/ChunkGeneratorUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.betterx.worlds.together.chunkgenerator; - -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.dimension.LevelStem; - -public class ChunkGeneratorUtils { - public static void restoreOriginalBiomeSourceInAllDimension(Registry dimensionRegistry) { - for (var entry : dimensionRegistry.entrySet()) { - ResourceKey key = entry.getKey(); - LevelStem stem = entry.getValue(); - - if (stem.generator() instanceof RestorableBiomeSource generator) { - generator.restoreInitialBiomeSource(key); - } - } - } - - -} diff --git a/src/main/java/org/betterx/worlds/together/chunkgenerator/EnforceableChunkGenerator.java b/src/main/java/org/betterx/worlds/together/chunkgenerator/EnforceableChunkGenerator.java deleted file mode 100644 index 9fa29286..00000000 --- a/src/main/java/org/betterx/worlds/together/chunkgenerator/EnforceableChunkGenerator.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.betterx.worlds.together.chunkgenerator; - -import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig; -import org.betterx.worlds.together.biomesource.MergeableBiomeSource; - -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.biome.BiomeSource; -import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.dimension.DimensionType; -import net.minecraft.world.level.dimension.LevelStem; - -public interface EnforceableChunkGenerator { - Registry enforceGeneratorInWorldGenSettings( - RegistryAccess access, - ResourceKey dimensionKey, - ResourceKey dimensionTypeKey, - ChunkGenerator loadedChunkGenerator, - Registry dimensionRegistry - ); - - default boolean togetherShouldRepair(ChunkGenerator chunkGenerator) { - ChunkGenerator self = (ChunkGenerator) this; - if (this == chunkGenerator || chunkGenerator == null) return false; - - BiomeSource one = self.getBiomeSource(); - BiomeSource two = chunkGenerator.getBiomeSource(); - if (one == two) return false; - - if (one instanceof BiomeSourceWithConfig ba && two instanceof BiomeSourceWithConfig bb) { - if (!ba.getTogetherConfig().couldSetWithoutRepair(bb.getTogetherConfig())) - return true; - } - if (one instanceof MergeableBiomeSource ba) { - if (ba.togetherShouldMerge(two)) - return true; - } - - return !one.getClass().isAssignableFrom(two.getClass()) && !two.getClass().isAssignableFrom(one.getClass()); - } -} diff --git a/src/main/java/org/betterx/worlds/together/chunkgenerator/InjectableSurfaceRules.java b/src/main/java/org/betterx/worlds/together/chunkgenerator/InjectableSurfaceRules.java deleted file mode 100644 index 3307d907..00000000 --- a/src/main/java/org/betterx/worlds/together/chunkgenerator/InjectableSurfaceRules.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.betterx.worlds.together.chunkgenerator; - -import org.betterx.worlds.together.surfaceRules.SurfaceRuleUtil; - -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; - -public interface InjectableSurfaceRules { - /** - * Called when the Surface Rules for this BiomeSource need to be - * - * @param dimensionKey The Dimension for which this injection is performed - */ - default void injectSurfaceRules(ResourceKey dimensionKey) { - if (this instanceof NoiseBasedChunkGenerator nbc) { - SurfaceRuleUtil.injectSurfaceRules(dimensionKey, nbc.generatorSettings().value(), nbc.getBiomeSource()); - } - } -} diff --git a/src/main/java/org/betterx/worlds/together/chunkgenerator/RestorableBiomeSource.java b/src/main/java/org/betterx/worlds/together/chunkgenerator/RestorableBiomeSource.java deleted file mode 100644 index 11ca787f..00000000 --- a/src/main/java/org/betterx/worlds/together/chunkgenerator/RestorableBiomeSource.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.betterx.worlds.together.chunkgenerator; - -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.dimension.LevelStem; - -public interface RestorableBiomeSource { - void restoreInitialBiomeSource(ResourceKey dimensionKey); -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/client/CreateWorldScreen_Mixin.java b/src/main/java/org/betterx/worlds/together/mixin/client/CreateWorldScreen_Mixin.java index 3f25d54e..127013a4 100644 --- a/src/main/java/org/betterx/worlds/together/mixin/client/CreateWorldScreen_Mixin.java +++ b/src/main/java/org/betterx/worlds/together/mixin/client/CreateWorldScreen_Mixin.java @@ -2,10 +2,7 @@ package org.betterx.worlds.together.mixin.client; import org.betterx.worlds.together.world.event.WorldBootstrap; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; -import net.minecraft.client.gui.screens.worldselection.WorldCreationContext; import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState; import net.minecraft.world.level.storage.LevelStorageSource; @@ -13,11 +10,9 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Optional; -import java.util.OptionalLong; @Mixin(CreateWorldScreen.class) public abstract class CreateWorldScreen_Mixin { @@ -27,22 +22,10 @@ public abstract class CreateWorldScreen_Mixin { @Shadow private boolean recreated; - @Inject(method = "", at = @At("TAIL")) - private void wt_init( - Minecraft minecraft, - Screen screen, - WorldCreationContext worldCreationContext, - Optional optional, - OptionalLong optionalLong, - CallbackInfo ci - ) { - //WorldBootstrap.InGUI.registryReadyOnNewWorld(worldGenSettingsComponent); - } //this is called when a new world is first created @Inject(method = "createNewWorldDirectory", at = @At("RETURN")) void wt_createNewWorld(CallbackInfoReturnable> cir) { - WorldBootstrap.InGUI.registryReadyOnNewWorld(this.getUiState().getSettings()); - WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.getUiState(), this.recreated); + WorldBootstrap.Helpers.onRegistryReady(this.getUiState().getSettings().worldgenLoadContext()); } } diff --git a/src/main/java/org/betterx/worlds/together/mixin/client/WorldOpenFlowsMixin.java b/src/main/java/org/betterx/worlds/together/mixin/client/WorldOpenFlowsMixin.java index 28314a71..efc922d3 100644 --- a/src/main/java/org/betterx/worlds/together/mixin/client/WorldOpenFlowsMixin.java +++ b/src/main/java/org/betterx/worlds/together/mixin/client/WorldOpenFlowsMixin.java @@ -1,18 +1,11 @@ package org.betterx.worlds.together.mixin.client; -import org.betterx.worlds.together.WorldsTogether; import org.betterx.worlds.together.world.event.WorldBootstrap; import com.mojang.serialization.Dynamic; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.GenericDirtMessageScreen; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.chat.Component; -import net.minecraft.world.level.LevelSettings; -import net.minecraft.world.level.levelgen.WorldDimensions; -import net.minecraft.world.level.levelgen.WorldOptions; import net.minecraft.world.level.storage.LevelStorageSource; import org.spongepowered.asm.mixin.Final; @@ -20,10 +13,8 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.function.Function; import org.jetbrains.annotations.Nullable; @Mixin(WorldOpenFlows.class) @@ -82,34 +73,4 @@ public abstract class WorldOpenFlowsMixin { WorldBootstrap.finishedWorldLoad(); } } - - - @ModifyArg( - method = "checkForBackupAndLoad(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Ljava/lang/Runnable;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/gui/screens/worldselection/WorldOpenFlows;loadLevel(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lcom/mojang/serialization/Dynamic;ZZLjava/lang/Runnable;)V" - ), - index = 3 - ) - public boolean wt_noWarningScreen(boolean bl) { - if (WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG) { - return false; - } - return bl; - } - - @Inject(method = "createFreshLevel", at = @At("HEAD")) - public void wt_createFreshLevel( - String string, - LevelSettings levelSettings, - WorldOptions worldOptions, - Function function, - Screen screen, - CallbackInfo ci - ) { - WorldsTogether.LOGGER.warning("called createFreshLevel..."); - //TODO: 1.19.3 no mor dimensions at this stage... - //WorldBootstrap.InFreshLevel.setupNewWorld(levelID, worldGenSettings, this.levelSource, Optional.empty()); - } } diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/BiomeSourceMixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/BiomeSourceMixin.java deleted file mode 100644 index 6383b292..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/BiomeSourceMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import org.betterx.worlds.together.biomesource.BiomeSourceHelper; - -import net.minecraft.world.level.biome.BiomeSource; - -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(BiomeSource.class) -public class BiomeSourceMixin { - @Override - public String toString() { - BiomeSource self = (BiomeSource) (Object) this; - return "\n" + getClass().getSimpleName() + " (" + Integer.toHexString(hashCode()) + ")" + - "\n biomes = " + self.possibleBiomes().size() + - "\n namespaces = " + BiomeSourceHelper.getNamespaces(self.possibleBiomes()); - } -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/MainDataMixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/MainDataMixin.java deleted file mode 100644 index c95201b3..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/MainDataMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import net.minecraft.data.Main; - -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(Main.class) -public class MainDataMixin { -// @Inject(method = "createStandardGenerator", at = @At("RETURN")) -// private static void wt_createStandardGenerator( -// Path path, -// Collection collection, -// boolean isClient, -// boolean isServer, -// boolean isDev, -// boolean reports, -// boolean validate, -// WorldVersion worldVersion, -// boolean alwaysGenerate, -// CallbackInfoReturnable cir -// ) { -// DataGenerator dataGenerator = cir.getReturnValue(); -// dataGenerator.addProvider(isServer, new SurfaceRulesDatapackGenerator(dataGenerator.getVanillaPackOutput())); -// cir.setReturnValue(dataGenerator); -// } -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/MinecraftServerMixinLate.java b/src/main/java/org/betterx/worlds/together/mixin/common/MinecraftServerMixinLate.java deleted file mode 100644 index d41ad786..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/MinecraftServerMixinLate.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import org.betterx.worlds.together.chunkgenerator.ChunkGeneratorUtils; - -import com.mojang.datafixers.DataFixer; -import net.minecraft.core.LayeredRegistryAccess; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.RegistryLayer; -import net.minecraft.server.Services; -import net.minecraft.server.WorldStem; -import net.minecraft.server.level.progress.ChunkProgressListenerFactory; -import net.minecraft.server.packs.repository.PackRepository; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.storage.LevelStorageSource; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.net.Proxy; - -@Mixin(value = MinecraftServer.class, priority = 2000) -public class MinecraftServerMixinLate { - @Shadow - @Final - private LayeredRegistryAccess registries; - - @Inject(at = @At("RETURN"), method = "") - private void bcl_restoreBiomeSource( - Thread thread, - LevelStorageSource.LevelStorageAccess levelStorageAccess, - PackRepository packRepository, - WorldStem worldStem, - Proxy proxy, - DataFixer dataFixer, - Services services, - ChunkProgressListenerFactory chunkProgressListenerFactory, - CallbackInfo ci - ) { - final Registry dimensionRegistry = this.registries.compositeAccess() - .registryOrThrow(Registries.LEVEL_STEM); - ChunkGeneratorUtils.restoreOriginalBiomeSourceInAllDimension(dimensionRegistry); - } -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/NoiseBasedChunkGeneratorMixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/NoiseBasedChunkGeneratorMixin.java deleted file mode 100644 index 9ecdf11e..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/NoiseBasedChunkGeneratorMixin.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import org.betterx.worlds.together.chunkgenerator.InjectableSurfaceRules; - -import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; - -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(NoiseBasedChunkGenerator.class) -public class NoiseBasedChunkGeneratorMixin implements InjectableSurfaceRules { -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/NoiseGeneratorSettingsMixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/NoiseGeneratorSettingsMixin.java deleted file mode 100644 index e226fe62..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/NoiseGeneratorSettingsMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import org.betterx.worlds.together.WorldsTogether; -import org.betterx.worlds.together.surfaceRules.SurfaceRuleProvider; - -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; -import net.minecraft.world.level.levelgen.SurfaceRules; - -import org.spongepowered.asm.mixin.*; - -@Mixin(NoiseGeneratorSettings.class) -public abstract class NoiseGeneratorSettingsMixin implements SurfaceRuleProvider { - @Mutable - @Final - @Shadow - private SurfaceRules.RuleSource surfaceRule; - - public void bclib_overwriteSurfaceRules(SurfaceRules.RuleSource surfaceRule) { - if (surfaceRule == null || surfaceRule == this.surfaceRule) return; - if (this.bcl_containsOverride) { - WorldsTogether.LOGGER.warning("Overwriting an overwritten set of Surface Rules."); - } - this.bcl_containsOverride = true; - this.surfaceRule = surfaceRule; - } - - public SurfaceRules.RuleSource bclib_getOriginalSurfaceRules() { - return this.surfaceRule; - } - - @Unique - private boolean bcl_containsOverride = false; - -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/RegistryDataLoaderMixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/RegistryDataLoaderMixin.java deleted file mode 100644 index 69f718c5..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/RegistryDataLoaderMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule; -import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry; - -import net.minecraft.resources.RegistryDataLoader; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.ArrayList; -import java.util.List; - -@Mixin(RegistryDataLoader.class) -public abstract class RegistryDataLoaderMixin { - @Accessor("WORLDGEN_REGISTRIES") - @Mutable - static void wt_set_WORLDGEN_REGISTRIES(List> list) { - //SHADOWED - } - - @Inject(method = "", at = @At("TAIL")) - private static void wt_init(CallbackInfo ci) { - List> enhanced = new ArrayList(RegistryDataLoader.WORLDGEN_REGISTRIES.size() + 1); - enhanced.addAll(RegistryDataLoader.WORLDGEN_REGISTRIES); - enhanced.add(new RegistryDataLoader.RegistryData<>( - SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, - AssignedSurfaceRule.CODEC - )); - wt_set_WORLDGEN_REGISTRIES(enhanced); - } -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/RegistryOpsAccessor.java b/src/main/java/org/betterx/worlds/together/mixin/common/RegistryOpsAccessor.java deleted file mode 100644 index 47330657..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/RegistryOpsAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import net.minecraft.resources.RegistryOps; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(RegistryOps.class) -public interface RegistryOpsAccessor { - @Accessor("lookupProvider") - RegistryOps.RegistryInfoLookup bcl_getLookupProvider(); -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/VanillaRegistriesMixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/VanillaRegistriesMixin.java deleted file mode 100644 index e80f28b9..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/VanillaRegistriesMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry; - -import net.minecraft.core.RegistrySetBuilder; -import net.minecraft.data.registries.VanillaRegistries; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(VanillaRegistries.class) -public class VanillaRegistriesMixin { - @Shadow - @Final - private static RegistrySetBuilder BUILDER; - - @Inject(method = "", at = @At(value = "TAIL")) - private static void together_registerSurface(CallbackInfo ci) { - //this code is only needed for the DataGen procedure... -// BUILDER.add( -// BCLBiomeRegistry.BCL_BIOMES_REGISTRY, -// BCLBiomeRegistry::bootstrap -// ); - - BUILDER.add( - SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, - SurfaceRuleRegistry::bootstrap - ); - } -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/WorldPresetAccessor.java b/src/main/java/org/betterx/worlds/together/mixin/common/WorldPresetAccessor.java deleted file mode 100644 index ff7ce286..00000000 --- a/src/main/java/org/betterx/worlds/together/mixin/common/WorldPresetAccessor.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.betterx.worlds.together.mixin.common; - -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.levelgen.presets.WorldPreset; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -@Mixin(WorldPreset.class) -public interface WorldPresetAccessor { - @Accessor("dimensions") - Map, LevelStem> bcl_getDimensions(); - - @Accessor("dimensions") - @Mutable - void bcl_setDimensions(Map, LevelStem> map); -} diff --git a/src/main/java/org/betterx/worlds/together/mixin/common/WorldStem_Mixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/WorldStem_Mixin.java index 33ffa668..c9317e8f 100644 --- a/src/main/java/org/betterx/worlds/together/mixin/common/WorldStem_Mixin.java +++ b/src/main/java/org/betterx/worlds/together/mixin/common/WorldStem_Mixin.java @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; public class WorldStem_Mixin { @ModifyVariable(method = "", argsOnly = true, at = @At(value = "INVOKE", target = "Ljava/lang/Record;()V", shift = At.Shift.AFTER)) LayeredRegistryAccess wt_bake(LayeredRegistryAccess registries) { - LayeredRegistryAccess rNew = WorldBootstrap.enforceInLayeredRegistry(registries); - return rNew; + WorldBootstrap.Helpers.onRegistryReady(registries.compositeAccess()); + return registries; } } diff --git a/src/main/java/org/betterx/worlds/together/surfaceRules/AssignedSurfaceRule.java b/src/main/java/org/betterx/worlds/together/surfaceRules/AssignedSurfaceRule.java deleted file mode 100644 index 3cab714e..00000000 --- a/src/main/java/org/betterx/worlds/together/surfaceRules/AssignedSurfaceRule.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.betterx.worlds.together.surfaceRules; - -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.levelgen.SurfaceRules; - -public class AssignedSurfaceRule { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance - .group( - SurfaceRules.RuleSource.CODEC.fieldOf("ruleSource").forGetter(o -> o.ruleSource), - ResourceLocation.CODEC.fieldOf("biome").forGetter(o -> o.biomeID) - ) - .apply(instance, AssignedSurfaceRule::new) - ); - - public final SurfaceRules.RuleSource ruleSource; - public final ResourceLocation biomeID; - - AssignedSurfaceRule(SurfaceRules.RuleSource ruleSource, ResourceLocation biomeID) { - this.ruleSource = ruleSource; - this.biomeID = biomeID; - } -} diff --git a/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleProvider.java b/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleProvider.java deleted file mode 100644 index 5b2dec78..00000000 --- a/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.betterx.worlds.together.surfaceRules; - -import net.minecraft.world.level.levelgen.SurfaceRules; - -public interface SurfaceRuleProvider { - void bclib_overwriteSurfaceRules(SurfaceRules.RuleSource surfaceRule); - SurfaceRules.RuleSource bclib_getOriginalSurfaceRules(); -} diff --git a/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleRegistry.java b/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleRegistry.java deleted file mode 100644 index ad18b5e2..00000000 --- a/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleRegistry.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.betterx.worlds.together.surfaceRules; - -import org.betterx.worlds.together.WorldsTogether; - -import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; -import net.minecraft.data.worldgen.BootstapContext; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.levelgen.SurfaceRules; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Predicate; -import org.jetbrains.annotations.ApiStatus; - -public class SurfaceRuleRegistry { - public static final ResourceKey> SURFACE_RULES_REGISTRY = - createRegistryKey(WorldsTogether.makeID("worldgen/betterx/surface_rules")); - public static final Predicate> NON_MANAGED_DIMENSIONS = dim -> dim != LevelStem.NETHER && dim != LevelStem.END; - public static final Predicate> ALL_DIMENSIONS = dim -> true; - - //public static Registry BUILTIN_SURFACE_RULES; - - private static ResourceKey> createRegistryKey(ResourceLocation location) { - return ResourceKey.createRegistryKey(location); - } - - @ApiStatus.Internal - public static void bootstrap(BootstapContext ctx) { -// ctx.register( -// ResourceKey.create( -// SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, -// WorldsTogether.makeID("dummy") -// ), -// new AssignedSurfaceRule( -// SurfaceRules.state(Blocks.YELLOW_CONCRETE.defaultBlockState()), -// WorldsTogether.makeID("none") -// ) -// ); - for (var entry : KNOWN.entrySet()) { - ctx.register(entry.getKey(), entry.getValue()); - } - } - - private static Map, AssignedSurfaceRule> KNOWN = new HashMap<>(); - - public static ResourceKey registerRule( - ResourceLocation ruleID, - SurfaceRules.RuleSource rules, - ResourceLocation biomeID - ) { - final ResourceKey key = ResourceKey.create( - SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, - ruleID - ); - KNOWN.put( - key, - new AssignedSurfaceRule( - SurfaceRules.ifTrue( - SurfaceRules.isBiome(ResourceKey.create(Registries.BIOME, biomeID)), - rules - ), biomeID - ) - ); - - return key; - } - - public static void ensureStaticallyLoaded() { - - } - -} diff --git a/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleUtil.java b/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleUtil.java deleted file mode 100644 index cfc8bff2..00000000 --- a/src/main/java/org/betterx/worlds/together/surfaceRules/SurfaceRuleUtil.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.betterx.worlds.together.surfaceRules; - -import org.betterx.bclib.BCLib; -import org.betterx.bclib.config.Configs; -import org.betterx.worlds.together.chunkgenerator.InjectableSurfaceRules; -import org.betterx.worlds.together.world.event.WorldBootstrap; - -import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.biome.BiomeSource; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; -import net.minecraft.world.level.levelgen.SurfaceRules; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.stream.Collectors; - -public class SurfaceRuleUtil { - private static List getRulesForBiome(ResourceLocation biomeID) { - Registry registry = null; - if (WorldBootstrap.getLastRegistryAccess() != null) - registry = WorldBootstrap.getLastRegistryAccess() - .registryOrThrow(SurfaceRuleRegistry.SURFACE_RULES_REGISTRY); - - if (registry == null) return List.of(); - - return registry.stream() - .filter(a -> a != null && a.biomeID != null && a.biomeID.equals( - biomeID)) - .map(a -> a.ruleSource) - .toList(); - - } - - private static List getRulesForBiomes(List biomes) { - Registry biomeRegistry = WorldBootstrap.getLastRegistryAccess().registryOrThrow(Registries.BIOME); - List biomeIDs = biomes.stream() - .map(b -> biomeRegistry.getKey(b)) - .filter(id -> id != null) - .toList(); - - return biomeIDs.stream() - .map(biomeID -> getRulesForBiome(biomeID)) - .flatMap(List::stream) - .collect(Collectors.toCollection(LinkedList::new)); - } - - private static SurfaceRules.RuleSource mergeSurfaceRules( - ResourceKey dimensionKey, - SurfaceRules.RuleSource org, - BiomeSource source, - List additionalRules - ) { - if (additionalRules == null || additionalRules.isEmpty()) return null; - final int count = additionalRules.size(); - if (org instanceof SurfaceRules.SequenceRuleSource sequenceRule) { - List existingSequence = sequenceRule.sequence(); - additionalRules = additionalRules - .stream() - .filter(r -> existingSequence.indexOf(r) < 0) - .collect(Collectors.toList()); - if (additionalRules.isEmpty()) return null; - - // when we are in the nether, we want to keep the nether roof and floor rules in the beginning of the sequence - // we will add our rules whne the first biome test sequence is found - if (dimensionKey.equals(LevelStem.NETHER)) { - final List combined = new ArrayList<>(existingSequence.size() + additionalRules.size()); - for (SurfaceRules.RuleSource rule : existingSequence) { - if (rule instanceof SurfaceRules.TestRuleSource testRule - && testRule.ifTrue() instanceof SurfaceRules.BiomeConditionSource) { - combined.addAll(additionalRules); - } - combined.add(rule); - } - additionalRules = combined; - } else { - additionalRules.addAll(existingSequence); - } - } else { - if (!additionalRules.contains(org)) - additionalRules.add(org); - } - - if (Configs.MAIN_CONFIG.verboseLogging()) { - BCLib.LOGGER.info("Merged " + count + " additional Surface Rules for " + source + " => " + additionalRules.size()); - } - return new SurfaceRules.SequenceRuleSource(additionalRules); - } - - public static void injectSurfaceRules( - ResourceKey dimensionKey, - NoiseGeneratorSettings noiseSettings, - BiomeSource loadedBiomeSource - ) { - if (((Object) noiseSettings) instanceof SurfaceRuleProvider srp) { - SurfaceRules.RuleSource originalRules = srp.bclib_getOriginalSurfaceRules(); - srp.bclib_overwriteSurfaceRules(mergeSurfaceRules( - dimensionKey, - originalRules, - loadedBiomeSource, - getRulesForBiomes(loadedBiomeSource.possibleBiomes().stream().map(h -> h.value()).toList()) - )); - } - } - - public static void injectSurfaceRulesToAllDimensions(Registry dimensionRegistry) { - for (var entry : dimensionRegistry.entrySet()) { - ResourceKey key = entry.getKey(); - LevelStem stem = entry.getValue(); - - if (stem.generator() instanceof InjectableSurfaceRules generator) { - generator.injectSurfaceRules(key); - } - } - } -} diff --git a/src/main/java/org/betterx/worlds/together/world/event/AdaptWorldPresetSettingEvent.java b/src/main/java/org/betterx/worlds/together/world/event/AdaptWorldPresetSettingEvent.java deleted file mode 100644 index 77a6d680..00000000 --- a/src/main/java/org/betterx/worlds/together/world/event/AdaptWorldPresetSettingEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.betterx.worlds.together.world.event; - -import net.minecraft.core.Holder; -import net.minecraft.world.level.levelgen.WorldDimensions; -import net.minecraft.world.level.levelgen.presets.WorldPreset; - -public class AdaptWorldPresetSettingEvent extends EventImpl { - public Holder emit(Holder start, WorldDimensions worldDims) { - for (OnAdaptWorldPresetSettings a : handlers) { - start = a.adapt(start, worldDims); - } - return start; - } -} diff --git a/src/main/java/org/betterx/worlds/together/world/event/OnAdaptWorldPresetSettings.java b/src/main/java/org/betterx/worlds/together/world/event/OnAdaptWorldPresetSettings.java deleted file mode 100644 index 117143af..00000000 --- a/src/main/java/org/betterx/worlds/together/world/event/OnAdaptWorldPresetSettings.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.betterx.worlds.together.world.event; - -import net.minecraft.core.Holder; -import net.minecraft.world.level.levelgen.WorldDimensions; -import net.minecraft.world.level.levelgen.presets.WorldPreset; - -@FunctionalInterface -public interface OnAdaptWorldPresetSettings { - Holder adapt( - Holder currentPreset, - WorldDimensions worldDims - ); -} diff --git a/src/main/java/org/betterx/worlds/together/world/event/WorldBootstrap.java b/src/main/java/org/betterx/worlds/together/world/event/WorldBootstrap.java index 55a27a01..1810866f 100644 --- a/src/main/java/org/betterx/worlds/together/world/event/WorldBootstrap.java +++ b/src/main/java/org/betterx/worlds/together/world/event/WorldBootstrap.java @@ -1,20 +1,14 @@ package org.betterx.worlds.together.world.event; -import org.betterx.bclib.BCLib; import org.betterx.bclib.config.Configs; import org.betterx.worlds.together.WorldsTogether; -import org.betterx.worlds.together.surfaceRules.SurfaceRuleUtil; import org.betterx.worlds.together.world.WorldConfig; -import net.minecraft.client.gui.screens.worldselection.WorldCreationContext; -import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState; import net.minecraft.core.Holder; -import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.server.RegistryLayer; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.levelgen.WorldDimensions; import net.minecraft.world.level.levelgen.presets.WorldPreset; @@ -58,7 +52,7 @@ public class WorldBootstrap { WorldConfig.load(new File(levelBaseDir, "data")); } - private static void onRegistryReady(RegistryAccess a) { + public static void onRegistryReady(RegistryAccess a) { if (a != LAST_REGISTRY_ACCESS) { LAST_REGISTRY_ACCESS = a; WorldEventsImpl.WORLD_REGISTRY_READY.emit(e -> e.initRegistry(a)); @@ -117,36 +111,11 @@ public class WorldBootstrap { } public static class InGUI { - public static void registryReadyOnNewWorld(WorldCreationContext worldGenSettingsComponent) { - Helpers.onRegistryReady(worldGenSettingsComponent.worldgenLoadContext()); - } public static void registryReady(RegistryAccess access) { Helpers.onRegistryReady(access); } - public static void setupNewWorld( - Optional levelStorageAccess, - WorldCreationUiState uiState, - boolean recreated - ) { - - if (levelStorageAccess.isPresent()) { - Holder currentPreset = uiState.getWorldType().preset(); - currentPreset = Helpers.presetFromDatapack(currentPreset); - Holder newPreset = setupNewWorldCommon( - levelStorageAccess.get(), - currentPreset - ); - if (newPreset != null && newPreset != currentPreset) { - uiState.setWorldType(new WorldCreationUiState.WorldTypeEntry(newPreset)); - } - } else { - WorldsTogether.LOGGER.error("Unable to access Level Folder."); - } - - } - static Holder setupNewWorldCommon( LevelStorageSource.LevelStorageAccess levelStorageAccess, Holder currentPreset @@ -232,35 +201,16 @@ public class WorldBootstrap { } public static void finalizeWorldGenSettings(Registry dimensionRegistry) { - String output = "World Dimensions: "; for (var entry : dimensionRegistry.entrySet()) { WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now( dimensionRegistry, entry.getKey(), entry.getValue() )); - - if (Configs.MAIN_CONFIG.verboseLogging()) - output += "\n - " + entry.getKey().location().toString() + ": " + - "\n " + entry.getValue().generator().toString() + " " + - entry.getValue() - .generator() - .getBiomeSource() - .toString() - .replace("\n", "\n "); } - if (Configs.MAIN_CONFIG.verboseLogging()) - BCLib.LOGGER.info(output); - SurfaceRuleUtil.injectSurfaceRulesToAllDimensions(dimensionRegistry); WorldEventsImpl.ON_FINALIZED_WORLD_LOAD.emit(e -> e.done(dimensionRegistry)); } - public static LayeredRegistryAccess enforceInLayeredRegistry(LayeredRegistryAccess registries) { - RegistryAccess access = registries.compositeAccess(); - Helpers.onRegistryReady(access); - return registries; - } - } diff --git a/src/main/java/org/betterx/worlds/together/world/event/WorldEvents.java b/src/main/java/org/betterx/worlds/together/world/event/WorldEvents.java index 7206592c..4ad14f95 100644 --- a/src/main/java/org/betterx/worlds/together/world/event/WorldEvents.java +++ b/src/main/java/org/betterx/worlds/together/world/event/WorldEvents.java @@ -7,7 +7,6 @@ public class WorldEvents { public static final Event ON_FINALIZE_LEVEL_STEM = WorldEventsImpl.ON_FINALIZE_LEVEL_STEM; public static final Event ON_FINALIZED_WORLD_LOAD = WorldEventsImpl.ON_FINALIZED_WORLD_LOAD; public static final Event PATCH_WORLD = WorldEventsImpl.PATCH_WORLD; - public static final Event ADAPT_WORLD_PRESET = WorldEventsImpl.ADAPT_WORLD_PRESET; public static final Event BEFORE_ADDING_TAGS = WorldEventsImpl.BEFORE_ADDING_TAGS; } diff --git a/src/main/java/org/betterx/worlds/together/world/event/WorldEventsImpl.java b/src/main/java/org/betterx/worlds/together/world/event/WorldEventsImpl.java index 6b9c74a7..1c2719c4 100644 --- a/src/main/java/org/betterx/worlds/together/world/event/WorldEventsImpl.java +++ b/src/main/java/org/betterx/worlds/together/world/event/WorldEventsImpl.java @@ -12,7 +12,7 @@ public class WorldEventsImpl { public static final EventImpl ON_FINALIZED_WORLD_LOAD = new EventImpl<>(); public static final PatchWorldEvent PATCH_WORLD = new PatchWorldEvent(); - public static final AdaptWorldPresetSettingEvent ADAPT_WORLD_PRESET = new AdaptWorldPresetSettingEvent(); + public static final EventImpl BEFORE_ADDING_TAGS = new EventImpl<>(); } diff --git a/src/main/resources/bclib.mixins.common.json b/src/main/resources/bclib.mixins.common.json index a336d65b..eb309ffb 100644 --- a/src/main/resources/bclib.mixins.common.json +++ b/src/main/resources/bclib.mixins.common.json @@ -10,9 +10,7 @@ "BiomeMixin", "BiomeSourceMixin", "BoneMealItemMixin", - "ChunkGeneratorAccessor", "ChunkGeneratorMixin", - "ChunkGeneratorsMixin", "ComposterBlockAccessor", "CraftingMenuMixin", "DiggerItemMixin", @@ -20,9 +18,7 @@ "ItemStackMixin", "LayerLightSectionStorageMixin", "LootPoolMixin", - "MissingDimensionFixMixin", "MobSpawnSettingsAccessor", - "NoiseBasedChunkGeneratorMixin", "PistonBaseBlockMixin", "PoiTypeMixin", "PortalShapeMixin", @@ -34,8 +30,6 @@ "ShovelItemAccessor", "SurfaceRulesContextAccessor", "TheEndBiomesMixin", - "V2551Mixin", - "V2832Mixin", "WorldGenRegionMixin", "boat.BoatItemMixin", "boat.BoatMixin", diff --git a/src/main/resources/together.mixins.common.json b/src/main/resources/together.mixins.common.json index dda9b764..ab8facaf 100644 --- a/src/main/resources/together.mixins.common.json +++ b/src/main/resources/together.mixins.common.json @@ -4,20 +4,11 @@ "package": "org.betterx.worlds.together.mixin.common", "compatibilityLevel": "JAVA_17", "mixins": [ - "BiomeSourceMixin", "DiggerItemAccessor", - "MainDataMixin", "MainMixin", "MinecraftServerMixin", - "MinecraftServerMixinLate", - "NoiseBasedChunkGeneratorMixin", - "NoiseGeneratorSettingsMixin", - "RegistryDataLoaderMixin", - "RegistryOpsAccessor", "TagLoaderMixin", - "VanillaRegistriesMixin", "WorldLoaderMixin", - "WorldPresetAccessor", "WorldStem_Mixin" ], "injectors": {