From 1784aa98bb815fd65f9097b4d04bcf28db445cea Mon Sep 17 00:00:00 2001 From: miyamashak Date: Thu, 17 Oct 2024 19:15:19 +0300 Subject: [PATCH 1/6] Move all density functions from AylythNoiseSettingBootstrap to AylythDensityFunctionBootstrap --- .../AylythDensityFunctionBootstrap.java | 172 ++++++++++--- .../terrain/AylythNoiseSettingBootstrap.java | 117 +-------- .../density_function/final_density.json | 139 +++++++++++ .../density_function/floodedness.json | 6 + .../density_function/fluid_spread.json | 6 + .../initial_density_without_jaggedness.json | 60 +++++ .../density_function/temperature.json | 12 + .../worldgen/density_function/vegetation.json | 12 + .../noise_settings/aylyth_settings.json | 235 +----------------- .../world/terrain/AylythDensityFunctions.java | 12 +- 10 files changed, 398 insertions(+), 373 deletions(-) create mode 100644 src/main/generated/data/aylyth/worldgen/density_function/final_density.json create mode 100644 src/main/generated/data/aylyth/worldgen/density_function/floodedness.json create mode 100644 src/main/generated/data/aylyth/worldgen/density_function/fluid_spread.json create mode 100644 src/main/generated/data/aylyth/worldgen/density_function/initial_density_without_jaggedness.json create mode 100644 src/main/generated/data/aylyth/worldgen/density_function/temperature.json create mode 100644 src/main/generated/data/aylyth/worldgen/density_function/vegetation.json diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java index 4e74ef0c..6bcbfe45 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java @@ -19,14 +19,21 @@ public final class AylythDensityFunctionBootstrap { private AylythDensityFunctionBootstrap() {} public static void bootstrap(Registerable context) { + var densityFunctions = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); var noiseParameters = context.getRegistryLookup(RegistryKeys.NOISE_PARAMETERS); + var floodedness = context.register(FLOODEDNESS_FUNCTION_KEY, noise(noiseParameters.getOrThrow(FLOODEDNESS), 1.0D, 0.67D)); + var fluidSpread = context.register(FLUID_SPREAD_FUNCTION_KEY, noise(noiseParameters.getOrThrow(FLUID_SPREAD), 1.0D, 1D / 1.4D)); var shiftX = context.register(SHIFT_X_KEY, flatCache(cache2d(shiftA(noiseParameters.getOrThrow(OFFSET))))); var shiftZ = context.register(SHIFT_Z_KEY, flatCache(cache2d(shiftB(noiseParameters.getOrThrow(OFFSET))))); var ridges = context.register(RIDGES_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(RIDGE)))); var ridgesFolded = context.register(RIDGES_FOLDED_FUNCTION_KEY, mul(constant(-3.0), add(constant(-0.3333333333333333), add(constant(-0.6666666666666666), holderFunction(ridges).abs()).abs()))); var continents = context.register(CONTINENTS_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(CONTINENTS)))); var erosion = context.register(EROSION_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(EROSION)))); + var temperature = context.register(TEMPERATURE_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(TEMPERATURE)))); + var vegetation = context.register(VEGETATION_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(VEGETATION)))); + var initialDensityWithoutJaggedness = context.register(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY, initialDensity(densityFunctions)); + var finalDensity = context.register(FINAL_DENSITY_FUNCTION_KEY, finalDensity(densityFunctions, noiseParameters)); Spline.DensityFunctionWrapper continentsCoordinate = new Spline.DensityFunctionWrapper(continents); Spline.DensityFunctionWrapper erosionCoordinate = new Spline.DensityFunctionWrapper(erosion); @@ -58,7 +65,7 @@ private static DensityFunction offset(Spline.DensityFunctionWrapper continentsCo blendOffset()); } - static DensityFunction depth(RegistryEntry offset) { + private static DensityFunction depth(RegistryEntry offset) { return add( yClampedGradient(-64, 272, 1.5, -1.5), holderFunction(offset) @@ -90,7 +97,7 @@ private static DensityFunction jaggedness(Spline.DensityFunctionWrapper continen ); } - static DensityFunction slopedCheese(RegistryEntry depth, RegistryEntry jaggednes, RegistryEntry factor, RegistryEntryLookup noiseParameters) { + private static DensityFunction slopedCheese(RegistryEntry depth, RegistryEntry jaggednes, RegistryEntry factor, RegistryEntryLookup noiseParameters) { return add( mul( constant(4.0), @@ -141,35 +148,35 @@ private static DensityFunction cavesSpaghetti2dThickness(RegistryEntryLookup caveSpaghetti2dThicknessModulator, RegistryEntryLookup noiseParameters) { return max( - add( - weirdScaledSampler( + add( + weirdScaledSampler( noise(noiseParameters.getOrThrow(SPAGHETTI_2D_MODULATOR), 2.0, 1.0), noiseParameters.getOrThrow(SPAGHETTI_2D), WeirdScaledSampler.RarityValueMapper.TYPE2 - ), - mul( - constant(0.083), - holderFunction(caveSpaghetti2dThicknessModulator) - ) - ), - add( - add( - add( - constant(0.0), - mul( - constant(8.0), - noise(noiseParameters.getOrThrow(SPAGHETTI_2D_ELEVATION), 1.0, 0.0) - ) - ), - yClampedGradient( - -64, - 80, - 8.0, - -40.0 - ) - ).abs(), - holderFunction(caveSpaghetti2dThicknessModulator) - ) + ), + mul( + constant(0.083), + holderFunction(caveSpaghetti2dThicknessModulator) + ) + ), + add( + add( + add( + constant(0.0), + mul( + constant(8.0), + noise(noiseParameters.getOrThrow(SPAGHETTI_2D_ELEVATION), 1.0, 0.0) + ) + ), + yClampedGradient( + -64, + 80, + 8.0, + -40.0 + ) + ).abs(), + holderFunction(caveSpaghetti2dThicknessModulator) + ) ).clamp(-1.0, 1.0); } @@ -177,7 +184,7 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg return rangeChoice( interpolated( rangeChoice( - holderFunction(y), + holderFunction(y), -60.0, 21.0, noise(noiseParameters.getOrThrow(NOODLE)), @@ -208,8 +215,8 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg max( interpolated( rangeChoice( - holderFunction(y), - -60.0, + holderFunction(y), + -60.0, 21.0, noise(noiseParameters.getOrThrow(NOODLE_RIDGE_A), 2.6666666666666665, 2.6666666666666665), constant(0.0) @@ -265,11 +272,11 @@ static DensityFunction holderFunction(RegistryEntry functionEnt return new RegistryEntryHolder(functionEntry); } - static DensityFunction withBlending(DensityFunction end, DensityFunction start) { + private static DensityFunction withBlending(DensityFunction end, DensityFunction start) { return flatCache(cache2d(lerp(blendAlpha(), start, end))); } - static DensityFunction slide(DensityFunction densityFunction, int i, int j, int k, int l, double d, int m, int n, double e) { + private static DensityFunction slide(DensityFunction densityFunction, int i, int j, int k, int l, double d, int m, int n, double e) { DensityFunction densityFunction2 = densityFunction; DensityFunction densityFunction3 = yClampedGradient(i + j - k, i + j - l, 1.0, 0.0); densityFunction2 = lerp(densityFunction3, constant(d), densityFunction2); @@ -278,8 +285,105 @@ static DensityFunction slide(DensityFunction densityFunction, int i, int j, int return densityFunction2; } - static DensityFunction postProcess(DensityFunction densityFunction) { + private static DensityFunction postProcess(DensityFunction densityFunction) { DensityFunction densityFunction2 = blendDensity(densityFunction); return mul(interpolated(densityFunction2), constant(0.64)).squeeze(); } + + private static DensityFunction initialDensity(RegistryEntryLookup functions) { + return slide( + add( + constant(-0.703125), + mul( + constant(4), + mul( + holderFunction(functions.getOrThrow(DEPTH_FUNCTION_KEY)), + cache2d(holderFunction(functions.getOrThrow(FACTOR_FUNCTION_KEY))) + ).quarterNegative() + ) + ).clamp(-64, 64), + -64, + 272, + 80, 64, -0.078125, + 0, 24, 0.1171875 + ); +// return slide( +// add( +// constant(-0.703125), +// mul( +// constant(4.0), +// mul( +// , +// ).quarterNegative() +// ) +// ).clamp(-64.0, 64.0), +// -64, +// 272, +// 80, 64, -0.078125, +// 0, 24, 0.1171875 +// ); + } + + private static DensityFunction finalDensity(RegistryEntryLookup functions, RegistryEntryLookup noiseParameters) { + return min( + AylythDensityFunctionBootstrap.postProcess( + AylythDensityFunctionBootstrap.slide( + rangeChoice( + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), + -1000000.0, + 1.5625, + min( + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), + mul( + constant(5.0), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) + ) + ), + max( + min( + min( + add( + mul( + constant(4.0), + noise(noiseParameters.getOrThrow(CAVE_LAYER), 1.0, 8.0).square() + ), + add( + add( + constant(0.27), + noise(noiseParameters.getOrThrow(CAVE_CHEESE), 2.0, 0.95) + ).clamp(-1.0, 1.0), + add( + constant(1.5), + mul( + constant(-0.64), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)) + ) + ).clamp(0.0, 0.5) + ) + ), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) + ), + add( + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_SPAGHETTI_2D_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY)) + ) + ), + rangeChoice( + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)), + -1000000.0, + 0.03, + constant(-1000000.0), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)) + ) + ) + ), + -64, + 272, + 80, 64, -0.078125, + 0, 24, 0.1171875 + ) + ), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_NOODLE_FUNCTION_KEY)) + ); + } } diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java index 5a5c0d9f..9e2e8b2b 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java @@ -51,119 +51,22 @@ static GenerationShapeConfig shapeConfig() { static NoiseRouter noiseRouter(RegistryEntryLookup functions, RegistryEntryLookup noiseParameters) { return new NoiseRouter( zero(), // barrierNoise - noise(noiseParameters.getOrThrow(FLOODEDNESS), 1.0D, 0.67D), // fluidLevelFloodednessNoise - noise(noiseParameters.getOrThrow(FLUID_SPREAD), 1.0D, 1D / 1.4D), // fluidLevelSpreadNoise + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(FLOODEDNESS_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(FLUID_SPREAD_FUNCTION_KEY)), zero(), // lavaNoise - shiftedNoise(AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SHIFT_X_KEY)), AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SHIFT_Z_KEY)), 0.25, noiseParameters.getOrThrow(TEMPERATURE)), // temperature - shiftedNoise(AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SHIFT_X_KEY)), AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SHIFT_Z_KEY)), 0.25, noiseParameters.getOrThrow(VEGETATION)), // vegetation - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CONTINENTS_FUNCTION_KEY)), // continents - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(EROSION_FUNCTION_KEY)), // erosion - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(DEPTH_FUNCTION_KEY)), // depth - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(RIDGES_FUNCTION_KEY)), // ridges - initialDensity(functions), // initialDensityWithoutJaggedness - finalDensity(functions, noiseParameters), // finalDensity + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(TEMPERATURE_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(VEGETATION_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CONTINENTS_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(EROSION_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(DEPTH_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(RIDGES_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(FINAL_DENSITY_FUNCTION_KEY)), zero(), // veinToggle zero(), // veinRidged zero()); // veinGap } - static DensityFunction initialDensity(RegistryEntryLookup functions) { - return AylythDensityFunctionBootstrap.slide( - add( - constant(-0.703125), - mul( - constant(4), - mul( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(DEPTH_FUNCTION_KEY)), - cache2d(AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(FACTOR_FUNCTION_KEY))) - ).quarterNegative() - ) - ).clamp(-64, 64), - -64, - 272, - 80, 64, -0.078125, - 0, 24, 0.1171875 - ); -// return slide( -// add( -// constant(-0.703125), -// mul( -// constant(4.0), -// mul( -// , -// ).quarterNegative() -// ) -// ).clamp(-64.0, 64.0), -// -64, -// 272, -// 80, 64, -0.078125, -// 0, 24, 0.1171875 -// ); - } - - static DensityFunction finalDensity(RegistryEntryLookup functions, RegistryEntryLookup noiseParameters) { - return min( - AylythDensityFunctionBootstrap.postProcess( - AylythDensityFunctionBootstrap.slide( - rangeChoice( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), - -1000000.0, - 1.5625, - min( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), - mul( - constant(5.0), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) - ) - ), - max( - min( - min( - add( - mul( - constant(4.0), - noise(noiseParameters.getOrThrow(CAVE_LAYER), 1.0, 8.0).square() - ), - add( - add( - constant(0.27), - noise(noiseParameters.getOrThrow(CAVE_CHEESE), 2.0, 0.95) - ).clamp(-1.0, 1.0), - add( - constant(1.5), - mul( - constant(-0.64), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)) - ) - ).clamp(0.0, 0.5) - ) - ), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) - ), - add( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_SPAGHETTI_2D_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY)) - ) - ), - rangeChoice( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)), - -1000000.0, - 0.03, - constant(-1000000.0), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)) - ) - ) - ), - -64, - 272, - 80, 64, -0.078125, - 0, 24, 0.1171875 - ) - ), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_NOODLE_FUNCTION_KEY)) - ); - } - static List spawnTargets() { return List.of(); } diff --git a/src/main/generated/data/aylyth/worldgen/density_function/final_density.json b/src/main/generated/data/aylyth/worldgen/density_function/final_density.json new file mode 100644 index 00000000..13ba6bd6 --- /dev/null +++ b/src/main/generated/data/aylyth/worldgen/density_function/final_density.json @@ -0,0 +1,139 @@ +{ + "type": "minecraft:min", + "argument1": { + "type": "minecraft:squeeze", + "argument": { + "type": "minecraft:mul", + "argument1": 0.64, + "argument2": { + "type": "minecraft:interpolated", + "argument": { + "type": "minecraft:blend_density", + "argument": { + "type": "minecraft:add", + "argument1": 0.1171875, + "argument2": { + "type": "minecraft:mul", + "argument1": { + "type": "minecraft:y_clamped_gradient", + "from_value": 0.0, + "from_y": -64, + "to_value": 1.0, + "to_y": -40 + }, + "argument2": { + "type": "minecraft:add", + "argument1": -0.1171875, + "argument2": { + "type": "minecraft:add", + "argument1": -0.078125, + "argument2": { + "type": "minecraft:mul", + "argument1": { + "type": "minecraft:y_clamped_gradient", + "from_value": 1.0, + "from_y": 128, + "to_value": 0.0, + "to_y": 144 + }, + "argument2": { + "type": "minecraft:add", + "argument1": 0.078125, + "argument2": { + "type": "minecraft:range_choice", + "input": "aylyth:sloped_cheese", + "max_exclusive": 1.5625, + "min_inclusive": -1000000.0, + "when_in_range": { + "type": "minecraft:min", + "argument1": "aylyth:sloped_cheese", + "argument2": { + "type": "minecraft:mul", + "argument1": 5.0, + "argument2": "aylyth:caves/entrances" + } + }, + "when_out_of_range": { + "type": "minecraft:max", + "argument1": { + "type": "minecraft:min", + "argument1": { + "type": "minecraft:min", + "argument1": { + "type": "minecraft:add", + "argument1": { + "type": "minecraft:mul", + "argument1": 4.0, + "argument2": { + "type": "minecraft:square", + "argument": { + "type": "minecraft:noise", + "noise": "aylyth:cave_layer", + "xz_scale": 1.0, + "y_scale": 8.0 + } + } + }, + "argument2": { + "type": "minecraft:add", + "argument1": { + "type": "minecraft:clamp", + "input": { + "type": "minecraft:add", + "argument1": 0.27, + "argument2": { + "type": "minecraft:noise", + "noise": "aylyth:cave_cheese", + "xz_scale": 2.0, + "y_scale": 0.95 + } + }, + "max": 1.0, + "min": -1.0 + }, + "argument2": { + "type": "minecraft:clamp", + "input": { + "type": "minecraft:add", + "argument1": 1.5, + "argument2": { + "type": "minecraft:mul", + "argument1": -0.64, + "argument2": "aylyth:sloped_cheese" + } + }, + "max": 0.5, + "min": 0.0 + } + } + }, + "argument2": "aylyth:caves/entrances" + }, + "argument2": { + "type": "minecraft:add", + "argument1": "aylyth:caves/spaghetti_2d", + "argument2": "aylyth:caves/spaghetti_roughness" + } + }, + "argument2": { + "type": "minecraft:range_choice", + "input": "aylyth:caves/pillars", + "max_exclusive": 0.03, + "min_inclusive": -1000000.0, + "when_in_range": -1000000.0, + "when_out_of_range": "aylyth:caves/pillars" + } + } + } + } + } + } + } + } + } + } + } + } + }, + "argument2": "aylyth:caves/noodle" +} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/density_function/floodedness.json b/src/main/generated/data/aylyth/worldgen/density_function/floodedness.json new file mode 100644 index 00000000..72eed373 --- /dev/null +++ b/src/main/generated/data/aylyth/worldgen/density_function/floodedness.json @@ -0,0 +1,6 @@ +{ + "type": "minecraft:noise", + "noise": "aylyth:aquifer_fluid_level_floodedness", + "xz_scale": 1.0, + "y_scale": 0.67 +} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/density_function/fluid_spread.json b/src/main/generated/data/aylyth/worldgen/density_function/fluid_spread.json new file mode 100644 index 00000000..79e1307f --- /dev/null +++ b/src/main/generated/data/aylyth/worldgen/density_function/fluid_spread.json @@ -0,0 +1,6 @@ +{ + "type": "minecraft:noise", + "noise": "aylyth:aquifer_fluid_level_spread", + "xz_scale": 1.0, + "y_scale": 0.7142857142857143 +} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/density_function/initial_density_without_jaggedness.json b/src/main/generated/data/aylyth/worldgen/density_function/initial_density_without_jaggedness.json new file mode 100644 index 00000000..7a943b92 --- /dev/null +++ b/src/main/generated/data/aylyth/worldgen/density_function/initial_density_without_jaggedness.json @@ -0,0 +1,60 @@ +{ + "type": "minecraft:add", + "argument1": 0.1171875, + "argument2": { + "type": "minecraft:mul", + "argument1": { + "type": "minecraft:y_clamped_gradient", + "from_value": 0.0, + "from_y": -64, + "to_value": 1.0, + "to_y": -40 + }, + "argument2": { + "type": "minecraft:add", + "argument1": -0.1171875, + "argument2": { + "type": "minecraft:add", + "argument1": -0.078125, + "argument2": { + "type": "minecraft:mul", + "argument1": { + "type": "minecraft:y_clamped_gradient", + "from_value": 1.0, + "from_y": 128, + "to_value": 0.0, + "to_y": 144 + }, + "argument2": { + "type": "minecraft:add", + "argument1": 0.078125, + "argument2": { + "type": "minecraft:clamp", + "input": { + "type": "minecraft:add", + "argument1": -0.703125, + "argument2": { + "type": "minecraft:mul", + "argument1": 4.0, + "argument2": { + "type": "minecraft:quarter_negative", + "argument": { + "type": "minecraft:mul", + "argument1": "aylyth:depth", + "argument2": { + "type": "minecraft:cache_2d", + "argument": "aylyth:factor" + } + } + } + } + }, + "max": 64.0, + "min": -64.0 + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/density_function/temperature.json b/src/main/generated/data/aylyth/worldgen/density_function/temperature.json new file mode 100644 index 00000000..c2407252 --- /dev/null +++ b/src/main/generated/data/aylyth/worldgen/density_function/temperature.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:flat_cache", + "argument": { + "type": "minecraft:shifted_noise", + "noise": "aylyth:temperature", + "shift_x": "aylyth:shift_x", + "shift_y": 0.0, + "shift_z": "aylyth:shift_z", + "xz_scale": 0.25, + "y_scale": 0.0 + } +} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/density_function/vegetation.json b/src/main/generated/data/aylyth/worldgen/density_function/vegetation.json new file mode 100644 index 00000000..c08f41b1 --- /dev/null +++ b/src/main/generated/data/aylyth/worldgen/density_function/vegetation.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:flat_cache", + "argument": { + "type": "minecraft:shifted_noise", + "noise": "aylyth:vegetation", + "shift_x": "aylyth:shift_x", + "shift_y": 0.0, + "shift_z": "aylyth:shift_z", + "xz_scale": 0.25, + "y_scale": 0.0 + } +} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json b/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json index 199b6b8d..fad9c34e 100644 --- a/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json +++ b/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json @@ -25,237 +25,14 @@ "continents": "aylyth:continents", "depth": "aylyth:depth", "erosion": "aylyth:erosion", - "final_density": { - "type": "minecraft:min", - "argument1": { - "type": "minecraft:squeeze", - "argument": { - "type": "minecraft:mul", - "argument1": 0.64, - "argument2": { - "type": "minecraft:interpolated", - "argument": { - "type": "minecraft:blend_density", - "argument": { - "type": "minecraft:add", - "argument1": 0.1171875, - "argument2": { - "type": "minecraft:mul", - "argument1": { - "type": "minecraft:y_clamped_gradient", - "from_value": 0.0, - "from_y": -64, - "to_value": 1.0, - "to_y": -40 - }, - "argument2": { - "type": "minecraft:add", - "argument1": -0.1171875, - "argument2": { - "type": "minecraft:add", - "argument1": -0.078125, - "argument2": { - "type": "minecraft:mul", - "argument1": { - "type": "minecraft:y_clamped_gradient", - "from_value": 1.0, - "from_y": 128, - "to_value": 0.0, - "to_y": 144 - }, - "argument2": { - "type": "minecraft:add", - "argument1": 0.078125, - "argument2": { - "type": "minecraft:range_choice", - "input": "aylyth:sloped_cheese", - "max_exclusive": 1.5625, - "min_inclusive": -1000000.0, - "when_in_range": { - "type": "minecraft:min", - "argument1": "aylyth:sloped_cheese", - "argument2": { - "type": "minecraft:mul", - "argument1": 5.0, - "argument2": "aylyth:caves/entrances" - } - }, - "when_out_of_range": { - "type": "minecraft:max", - "argument1": { - "type": "minecraft:min", - "argument1": { - "type": "minecraft:min", - "argument1": { - "type": "minecraft:add", - "argument1": { - "type": "minecraft:mul", - "argument1": 4.0, - "argument2": { - "type": "minecraft:square", - "argument": { - "type": "minecraft:noise", - "noise": "aylyth:cave_layer", - "xz_scale": 1.0, - "y_scale": 8.0 - } - } - }, - "argument2": { - "type": "minecraft:add", - "argument1": { - "type": "minecraft:clamp", - "input": { - "type": "minecraft:add", - "argument1": 0.27, - "argument2": { - "type": "minecraft:noise", - "noise": "aylyth:cave_cheese", - "xz_scale": 2.0, - "y_scale": 0.95 - } - }, - "max": 1.0, - "min": -1.0 - }, - "argument2": { - "type": "minecraft:clamp", - "input": { - "type": "minecraft:add", - "argument1": 1.5, - "argument2": { - "type": "minecraft:mul", - "argument1": -0.64, - "argument2": "aylyth:sloped_cheese" - } - }, - "max": 0.5, - "min": 0.0 - } - } - }, - "argument2": "aylyth:caves/entrances" - }, - "argument2": { - "type": "minecraft:add", - "argument1": "aylyth:caves/spaghetti_2d", - "argument2": "aylyth:caves/spaghetti_roughness" - } - }, - "argument2": { - "type": "minecraft:range_choice", - "input": "aylyth:caves/pillars", - "max_exclusive": 0.03, - "min_inclusive": -1000000.0, - "when_in_range": -1000000.0, - "when_out_of_range": "aylyth:caves/pillars" - } - } - } - } - } - } - } - } - } - } - } - } - }, - "argument2": "aylyth:caves/noodle" - }, - "fluid_level_floodedness": { - "type": "minecraft:noise", - "noise": "aylyth:aquifer_fluid_level_floodedness", - "xz_scale": 1.0, - "y_scale": 0.67 - }, - "fluid_level_spread": { - "type": "minecraft:noise", - "noise": "aylyth:aquifer_fluid_level_spread", - "xz_scale": 1.0, - "y_scale": 0.7142857142857143 - }, - "initial_density_without_jaggedness": { - "type": "minecraft:add", - "argument1": 0.1171875, - "argument2": { - "type": "minecraft:mul", - "argument1": { - "type": "minecraft:y_clamped_gradient", - "from_value": 0.0, - "from_y": -64, - "to_value": 1.0, - "to_y": -40 - }, - "argument2": { - "type": "minecraft:add", - "argument1": -0.1171875, - "argument2": { - "type": "minecraft:add", - "argument1": -0.078125, - "argument2": { - "type": "minecraft:mul", - "argument1": { - "type": "minecraft:y_clamped_gradient", - "from_value": 1.0, - "from_y": 128, - "to_value": 0.0, - "to_y": 144 - }, - "argument2": { - "type": "minecraft:add", - "argument1": 0.078125, - "argument2": { - "type": "minecraft:clamp", - "input": { - "type": "minecraft:add", - "argument1": -0.703125, - "argument2": { - "type": "minecraft:mul", - "argument1": 4.0, - "argument2": { - "type": "minecraft:quarter_negative", - "argument": { - "type": "minecraft:mul", - "argument1": "aylyth:depth", - "argument2": { - "type": "minecraft:cache_2d", - "argument": "aylyth:factor" - } - } - } - } - }, - "max": 64.0, - "min": -64.0 - } - } - } - } - } - } - }, + "final_density": "aylyth:final_density", + "fluid_level_floodedness": "aylyth:floodedness", + "fluid_level_spread": "aylyth:fluid_spread", + "initial_density_without_jaggedness": "aylyth:initial_density_without_jaggedness", "lava": 0.0, "ridges": "aylyth:ridges", - "temperature": { - "type": "minecraft:shifted_noise", - "noise": "aylyth:temperature", - "shift_x": "aylyth:shift_x", - "shift_y": 0.0, - "shift_z": "aylyth:shift_z", - "xz_scale": 0.25, - "y_scale": 0.0 - }, - "vegetation": { - "type": "minecraft:shifted_noise", - "noise": "aylyth:vegetation", - "shift_x": "aylyth:shift_x", - "shift_y": 0.0, - "shift_z": "aylyth:shift_z", - "xz_scale": 0.25, - "y_scale": 0.0 - }, + "temperature": "aylyth:temperature", + "vegetation": "aylyth:vegetation", "vein_gap": 0.0, "vein_ridged": 0.0, "vein_toggle": 0.0 diff --git a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java index 03a7e89f..2a22a9c8 100644 --- a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java +++ b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java @@ -7,16 +7,20 @@ public interface AylythDensityFunctions { + RegistryKey FLOODEDNESS_FUNCTION_KEY = bind("floodedness"); + RegistryKey FLUID_SPREAD_FUNCTION_KEY = bind("fluid_spread"); RegistryKey SHIFT_X_KEY = bind("shift_x"); RegistryKey SHIFT_Z_KEY = bind("shift_z"); - RegistryKey RIDGES_FUNCTION_KEY = bind("ridges"); - RegistryKey RIDGES_FOLDED_FUNCTION_KEY = bind("ridges_folded"); + RegistryKey TEMPERATURE_FUNCTION_KEY = bind("temperature"); + RegistryKey VEGETATION_FUNCTION_KEY = bind("vegetation"); RegistryKey CONTINENTS_FUNCTION_KEY = bind("continents"); RegistryKey EROSION_FUNCTION_KEY = bind("erosion"); + RegistryKey RIDGES_FUNCTION_KEY = bind("ridges"); + RegistryKey RIDGES_FOLDED_FUNCTION_KEY = bind("ridges_folded"); RegistryKey OFFSET_FUNCTION_KEY = bind("offset"); + RegistryKey DEPTH_FUNCTION_KEY = bind("depth"); RegistryKey FACTOR_FUNCTION_KEY = bind("factor"); RegistryKey JAGGEDNESS_FUNCTION_KEY = bind("jaggedness"); - RegistryKey DEPTH_FUNCTION_KEY = bind("depth"); RegistryKey SLOPED_CHEESE_FUNCTION_KEY = bind("sloped_cheese"); RegistryKey Y_FUNCTION_KEY = bind("y"); RegistryKey CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY = bind("caves/spaghetti_roughness"); @@ -25,6 +29,8 @@ public interface AylythDensityFunctions { RegistryKey CAVES_NOODLE_FUNCTION_KEY = bind("caves/noodle"); RegistryKey CAVES_PILLARS_FUNCTION_KEY = bind("caves/pillars"); RegistryKey CAVES_ENTRANCES_FUNCTION_KEY = bind("caves/entrances"); + RegistryKey INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY = bind("initial_density_without_jaggedness"); + RegistryKey FINAL_DENSITY_FUNCTION_KEY = bind("final_density"); private static RegistryKey bind(String name) { return RegistryKey.of(RegistryKeys.DENSITY_FUNCTION, Aylyth.id(name)); From e7daf6fbc6b837c187133de80b5ef668eecf6237 Mon Sep 17 00:00:00 2001 From: miyamashak Date: Thu, 17 Oct 2024 20:00:22 +0300 Subject: [PATCH 2/6] Cleanup code and remove unused noise parameters --- .../AylythDensityFunctionBootstrap.java | 243 +++++++++--------- ...ootstrap.java => AylythMaterialRules.java} | 31 ++- .../terrain/AylythNoiseSettingBootstrap.java | 76 ++---- .../terrain/AylythNoiseTypeBootstrap.java | 70 ++--- .../aylyth/worldgen/noise/base_layer.json | 9 - .../aylyth/worldgen/noise/cave_entrances.json | 8 - .../aylyth/worldgen/noise/spaghetti_3d_1.json | 6 - .../aylyth/worldgen/noise/spaghetti_3d_2.json | 6 - .../worldgen/noise/spaghetti_3d_rareness.json | 6 - .../noise/spaghetti_3d_thickness.json | 6 - .../data/world/AylythDimensionData.java | 7 +- .../world/terrain/AylythDensityFunctions.java | 14 +- .../data/world/terrain/AylythNoises.java | 70 +++-- 13 files changed, 246 insertions(+), 306 deletions(-) rename src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/{AylythMaterialRuleBootstrap.java => AylythMaterialRules.java} (78%) delete mode 100644 src/main/generated/data/aylyth/worldgen/noise/base_layer.json delete mode 100644 src/main/generated/data/aylyth/worldgen/noise/cave_entrances.json delete mode 100644 src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_1.json delete mode 100644 src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_2.json delete mode 100644 src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_rareness.json delete mode 100644 src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_thickness.json diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java index 6bcbfe45..d20acb4d 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java @@ -10,6 +10,7 @@ import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.densityfunction.DensityFunction; +import static moriyashiine.aylyth.common.data.world.AylythDimensionData.*; import static net.minecraft.world.gen.densityfunction.DensityFunctionTypes.*; import static moriyashiine.aylyth.common.data.world.terrain.AylythDensityFunctions.*; @@ -19,39 +20,51 @@ public final class AylythDensityFunctionBootstrap { private AylythDensityFunctionBootstrap() {} public static void bootstrap(Registerable context) { - var densityFunctions = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); - var noiseParameters = context.getRegistryLookup(RegistryKeys.NOISE_PARAMETERS); + var densityFuns = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); + var noiseParams = context.getRegistryLookup(RegistryKeys.NOISE_PARAMETERS); - var floodedness = context.register(FLOODEDNESS_FUNCTION_KEY, noise(noiseParameters.getOrThrow(FLOODEDNESS), 1.0D, 0.67D)); - var fluidSpread = context.register(FLUID_SPREAD_FUNCTION_KEY, noise(noiseParameters.getOrThrow(FLUID_SPREAD), 1.0D, 1D / 1.4D)); - var shiftX = context.register(SHIFT_X_KEY, flatCache(cache2d(shiftA(noiseParameters.getOrThrow(OFFSET))))); - var shiftZ = context.register(SHIFT_Z_KEY, flatCache(cache2d(shiftB(noiseParameters.getOrThrow(OFFSET))))); - var ridges = context.register(RIDGES_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(RIDGE)))); - var ridgesFolded = context.register(RIDGES_FOLDED_FUNCTION_KEY, mul(constant(-3.0), add(constant(-0.3333333333333333), add(constant(-0.6666666666666666), holderFunction(ridges).abs()).abs()))); - var continents = context.register(CONTINENTS_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(CONTINENTS)))); - var erosion = context.register(EROSION_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(EROSION)))); - var temperature = context.register(TEMPERATURE_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(TEMPERATURE)))); - var vegetation = context.register(VEGETATION_FUNCTION_KEY, flatCache(shiftedNoise(holderFunction(shiftX), holderFunction(shiftZ), 0.25, noiseParameters.getOrThrow(VEGETATION)))); - var initialDensityWithoutJaggedness = context.register(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY, initialDensity(densityFunctions)); - var finalDensity = context.register(FINAL_DENSITY_FUNCTION_KEY, finalDensity(densityFunctions, noiseParameters)); + var floodedness = context.register(FLOODEDNESS_FUNCTION_KEY, noise(noiseParams.getOrThrow(FLOODEDNESS), 1.0D, 0.67D)); + var fluidSpread = context.register(FLUID_SPREAD_FUNCTION_KEY, noise(noiseParams.getOrThrow(FLUID_SPREAD), 1.0D, 1D / 1.4D)); - Spline.DensityFunctionWrapper continentsCoordinate = new Spline.DensityFunctionWrapper(continents); - Spline.DensityFunctionWrapper erosionCoordinate = new Spline.DensityFunctionWrapper(erosion); - Spline.DensityFunctionWrapper ridgesCoordinate = new Spline.DensityFunctionWrapper(ridges); - Spline.DensityFunctionWrapper ridgesFoldedCoordinate = new Spline.DensityFunctionWrapper(ridgesFolded); + var shiftX = context.register(SHIFT_X_KEY, flatCache(cache2d(shiftA(noiseParams.getOrThrow(OFFSET))))); + var shiftZ = context.register(SHIFT_Z_KEY, flatCache(cache2d(shiftB(noiseParams.getOrThrow(OFFSET))))); - var offset = context.register(OFFSET_FUNCTION_KEY, offset(continentsCoordinate, erosionCoordinate, ridgesFoldedCoordinate)); - var factor = context.register(FACTOR_FUNCTION_KEY, factor(continentsCoordinate, erosionCoordinate, ridgesCoordinate, ridgesFoldedCoordinate)); - var jaggedness = context.register(JAGGEDNESS_FUNCTION_KEY, jaggedness(continentsCoordinate, erosionCoordinate, ridgesCoordinate, ridgesFoldedCoordinate)); - var depth = context.register(DEPTH_FUNCTION_KEY, depth(offset)); - var y = context.register(Y_FUNCTION_KEY, aylythY()); - context.register(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY, cavesSpaghettiRoughness(noiseParameters)); - var caveSpaghetti2dThiknessModulator = context.register(CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR_FUNCTION_KEY, cavesSpaghetti2dThickness(noiseParameters)); - context.register(CAVES_SPAGHETTI_2D_FUNCTION_KEY, cavesSpaghetti2d(caveSpaghetti2dThiknessModulator, noiseParameters)); - context.register(CAVES_NOODLE_FUNCTION_KEY, cavesNoodle(y, noiseParameters)); - context.register(CAVES_PILLARS_FUNCTION_KEY, cavesPillars(noiseParameters)); - context.register(CAVES_ENTRANCES_FUNCTION_KEY, cavesEntrances()); - context.register(SLOPED_CHEESE_FUNCTION_KEY, slopedCheese(depth, jaggedness, factor, noiseParameters)); + var temperature = context.register(TEMPERATURE_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(TEMPERATURE)))); + var vegetation = context.register(VEGETATION_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(VEGETATION)))); + var continents = context.register(CONTINENTS_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(CONTINENTS)))); + var erosion = context.register(EROSION_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(EROSION)))); + var ridges = context.register(RIDGES_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(RIDGE)))); + var ridgesFolded = context.register(RIDGES_FOLDED_FUNCTION_KEY, mul(constant(-3.0), add(constant(-0.3333333333333333), add(constant(-0.6666666666666666), wrap(ridges).abs()).abs()))); + + var offset = context.register(OFFSET_FUNCTION_KEY, offset(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridgesFolded))); + var depth = context.register(DEPTH_FUNCTION_KEY, add(yClampedGradient(MIN_HEIGHT, ACTUAL_MAX_HEIGHT, 1.5, -1.5), wrap(offset))); + + var factor = context.register(FACTOR_FUNCTION_KEY, factor(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); + var jaggedness = context.register(JAGGEDNESS_FUNCTION_KEY, jaggedness(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); + var slopedCheese = context.register(SLOPED_CHEESE_FUNCTION_KEY, slopedCheese(depth, jaggedness, factor, noiseParams)); + + var caveSpaghetti2dThiknessModulator = context.register(CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR_FUNCTION_KEY, cavesSpaghetti2dThickness(noiseParams)); + var cavesSpaghetti2d = context.register(CAVES_SPAGHETTI_2D_FUNCTION_KEY, cavesSpaghetti2d(caveSpaghetti2dThiknessModulator, noiseParams)); + var cavesSpaghettiRoughness = context.register(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY, cavesSpaghettiRoughness(noiseParams)); + var cavesPillars = context.register(CAVES_PILLARS_FUNCTION_KEY, cavesPillars(noiseParams)); + + int fromY = DimensionType.MIN_HEIGHT * 2; + int toY = DimensionType.MAX_COLUMN_HEIGHT * 2; + var y = context.register(Y_FUNCTION_KEY, yClampedGradient(fromY, toY, fromY, toY)); + + var cavesNoodle = context.register(CAVES_NOODLE_FUNCTION_KEY, cavesNoodle(y, noiseParams)); + var cavesEntrances = context.register(CAVES_ENTRANCES_FUNCTION_KEY, constant(1)); + + var initialDensityWithoutJaggedness = context.register(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY, initialDensity(densityFuns)); + var finalDensity = context.register(FINAL_DENSITY_FUNCTION_KEY, finalDensity(densityFuns, noiseParams)); + } + + static DensityFunction wrap(RegistryEntry fun) { + return new RegistryEntryHolder(fun); + } + + private static Spline.DensityFunctionWrapper wrapSlidePos(RegistryEntry fun) { + return new Spline.DensityFunctionWrapper(fun); } private static DensityFunction offset(Spline.DensityFunctionWrapper continentsCoordinate, Spline.DensityFunctionWrapper erosionCoordinate, Spline.DensityFunctionWrapper ridgesFoldedCoordinate) { @@ -65,24 +78,6 @@ private static DensityFunction offset(Spline.DensityFunctionWrapper continentsCo blendOffset()); } - private static DensityFunction depth(RegistryEntry offset) { - return add( - yClampedGradient(-64, 272, 1.5, -1.5), - holderFunction(offset) - ); - } - - private static DensityFunction aylythY() { - int min = DimensionType.MIN_HEIGHT * 2; - int max = DimensionType.MAX_COLUMN_HEIGHT * 2; - return yClampedGradient( - min, - max, - min, - max - ); - } - private static DensityFunction factor(Spline.DensityFunctionWrapper continentsCoordinate, Spline.DensityFunctionWrapper erosionCoordinate, Spline.DensityFunctionWrapper ridgesCoordinate, Spline.DensityFunctionWrapper ridgesFoldedCoordinate) { return withBlending( spline(VanillaTerrainParametersCreator.createFactorSpline(continentsCoordinate, erosionCoordinate, ridgesCoordinate, ridgesFoldedCoordinate, false)), @@ -103,37 +98,19 @@ private static DensityFunction slopedCheese(RegistryEntry depth constant(4.0), mul( add( - holderFunction(depth), + wrap(depth), mul( - holderFunction(jaggednes), + wrap(jaggednes), noise(noiseParameters.getOrThrow(JAGGED), 1500.0, 0.0).halfNegative() ) ), - holderFunction(factor) + wrap(factor) ).quarterNegative() ), InterpolatedNoiseSampler.createBase3dNoiseFunction(0.25, 0.125, 80.0, 160.0, 8.0) ); } - private static DensityFunction cavesSpaghettiRoughness(RegistryEntryLookup noiseParameters) { - return cacheOnce( - mul( - add( - constant(-0.05), - mul( - constant(-0.05), - noise(noiseParameters.getOrThrow(SPAGHETTI_2D_MODULATOR)) - ) - ), - add( - constant(-0.4), - noise(noiseParameters.getOrThrow(SPAGHETTI_2D_ROUGHNESS)).abs() - ) - ) - ); - } - private static DensityFunction cavesSpaghetti2dThickness(RegistryEntryLookup noiseParameters) { return cacheOnce( add( @@ -156,7 +133,7 @@ private static DensityFunction cavesSpaghetti2d(RegistryEntry c ), mul( constant(0.083), - holderFunction(caveSpaghetti2dThicknessModulator) + wrap(caveSpaghetti2dThicknessModulator) ) ), add( @@ -175,16 +152,61 @@ private static DensityFunction cavesSpaghetti2d(RegistryEntry c -40.0 ) ).abs(), - holderFunction(caveSpaghetti2dThicknessModulator) + wrap(caveSpaghetti2dThicknessModulator) ) ).clamp(-1.0, 1.0); } + private static DensityFunction cavesSpaghettiRoughness(RegistryEntryLookup noiseParameters) { + return cacheOnce( + mul( + add( + constant(-0.05), + mul( + constant(-0.05), + noise(noiseParameters.getOrThrow(SPAGHETTI_2D_MODULATOR)) + ) + ), + add( + constant(-0.4), + noise(noiseParameters.getOrThrow(SPAGHETTI_2D_ROUGHNESS)).abs() + ) + ) + ); + } + + private static DensityFunction cavesPillars(RegistryEntryLookup noiseParameters) { + return cacheOnce( + mul( + add( + mul( + constant(2.0), + noise(noiseParameters.getOrThrow(PILLAR), 25.0, 0.3) + ), + add( + constant(-1.0), + mul( + constant(-1.0), + noise(noiseParameters.getOrThrow(PILLAR_RARENESS)) + ) + ) + ), + add( + constant(0.55), + mul( + constant(0.55), + noise(noiseParameters.getOrThrow(PILLAR_THICKNESS)) + ) + ).cube() + ) + ); + } + private static DensityFunction cavesNoodle(RegistryEntry y, RegistryEntryLookup noiseParameters) { // NOTE: This is the cave type that sucks and I hate return rangeChoice( interpolated( rangeChoice( - holderFunction(y), + wrap(y), -60.0, 21.0, noise(noiseParameters.getOrThrow(NOODLE)), @@ -197,7 +219,7 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg add( interpolated( rangeChoice( - holderFunction(y), + wrap(y), -60.0, 21.0, add( @@ -215,7 +237,7 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg max( interpolated( rangeChoice( - holderFunction(y), + wrap(y), -60.0, 21.0, noise(noiseParameters.getOrThrow(NOODLE_RIDGE_A), 2.6666666666666665, 2.6666666666666665), @@ -224,7 +246,7 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg ).abs(), interpolated( rangeChoice( - holderFunction(y), + wrap(y), -60.0, 21.0, noise(noiseParameters.getOrThrow(NOODLE_RIDGE_B), 2.6666666666666665, 2.6666666666666665), @@ -237,41 +259,6 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg ); } - private static DensityFunction cavesPillars(RegistryEntryLookup noiseParameters) { - return cacheOnce( - mul( - add( - mul( - constant(2.0), - noise(noiseParameters.getOrThrow(PILLAR), 25.0, 0.3) - ), - add( - constant(-1.0), - mul( - constant(-1.0), - noise(noiseParameters.getOrThrow(PILLAR_RARENESS)) - ) - ) - ), - add( - constant(0.55), - mul( - constant(0.55), - noise(noiseParameters.getOrThrow(PILLAR_THICKNESS)) - ) - ).cube() - ) - ); - } - - private static DensityFunction cavesEntrances() { - return constant(1); - } - - static DensityFunction holderFunction(RegistryEntry functionEntry) { - return new RegistryEntryHolder(functionEntry); - } - private static DensityFunction withBlending(DensityFunction end, DensityFunction start) { return flatCache(cache2d(lerp(blendAlpha(), start, end))); } @@ -297,13 +284,13 @@ private static DensityFunction initialDensity(RegistryEntryLookup AylythDensityFunctionBootstrap.postProcess( AylythDensityFunctionBootstrap.slide( rangeChoice( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), -1000000.0, 1.5625, min( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), mul( constant(5.0), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) ) ), max( @@ -356,34 +343,34 @@ private static DensityFunction finalDensity(RegistryEntryLookup constant(1.5), mul( constant(-0.64), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)) ) ).clamp(0.0, 0.5) ) ), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) ), add( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_SPAGHETTI_2D_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_2D_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY)) ) ), rangeChoice( - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)), -1000000.0, 0.03, constant(-1000000.0), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)) ) ) ), - -64, - 272, + MIN_HEIGHT, + ACTUAL_MAX_HEIGHT, 80, 64, -0.078125, 0, 24, 0.1171875 ) ), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CAVES_NOODLE_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_NOODLE_FUNCTION_KEY)) ); } } diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRuleBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java similarity index 78% rename from src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRuleBootstrap.java rename to src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java index c762cdad..f0d0e085 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRuleBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java @@ -9,13 +9,17 @@ import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; import net.minecraft.world.gen.YOffset; import net.minecraft.world.gen.surfacebuilder.MaterialRules; +import net.minecraft.world.gen.surfacebuilder.MaterialRules.MaterialRule; -public final class AylythMaterialRuleBootstrap extends MaterialRules { - private AylythMaterialRuleBootstrap() {} +import static net.minecraft.world.gen.surfacebuilder.MaterialRules.*; - static MaterialRule materialRules() { +final class AylythMaterialRules { + private AylythMaterialRules() {} + + public static MaterialRule create() { var dirt = block(Blocks.DIRT); var grass = block(Blocks.GRASS_BLOCK); + var onReplaceWithGrass = condition(water(0, 0), grass); var commonPodzol = podzol(AylythNoises.PODZOL_COMMON, 0.3, Double.MAX_VALUE); var rarePodzol = podzol(AylythNoises.PODZOL_RARE, 0.95, Double.MAX_VALUE); @@ -31,42 +35,43 @@ static MaterialRule materialRules() { var aboveBasicSurface = condition(surface(), sequence(onSurface, onUnderSurface)); var bedrock = condition(verticalGradient("aylyth:bedrock_layer", YOffset.BOTTOM, YOffset.aboveBottom(5)), block(Blocks.BEDROCK)); var uplands = condition(biome(AylythBiomes.UPLANDS), condition(surface(), condition(waterWithStoneDepth(-6, -1), uplandsTerracotta()))); + return sequence(bedrock, bowels(), uplands, mire(), aboveBasicSurface); } - static MaterialRule uplandsTerracotta() { + private static MaterialRule uplandsTerracotta() { return sequence(surfaceNoiseBlock(Blocks.DEEPSLATE, -2, -0.6), surfaceNoiseBlock(Blocks.BROWN_TERRACOTTA, -0.6, -0.15), surfaceNoiseBlock(Blocks.YELLOW_TERRACOTTA, -0.15, 0), surfaceNoiseBlock(Blocks.ORANGE_TERRACOTTA, 0, 0.3), surfaceNoiseBlock(Blocks.RED_TERRACOTTA, 0.3, 0.6), surfaceNoiseBlock(Blocks.TERRACOTTA, 0.6, 0.8), surfaceNoiseBlock(Blocks.DEEPSLATE, 0.8, 2.0)); } - static MaterialRule mire() { + private static MaterialRule mire() { return condition(biome(AylythBiomes.MIRE), sequence(mireAroundLand(), mireUnderwaterMud())); } - static MaterialRule mireAroundLand() { + private static MaterialRule mireAroundLand() { return condition(surface(), condition(not(aboveYWithStoneDepth(YOffset.fixed(48), 0)), sequence(surfaceNoiseBlock(Blocks.SOUL_SOIL, 0.70, Double.MAX_VALUE), block(Blocks.MUD)))); } - static MaterialRule mireUnderwaterMud() { + private static MaterialRule mireUnderwaterMud() { return condition(surface(), condition(stoneDepth(0, false, 0, VerticalSurfaceType.FLOOR), condition(not(water(0, 0)), block(Blocks.MUD)))); } - static MaterialRule bowels() { + private static MaterialRule bowels() { return condition(biome(AylythBiomes.BOWELS), sequence(condition(stoneDepth(0, false, 0, VerticalSurfaceType.FLOOR), condition(water(0, 0), noiseBlock(AylythNoises.BOWELS_SOUL_SAND, Blocks.SOUL_SAND, 0.6, Double.MAX_VALUE))), condition(waterWithStoneDepth(-6, -1), condition(stoneDepth(0, true, 0, VerticalSurfaceType.FLOOR), block(Blocks.SOUL_SOIL))))); } - static MaterialRule podzol(RegistryKey noise, double min, double max) { + private static MaterialRule podzol(RegistryKey noise, double min, double max) { return condition(noiseThreshold(noise, min, max), block(Blocks.PODZOL)); } - static MaterialRule noiseBlock(RegistryKey noise, Block block, double min, double max) { + private static MaterialRule noiseBlock(RegistryKey noise, Block block, double min, double max) { return condition(noiseThreshold(noise, min, max), block(block)); } - static MaterialRule surfaceNoiseBlock(Block block, double min, double max) { + private static MaterialRule surfaceNoiseBlock(Block block, double min, double max) { return condition(noiseThreshold(AylythNoises.SURFACE, min, max), block(block)); } - static MaterialRule block(Block block) { - return block(block.getDefaultState()); + private static MaterialRule block(Block block) { + return MaterialRules.block(block.getDefaultState()); } } diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java index 9e2e8b2b..381e48f0 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java @@ -1,73 +1,49 @@ package moriyashiine.aylyth.datagen.common.world.terrain; import moriyashiine.aylyth.common.data.world.AylythDimensionData; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryEntryLookup; import net.minecraft.registry.RegistryKeys; -import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; -import net.minecraft.world.biome.source.util.MultiNoiseUtil; +import net.minecraft.world.biome.source.util.MultiNoiseUtil.NoiseHypercube; import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; import net.minecraft.world.gen.chunk.GenerationShapeConfig; -import net.minecraft.world.gen.densityfunction.DensityFunction; import net.minecraft.world.gen.noise.NoiseRouter; import java.util.List; +import static moriyashiine.aylyth.common.data.world.AylythDimensionData.*; import static moriyashiine.aylyth.common.data.world.terrain.AylythDensityFunctions.*; -import static moriyashiine.aylyth.common.data.world.terrain.AylythNoises.*; +import static moriyashiine.aylyth.datagen.common.world.terrain.AylythDensityFunctionBootstrap.wrap; import static net.minecraft.world.gen.densityfunction.DensityFunctionTypes.*; public final class AylythNoiseSettingBootstrap { private AylythNoiseSettingBootstrap() {} public static void bootstrap(Registerable context) { - context.register(AylythDimensionData.CHUNK_GEN_SETTINGS, createSettings(context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION), context.getRegistryLookup(RegistryKeys.NOISE_PARAMETERS))); - } - - static ChunkGeneratorSettings createSettings(RegistryEntryLookup functions, RegistryEntryLookup noiseParameters) { + var densityFuns = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); + + var shapeConfig = new GenerationShapeConfig(MIN_HEIGHT, SHAPE_MAX_HEIGHT, 1, 1); + var noiseRouter = new NoiseRouter( + zero(), + wrap(densityFuns.getOrThrow(FLOODEDNESS_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(FLUID_SPREAD_FUNCTION_KEY)), + zero(), + wrap(densityFuns.getOrThrow(TEMPERATURE_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(VEGETATION_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(CONTINENTS_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(EROSION_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(DEPTH_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(RIDGES_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(FINAL_DENSITY_FUNCTION_KEY)), + zero(), + zero(), + zero() + ); + var surfaceMaterialRules = AylythMaterialRules.create(); + var spawnTarget = List.of(); var seaLevel = 47; - var disableMobGen = false; - var aquifers = true; - var oreVeins = false; - var legacyRandom = false; - return new ChunkGeneratorSettings(shapeConfig(), defaultState(Blocks.DEEPSLATE), defaultState(Blocks.WATER), noiseRouter(functions, noiseParameters), AylythMaterialRuleBootstrap.materialRules(), spawnTargets(), seaLevel, disableMobGen, aquifers, oreVeins, legacyRandom); - } - - static BlockState defaultState(Block block) { - return block.getDefaultState(); - } - - static GenerationShapeConfig shapeConfig() { - var minY = -64; - var height = 304; - var horizontal = 1; - var vertical = 1; - return new GenerationShapeConfig(minY, height, horizontal, vertical); - } - - static NoiseRouter noiseRouter(RegistryEntryLookup functions, RegistryEntryLookup noiseParameters) { - return new NoiseRouter( - zero(), // barrierNoise - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(FLOODEDNESS_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(FLUID_SPREAD_FUNCTION_KEY)), - zero(), // lavaNoise - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(TEMPERATURE_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(VEGETATION_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(CONTINENTS_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(EROSION_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(DEPTH_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(RIDGES_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.holderFunction(functions.getOrThrow(FINAL_DENSITY_FUNCTION_KEY)), - zero(), // veinToggle - zero(), // veinRidged - zero()); // veinGap - } - static List spawnTargets() { - return List.of(); + context.register(AylythDimensionData.CHUNK_GEN_SETTINGS, new ChunkGeneratorSettings(shapeConfig, Blocks.DEEPSLATE.getDefaultState(), Blocks.WATER.getDefaultState(), noiseRouter, surfaceMaterialRules, spawnTarget, seaLevel, false, true, false, false)); } } \ No newline at end of file diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseTypeBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseTypeBootstrap.java index 63959f48..eed24357 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseTypeBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseTypeBootstrap.java @@ -1,6 +1,5 @@ package moriyashiine.aylyth.datagen.common.world.terrain; -import it.unimi.dsi.fastutil.doubles.DoubleList; import net.minecraft.registry.Registerable; import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters; @@ -10,38 +9,41 @@ public final class AylythNoiseTypeBootstrap { private AylythNoiseTypeBootstrap() {} public static void bootstrap(Registerable context) { - context.register(FLOODEDNESS, new NoiseParameters(-7, DoubleList.of(1.0))); - context.register(FLUID_SPREAD, new NoiseParameters(-5, DoubleList.of(1.0))); - context.register(OFFSET, new NoiseParameters(-3, DoubleList.of(1.0, 1.0, 1.0, 0.0))); - context.register(RIDGE, new NoiseParameters(-7, DoubleList.of(1.0, 2.0, 1.0, 0.0, 0.0, 0.0))); - context.register(JAGGED, new NoiseParameters(-16, DoubleList.of(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0))); - context.register(CONTINENTS, new NoiseParameters(-9, DoubleList.of(1.0, 1.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 1.0))); - context.register(TEMPERATURE, new NoiseParameters(-10, DoubleList.of(1.5, 0.0, 1.0, 0.0, 0.0, 0.0))); - context.register(VEGETATION, new NoiseParameters(-8, DoubleList.of(1.0, 1.0, 0.0, 0.0, 0.0, 0.0))); - context.register(EROSION, new NoiseParameters(-9, DoubleList.of(1.0, 1.0, 0.0, 0.0, 1.0, 1.0))); - context.register(BASE_LAYER, new NoiseParameters(-8, DoubleList.of(1.0, 1.0, 1.0, 1.0))); - context.register(SURFACE, new NoiseParameters(-6, DoubleList.of(1.0, 1.0, 1.0))); - context.register(CAVE_LAYER, new NoiseParameters(-8, DoubleList.of(1.0))); - context.register(CAVE_CHEESE, new NoiseParameters(-8, DoubleList.of(0.5, 1.0, 2.0, 1.0, 2.0, 1.0, 0.0, 2.0, 0.0))); - context.register(SPAGHETTI_2D, new NoiseParameters(-7, DoubleList.of(1.0))); - context.register(SPAGHETTI_2D_MODULATOR, new NoiseParameters(-11, DoubleList.of(1.0))); - context.register(SPAGHETTI_2D_ROUGHNESS, new NoiseParameters(-5, DoubleList.of(1.0))); - context.register(SPAGHETTI_2D_THICKNESS, new NoiseParameters(-11, DoubleList.of(1.0))); - context.register(SPAGHETTI_2D_ELEVATION, new NoiseParameters(-8, DoubleList.of(1.0))); - context.register(SPAGHETTI_3D_1, new NoiseParameters(-7, DoubleList.of(1.0))); - context.register(SPAGHETTI_3D_2, new NoiseParameters(-7, DoubleList.of(1.0))); - context.register(SPAGHETTI_3D_RARITY, new NoiseParameters(-11, DoubleList.of(1.0))); - context.register(SPAGHETTI_3D_THICKNESS, new NoiseParameters(-11, DoubleList.of(1.0))); - context.register(NOODLE, new NoiseParameters(-8, DoubleList.of(1.0))); - context.register(NOODLE_THICKNESS, new NoiseParameters(-8, DoubleList.of(1.0))); - context.register(NOODLE_RIDGE_A, new NoiseParameters(-7, DoubleList.of(1.0))); - context.register(NOODLE_RIDGE_B, new NoiseParameters(-7, DoubleList.of(1.0))); - context.register(PILLAR, new NoiseParameters(-7, DoubleList.of(1.0, 1.0))); - context.register(PILLAR_RARENESS, new NoiseParameters(-8, DoubleList.of(1.0))); - context.register(PILLAR_THICKNESS, new NoiseParameters(-8, DoubleList.of(1.0))); - context.register(CAVE_ENTRANCES, new NoiseParameters(-7, DoubleList.of(0.4, 0.5, 1.0))); - context.register(PODZOL_COMMON, new NoiseParameters(-4, DoubleList.of(1.0, 1.0))); - context.register(PODZOL_RARE, new NoiseParameters(-5, DoubleList.of(1.0, 1.0, 1.0))); - context.register(BOWELS_SOUL_SAND, new NoiseParameters(-5, DoubleList.of(1.0, 1.0, 1.0))); + context.register(FLOODEDNESS, new NoiseParameters(-7, 1)); + context.register(FLUID_SPREAD, new NoiseParameters(-5, 1)); + + context.register(TEMPERATURE, new NoiseParameters(-10, 1.5, 0, 1, 0, 0, 0)); + context.register(VEGETATION, new NoiseParameters(-8, 1, 1, 0, 0, 0, 0)); + context.register(CONTINENTS, new NoiseParameters(-9, 1, 1, 2, 2, 2, 1, 1, 1, 1)); + context.register(EROSION, new NoiseParameters(-9, 1, 1, 0, 0, 1, 1)); + context.register(RIDGE, new NoiseParameters(-7, 1, 2, 1, 0, 0, 0)); + + context.register(OFFSET, new NoiseParameters(-3, 1, 1, 1, 0)); + context.register(JAGGED, new NoiseParameters(-16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)); + + context.register(CAVE_LAYER, new NoiseParameters(-8, 1)); + context.register(CAVE_CHEESE, new NoiseParameters(-8, 0.5, 1, 2, 1, 2, 1, 0, 2, 0)); + context.register(SPAGHETTI_2D, new NoiseParameters(-7, 1)); + context.register(SPAGHETTI_2D_MODULATOR, new NoiseParameters(-11, 1)); + context.register(SPAGHETTI_2D_ROUGHNESS, new NoiseParameters(-5, 1)); + context.register(SPAGHETTI_2D_THICKNESS, new NoiseParameters(-11, 1)); + context.register(SPAGHETTI_2D_ELEVATION, new NoiseParameters(-8, 1)); + context.register(SPAGHETTI_3D_1, new NoiseParameters(-7, 1)); + context.register(SPAGHETTI_3D_2, new NoiseParameters(-7, 1)); + context.register(SPAGHETTI_3D_RARITY, new NoiseParameters(-11, 1)); + context.register(SPAGHETTI_3D_THICKNESS, new NoiseParameters(-11, 1)); + context.register(PILLAR, new NoiseParameters(-7, 1, 1)); + context.register(PILLAR_RARENESS, new NoiseParameters(-8, 1)); + context.register(PILLAR_THICKNESS, new NoiseParameters(-8, 1)); + context.register(NOODLE, new NoiseParameters(-8, 1)); + context.register(NOODLE_THICKNESS, new NoiseParameters(-8, 1)); + context.register(NOODLE_RIDGE_A, new NoiseParameters(-7, 1)); + context.register(NOODLE_RIDGE_B, new NoiseParameters(-7, 1)); + context.register(CAVE_ENTRANCES, new NoiseParameters(-7, 0.4, 0.5, 1)); + + context.register(SURFACE, new NoiseParameters(-6, 1, 1, 1)); + context.register(PODZOL_COMMON, new NoiseParameters(-4, 1, 1)); + context.register(PODZOL_RARE, new NoiseParameters(-5, 1, 1, 1)); + context.register(BOWELS_SOUL_SAND, new NoiseParameters(-5, 1, 1, 1)); } } diff --git a/src/main/generated/data/aylyth/worldgen/noise/base_layer.json b/src/main/generated/data/aylyth/worldgen/noise/base_layer.json deleted file mode 100644 index 77668018..00000000 --- a/src/main/generated/data/aylyth/worldgen/noise/base_layer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "amplitudes": [ - 1.0, - 1.0, - 1.0, - 1.0 - ], - "firstOctave": -8 -} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/noise/cave_entrances.json b/src/main/generated/data/aylyth/worldgen/noise/cave_entrances.json deleted file mode 100644 index b03b4dd6..00000000 --- a/src/main/generated/data/aylyth/worldgen/noise/cave_entrances.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "amplitudes": [ - 0.4, - 0.5, - 1.0 - ], - "firstOctave": -7 -} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_1.json b/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_1.json deleted file mode 100644 index 0701b239..00000000 --- a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_1.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "amplitudes": [ - 1.0 - ], - "firstOctave": -7 -} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_2.json b/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_2.json deleted file mode 100644 index 0701b239..00000000 --- a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_2.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "amplitudes": [ - 1.0 - ], - "firstOctave": -7 -} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_rareness.json b/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_rareness.json deleted file mode 100644 index 90d5f80b..00000000 --- a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_rareness.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "amplitudes": [ - 1.0 - ], - "firstOctave": -11 -} \ No newline at end of file diff --git a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_thickness.json b/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_thickness.json deleted file mode 100644 index 90d5f80b..00000000 --- a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_3d_thickness.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "amplitudes": [ - 1.0 - ], - "firstOctave": -11 -} \ No newline at end of file diff --git a/src/main/java/moriyashiine/aylyth/common/data/world/AylythDimensionData.java b/src/main/java/moriyashiine/aylyth/common/data/world/AylythDimensionData.java index f5c135c9..13f1dc2a 100644 --- a/src/main/java/moriyashiine/aylyth/common/data/world/AylythDimensionData.java +++ b/src/main/java/moriyashiine/aylyth/common/data/world/AylythDimensionData.java @@ -10,8 +10,13 @@ public interface AylythDimensionData { + int MIN_HEIGHT = -64; + int MAX_HEIGHT = 336; + int ACTUAL_MAX_HEIGHT = MIN_HEIGHT + MAX_HEIGHT; // 272 + int SHAPE_MAX_HEIGHT = MAX_HEIGHT - 32; // 304 + RegistryKey DIMENSION_TYPE = RegistryKey.of(RegistryKeys.DIMENSION_TYPE, Aylyth.id("aylyth")); - RegistryKey DIMENSION_OPTIONS = RegistryKey.of(RegistryKeys.DIMENSION, Aylyth.id("aylyth")); RegistryKey CHUNK_GEN_SETTINGS = RegistryKey.of(RegistryKeys.CHUNK_GENERATOR_SETTINGS, Aylyth.id("aylyth_settings")); + RegistryKey DIMENSION = RegistryKey.of(RegistryKeys.DIMENSION, Aylyth.id("aylyth")); RegistryKey WORLD = RegistryKey.of(RegistryKeys.WORLD, Aylyth.id("aylyth")); } diff --git a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java index 2a22a9c8..0869cf34 100644 --- a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java +++ b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java @@ -9,26 +9,34 @@ public interface AylythDensityFunctions { RegistryKey FLOODEDNESS_FUNCTION_KEY = bind("floodedness"); RegistryKey FLUID_SPREAD_FUNCTION_KEY = bind("fluid_spread"); + RegistryKey SHIFT_X_KEY = bind("shift_x"); RegistryKey SHIFT_Z_KEY = bind("shift_z"); + RegistryKey TEMPERATURE_FUNCTION_KEY = bind("temperature"); RegistryKey VEGETATION_FUNCTION_KEY = bind("vegetation"); RegistryKey CONTINENTS_FUNCTION_KEY = bind("continents"); RegistryKey EROSION_FUNCTION_KEY = bind("erosion"); RegistryKey RIDGES_FUNCTION_KEY = bind("ridges"); RegistryKey RIDGES_FOLDED_FUNCTION_KEY = bind("ridges_folded"); + RegistryKey OFFSET_FUNCTION_KEY = bind("offset"); RegistryKey DEPTH_FUNCTION_KEY = bind("depth"); + RegistryKey FACTOR_FUNCTION_KEY = bind("factor"); RegistryKey JAGGEDNESS_FUNCTION_KEY = bind("jaggedness"); RegistryKey SLOPED_CHEESE_FUNCTION_KEY = bind("sloped_cheese"); - RegistryKey Y_FUNCTION_KEY = bind("y"); - RegistryKey CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY = bind("caves/spaghetti_roughness"); + RegistryKey CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR_FUNCTION_KEY = bind("caves/spaghetti_2d_thickness_modulator"); RegistryKey CAVES_SPAGHETTI_2D_FUNCTION_KEY = bind("caves/spaghetti_2d"); - RegistryKey CAVES_NOODLE_FUNCTION_KEY = bind("caves/noodle"); + RegistryKey CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY = bind("caves/spaghetti_roughness"); RegistryKey CAVES_PILLARS_FUNCTION_KEY = bind("caves/pillars"); + + RegistryKey Y_FUNCTION_KEY = bind("y"); + + RegistryKey CAVES_NOODLE_FUNCTION_KEY = bind("caves/noodle"); RegistryKey CAVES_ENTRANCES_FUNCTION_KEY = bind("caves/entrances"); + RegistryKey INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY = bind("initial_density_without_jaggedness"); RegistryKey FINAL_DENSITY_FUNCTION_KEY = bind("final_density"); diff --git a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoises.java b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoises.java index 2dfdc9b2..c4ac6587 100644 --- a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoises.java +++ b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoises.java @@ -3,45 +3,43 @@ import moriyashiine.aylyth.common.Aylyth; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; +import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters; public interface AylythNoises { - RegistryKey FLOODEDNESS = bind("aquifer_fluid_level_floodedness"); - RegistryKey FLUID_SPREAD = bind("aquifer_fluid_level_spread"); - RegistryKey OFFSET = bind("offset"); - RegistryKey RIDGE = bind("ridge"); - RegistryKey JAGGED = bind("jagged"); - RegistryKey CONTINENTS = bind("continents"); - RegistryKey TEMPERATURE = bind("temperature"); - RegistryKey VEGETATION = bind("vegetation"); - RegistryKey EROSION = bind("erosion"); - RegistryKey BASE_LAYER = bind("base_layer"); - RegistryKey SURFACE = bind("surface"); - RegistryKey CAVE_LAYER = bind("cave_layer"); - RegistryKey CAVE_CHEESE = bind("cave_cheese"); - RegistryKey SPAGHETTI_2D = bind("spaghetti_2d"); - RegistryKey SPAGHETTI_2D_MODULATOR = bind("spaghetti_2d_modulator"); - RegistryKey SPAGHETTI_2D_ROUGHNESS = bind("spaghetti_2d_roughness"); - RegistryKey SPAGHETTI_2D_THICKNESS = bind("spaghetti_2d_thickness"); - RegistryKey SPAGHETTI_2D_ELEVATION = bind("spaghetti_2d_elevation"); - RegistryKey SPAGHETTI_3D_1 = bind("spaghetti_3d_1"); - RegistryKey SPAGHETTI_3D_2 = bind("spaghetti_3d_2"); - RegistryKey SPAGHETTI_3D_RARITY = bind("spaghetti_3d_rareness"); - RegistryKey SPAGHETTI_3D_THICKNESS = bind("spaghetti_3d_thickness"); - RegistryKey NOODLE = bind("noodle"); - RegistryKey NOODLE_THICKNESS = bind("noodle_thickness"); - RegistryKey NOODLE_RIDGE_A = bind("noodle_ridge_a"); - RegistryKey NOODLE_RIDGE_B = bind("noodle_ridge_b"); - RegistryKey PILLAR = bind("pillar"); - RegistryKey PILLAR_RARENESS = bind("pillar_rareness"); - RegistryKey PILLAR_THICKNESS = bind("pillar_thickness"); - RegistryKey CAVE_ENTRANCES = bind("cave_entrances"); - RegistryKey PODZOL_COMMON = bind("podzol_common"); - RegistryKey PODZOL_RARE = bind("podzol_rare"); - RegistryKey BOWELS_SOUL_SAND = bind("bowels_soul_sand"); - - private static RegistryKey bind(String name) { + RegistryKey FLOODEDNESS = bind("aquifer_fluid_level_floodedness"); + RegistryKey FLUID_SPREAD = bind("aquifer_fluid_level_spread"); + + RegistryKey TEMPERATURE = bind("temperature"); + RegistryKey VEGETATION = bind("vegetation"); + RegistryKey CONTINENTS = bind("continents"); + RegistryKey EROSION = bind("erosion"); + RegistryKey RIDGE = bind("ridge"); + + RegistryKey OFFSET = bind("offset"); + RegistryKey JAGGED = bind("jagged"); + + RegistryKey SPAGHETTI_2D = bind("spaghetti_2d"); + RegistryKey SPAGHETTI_2D_MODULATOR = bind("spaghetti_2d_modulator"); + RegistryKey SPAGHETTI_2D_ROUGHNESS = bind("spaghetti_2d_roughness"); + RegistryKey SPAGHETTI_2D_THICKNESS = bind("spaghetti_2d_thickness"); + RegistryKey SPAGHETTI_2D_ELEVATION = bind("spaghetti_2d_elevation"); + RegistryKey PILLAR = bind("pillar"); + RegistryKey PILLAR_RARENESS = bind("pillar_rareness"); + RegistryKey PILLAR_THICKNESS = bind("pillar_thickness"); + RegistryKey NOODLE = bind("noodle"); + RegistryKey NOODLE_THICKNESS = bind("noodle_thickness"); + RegistryKey NOODLE_RIDGE_A = bind("noodle_ridge_a"); + RegistryKey NOODLE_RIDGE_B = bind("noodle_ridge_b"); + RegistryKey CAVE_LAYER = bind("cave_layer"); + RegistryKey CAVE_CHEESE = bind("cave_cheese"); + + RegistryKey SURFACE = bind("surface"); + RegistryKey PODZOL_COMMON = bind("podzol_common"); + RegistryKey PODZOL_RARE = bind("podzol_rare"); + RegistryKey BOWELS_SOUL_SAND = bind("bowels_soul_sand"); + + private static RegistryKey bind(String name) { return RegistryKey.of(RegistryKeys.NOISE_PARAMETERS, Aylyth.id(name)); } } From 13521acb45638ca17fb4261a76ec063dfba0ec1e Mon Sep 17 00:00:00 2001 From: miyamashak Date: Thu, 17 Oct 2024 20:49:51 +0300 Subject: [PATCH 3/6] Code renaming --- .../aylyth/datagen/AylythDatagen.java | 8 +- ...a => AylythChunkGenSettingsBootstrap.java} | 24 ++-- .../AylythDensityFunctionBootstrap.java | 112 +++++++++--------- .../world/terrain/AylythMaterialRules.java | 10 +- ...p.java => AylythNoiseParamsBootstrap.java} | 13 +- ...ss.json => aquifer_fluid_floodedness.json} | 0 ..._spread.json => aquifer_fluid_spread.json} | 0 ...{final_density.json => density_final.json} | 0 ...> density_initial_without_jaggedness.json} | 0 .../worldgen/density_function/ridges.json | 2 +- .../noise/{ridge.json => ridges.json} | 0 .../noise_settings/aylyth_settings.json | 8 +- .../world/terrain/AylythDensityFunctions.java | 48 ++++---- ...lythNoises.java => AylythNoiseParams.java} | 4 +- 14 files changed, 113 insertions(+), 116 deletions(-) rename src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/{AylythNoiseSettingBootstrap.java => AylythChunkGenSettingsBootstrap.java} (67%) rename src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/{AylythNoiseTypeBootstrap.java => AylythNoiseParamsBootstrap.java} (80%) rename src/main/generated/data/aylyth/worldgen/density_function/{floodedness.json => aquifer_fluid_floodedness.json} (100%) rename src/main/generated/data/aylyth/worldgen/density_function/{fluid_spread.json => aquifer_fluid_spread.json} (100%) rename src/main/generated/data/aylyth/worldgen/density_function/{final_density.json => density_final.json} (100%) rename src/main/generated/data/aylyth/worldgen/density_function/{initial_density_without_jaggedness.json => density_initial_without_jaggedness.json} (100%) rename src/main/generated/data/aylyth/worldgen/noise/{ridge.json => ridges.json} (100%) rename src/main/java/moriyashiine/aylyth/common/data/world/terrain/{AylythNoises.java => AylythNoiseParams.java} (96%) diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java b/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java index 8f586ccd..2399e84d 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java @@ -20,8 +20,8 @@ import moriyashiine.aylyth.datagen.common.world.structure.AylythStructurePoolBootstrap; import moriyashiine.aylyth.datagen.common.world.structure.AylythStructureSetBootstrap; import moriyashiine.aylyth.datagen.common.world.terrain.AylythDensityFunctionBootstrap; -import moriyashiine.aylyth.datagen.common.world.terrain.AylythNoiseSettingBootstrap; -import moriyashiine.aylyth.datagen.common.world.terrain.AylythNoiseTypeBootstrap; +import moriyashiine.aylyth.datagen.common.world.terrain.AylythChunkGenSettingsBootstrap; +import moriyashiine.aylyth.datagen.common.world.terrain.AylythNoiseParamsBootstrap; import moriyashiine.aylyth.datagen.common.loot.AylythBlockLootProvider; import moriyashiine.aylyth.datagen.common.loot.AylythEntityLootProvider; import moriyashiine.aylyth.datagen.common.tag.*; @@ -62,9 +62,9 @@ public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) { @Override public void buildRegistry(RegistryBuilder registryBuilder) { - registryBuilder.addRegistry(RegistryKeys.NOISE_PARAMETERS, AylythNoiseTypeBootstrap::bootstrap); + registryBuilder.addRegistry(RegistryKeys.NOISE_PARAMETERS, AylythNoiseParamsBootstrap::bootstrap); registryBuilder.addRegistry(RegistryKeys.DENSITY_FUNCTION, AylythDensityFunctionBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.CHUNK_GENERATOR_SETTINGS, AylythNoiseSettingBootstrap::bootstrap); + registryBuilder.addRegistry(RegistryKeys.CHUNK_GENERATOR_SETTINGS, AylythChunkGenSettingsBootstrap::bootstrap); registryBuilder.addRegistry(RegistryKeys.CONFIGURED_CARVER, AylythConfiguredCarverBootstrap::bootstrap); registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, AylythConfiguredFeatureBootstrap::bootstrap); registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, AylythPlacedFeatureBootstrap::bootstrap); diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java similarity index 67% rename from src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java rename to src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java index 381e48f0..49541a66 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseSettingBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java @@ -16,8 +16,8 @@ import static moriyashiine.aylyth.datagen.common.world.terrain.AylythDensityFunctionBootstrap.wrap; import static net.minecraft.world.gen.densityfunction.DensityFunctionTypes.*; -public final class AylythNoiseSettingBootstrap { - private AylythNoiseSettingBootstrap() {} +public final class AylythChunkGenSettingsBootstrap { + private AylythChunkGenSettingsBootstrap() {} public static void bootstrap(Registerable context) { var densityFuns = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); @@ -25,17 +25,17 @@ public static void bootstrap(Registerable context) { var shapeConfig = new GenerationShapeConfig(MIN_HEIGHT, SHAPE_MAX_HEIGHT, 1, 1); var noiseRouter = new NoiseRouter( zero(), - wrap(densityFuns.getOrThrow(FLOODEDNESS_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(FLUID_SPREAD_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(AQUIFER_FLUID_FLOODEDNESS)), + wrap(densityFuns.getOrThrow(AQUIFER_FLUID_SPREAD)), zero(), - wrap(densityFuns.getOrThrow(TEMPERATURE_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(VEGETATION_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(CONTINENTS_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(EROSION_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(DEPTH_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(RIDGES_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY)), - wrap(densityFuns.getOrThrow(FINAL_DENSITY_FUNCTION_KEY)), + wrap(densityFuns.getOrThrow(TEMPERATURE)), + wrap(densityFuns.getOrThrow(VEGETATION)), + wrap(densityFuns.getOrThrow(CONTINENTS)), + wrap(densityFuns.getOrThrow(EROSION)), + wrap(densityFuns.getOrThrow(DEPTH)), + wrap(densityFuns.getOrThrow(RIDGES)), + wrap(densityFuns.getOrThrow(DENSITY_INITIAL_WITHOUT_JAGGEDNESS)), + wrap(densityFuns.getOrThrow(DENSITY_FINAL)), zero(), zero(), zero() diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java index d20acb4d..1f87e9ae 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java @@ -1,5 +1,6 @@ package moriyashiine.aylyth.datagen.common.world.terrain; +import moriyashiine.aylyth.common.data.world.terrain.AylythNoiseParams; import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryEntryLookup; import net.minecraft.registry.RegistryKeys; @@ -9,12 +10,13 @@ import net.minecraft.world.biome.source.util.VanillaTerrainParametersCreator; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.densityfunction.DensityFunction; +import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.RegistryEntryHolder; +import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.Spline; +import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.WeirdScaledSampler; import static moriyashiine.aylyth.common.data.world.AylythDimensionData.*; -import static net.minecraft.world.gen.densityfunction.DensityFunctionTypes.*; - import static moriyashiine.aylyth.common.data.world.terrain.AylythDensityFunctions.*; -import static moriyashiine.aylyth.common.data.world.terrain.AylythNoises.*; +import static net.minecraft.world.gen.densityfunction.DensityFunctionTypes.*; public final class AylythDensityFunctionBootstrap { private AylythDensityFunctionBootstrap() {} @@ -23,40 +25,40 @@ public static void bootstrap(Registerable context) { var densityFuns = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); var noiseParams = context.getRegistryLookup(RegistryKeys.NOISE_PARAMETERS); - var floodedness = context.register(FLOODEDNESS_FUNCTION_KEY, noise(noiseParams.getOrThrow(FLOODEDNESS), 1.0D, 0.67D)); - var fluidSpread = context.register(FLUID_SPREAD_FUNCTION_KEY, noise(noiseParams.getOrThrow(FLUID_SPREAD), 1.0D, 1D / 1.4D)); + var floodedness = context.register(AQUIFER_FLUID_FLOODEDNESS, noise(noiseParams.getOrThrow(AylythNoiseParams.FLOODEDNESS), 1.0D, 0.67D)); + var fluidSpread = context.register(AQUIFER_FLUID_SPREAD, noise(noiseParams.getOrThrow(AylythNoiseParams.FLUID_SPREAD), 1.0D, 1D / 1.4D)); - var shiftX = context.register(SHIFT_X_KEY, flatCache(cache2d(shiftA(noiseParams.getOrThrow(OFFSET))))); - var shiftZ = context.register(SHIFT_Z_KEY, flatCache(cache2d(shiftB(noiseParams.getOrThrow(OFFSET))))); + var shiftX = context.register(SHIFT_X, flatCache(cache2d(shiftA(noiseParams.getOrThrow(AylythNoiseParams.OFFSET))))); + var shiftZ = context.register(SHIFT_Z, flatCache(cache2d(shiftB(noiseParams.getOrThrow(AylythNoiseParams.OFFSET))))); - var temperature = context.register(TEMPERATURE_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(TEMPERATURE)))); - var vegetation = context.register(VEGETATION_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(VEGETATION)))); - var continents = context.register(CONTINENTS_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(CONTINENTS)))); - var erosion = context.register(EROSION_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(EROSION)))); - var ridges = context.register(RIDGES_FUNCTION_KEY, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(RIDGE)))); - var ridgesFolded = context.register(RIDGES_FOLDED_FUNCTION_KEY, mul(constant(-3.0), add(constant(-0.3333333333333333), add(constant(-0.6666666666666666), wrap(ridges).abs()).abs()))); + var temperature = context.register(TEMPERATURE, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.TEMPERATURE)))); + var vegetation = context.register(VEGETATION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.VEGETATION)))); + var continents = context.register(CONTINENTS, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.CONTINENTS)))); + var erosion = context.register(EROSION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.EROSION)))); + var ridges = context.register(RIDGES, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.RIDGES)))); + var ridgesFolded = context.register(RIDGES_FOLDED, mul(constant(-3.0), add(constant(-0.3333333333333333), add(constant(-0.6666666666666666), wrap(ridges).abs()).abs()))); - var offset = context.register(OFFSET_FUNCTION_KEY, offset(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridgesFolded))); - var depth = context.register(DEPTH_FUNCTION_KEY, add(yClampedGradient(MIN_HEIGHT, ACTUAL_MAX_HEIGHT, 1.5, -1.5), wrap(offset))); + var offset = context.register(OFFSET, offset(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridgesFolded))); + var depth = context.register(DEPTH, add(yClampedGradient(MIN_HEIGHT, ACTUAL_MAX_HEIGHT, 1.5, -1.5), wrap(offset))); - var factor = context.register(FACTOR_FUNCTION_KEY, factor(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); - var jaggedness = context.register(JAGGEDNESS_FUNCTION_KEY, jaggedness(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); - var slopedCheese = context.register(SLOPED_CHEESE_FUNCTION_KEY, slopedCheese(depth, jaggedness, factor, noiseParams)); + var factor = context.register(FACTOR, factor(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); + var jaggedness = context.register(JAGGEDNESS, jaggedness(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); + var slopedCheese = context.register(SLOPED_CHEESE, slopedCheese(depth, jaggedness, factor, noiseParams)); - var caveSpaghetti2dThiknessModulator = context.register(CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR_FUNCTION_KEY, cavesSpaghetti2dThickness(noiseParams)); - var cavesSpaghetti2d = context.register(CAVES_SPAGHETTI_2D_FUNCTION_KEY, cavesSpaghetti2d(caveSpaghetti2dThiknessModulator, noiseParams)); - var cavesSpaghettiRoughness = context.register(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY, cavesSpaghettiRoughness(noiseParams)); - var cavesPillars = context.register(CAVES_PILLARS_FUNCTION_KEY, cavesPillars(noiseParams)); + var caveSpaghetti2dThiknessModulator = context.register(CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR, cavesSpaghetti2dThickness(noiseParams)); + var cavesSpaghetti2d = context.register(CAVES_SPAGHETTI_2D, cavesSpaghetti2d(caveSpaghetti2dThiknessModulator, noiseParams)); + var cavesSpaghettiRoughness = context.register(CAVES_SPAGHETTI_ROUGHNESS, cavesSpaghettiRoughness(noiseParams)); + var cavesPillars = context.register(CAVES_PILLARS, cavesPillars(noiseParams)); int fromY = DimensionType.MIN_HEIGHT * 2; int toY = DimensionType.MAX_COLUMN_HEIGHT * 2; - var y = context.register(Y_FUNCTION_KEY, yClampedGradient(fromY, toY, fromY, toY)); + var y = context.register(Y, yClampedGradient(fromY, toY, fromY, toY)); - var cavesNoodle = context.register(CAVES_NOODLE_FUNCTION_KEY, cavesNoodle(y, noiseParams)); - var cavesEntrances = context.register(CAVES_ENTRANCES_FUNCTION_KEY, constant(1)); + var cavesNoodle = context.register(CAVES_NOODLE, cavesNoodle(y, noiseParams)); + var cavesEntrances = context.register(CAVES_ENTRANCES, constant(1)); - var initialDensityWithoutJaggedness = context.register(INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY, initialDensity(densityFuns)); - var finalDensity = context.register(FINAL_DENSITY_FUNCTION_KEY, finalDensity(densityFuns, noiseParams)); + var initialDensityWithoutJaggedness = context.register(DENSITY_INITIAL_WITHOUT_JAGGEDNESS, initialDensity(densityFuns)); + var finalDensity = context.register(DENSITY_FINAL, finalDensity(densityFuns, noiseParams)); } static DensityFunction wrap(RegistryEntry fun) { @@ -101,7 +103,7 @@ private static DensityFunction slopedCheese(RegistryEntry depth wrap(depth), mul( wrap(jaggednes), - noise(noiseParameters.getOrThrow(JAGGED), 1500.0, 0.0).halfNegative() + noise(noiseParameters.getOrThrow(AylythNoiseParams.JAGGED), 1500.0, 0.0).halfNegative() ) ), wrap(factor) @@ -117,7 +119,7 @@ private static DensityFunction cavesSpaghetti2dThickness(RegistryEntryLookup c return max( add( weirdScaledSampler( - noise(noiseParameters.getOrThrow(SPAGHETTI_2D_MODULATOR), 2.0, 1.0), - noiseParameters.getOrThrow(SPAGHETTI_2D), + noise(noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_MODULATOR), 2.0, 1.0), + noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D), WeirdScaledSampler.RarityValueMapper.TYPE2 ), mul( @@ -142,7 +144,7 @@ private static DensityFunction cavesSpaghetti2d(RegistryEntry c constant(0.0), mul( constant(8.0), - noise(noiseParameters.getOrThrow(SPAGHETTI_2D_ELEVATION), 1.0, 0.0) + noise(noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_ELEVATION), 1.0, 0.0) ) ), yClampedGradient( @@ -164,12 +166,12 @@ private static DensityFunction cavesSpaghettiRoughness(RegistryEntryLookup y, Reg wrap(y), -60.0, 21.0, - noise(noiseParameters.getOrThrow(NOODLE)), + noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE)), constant(-1.0) ) ), @@ -226,7 +228,7 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg constant(-0.075), mul( constant(-0.025), - noise(noiseParameters.getOrThrow(NOODLE_THICKNESS)) + noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE_THICKNESS)) ) ), constant(0.0) @@ -240,7 +242,7 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg wrap(y), -60.0, 21.0, - noise(noiseParameters.getOrThrow(NOODLE_RIDGE_A), 2.6666666666666665, 2.6666666666666665), + noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE_RIDGE_A), 2.6666666666666665, 2.6666666666666665), constant(0.0) ) ).abs(), @@ -249,7 +251,7 @@ private static DensityFunction cavesNoodle(RegistryEntry y, Reg wrap(y), -60.0, 21.0, - noise(noiseParameters.getOrThrow(NOODLE_RIDGE_B), 2.6666666666666665, 2.6666666666666665), + noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE_RIDGE_B), 2.6666666666666665, 2.6666666666666665), constant(0.0) ) ) @@ -284,8 +286,8 @@ private static DensityFunction initialDensity(RegistryEntryLookup AylythDensityFunctionBootstrap.postProcess( AylythDensityFunctionBootstrap.slide( rangeChoice( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE)), -1000000.0, 1.5625, min( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE)), mul( constant(5.0), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES)) ) ), max( @@ -332,35 +334,35 @@ private static DensityFunction finalDensity(RegistryEntryLookup add( mul( constant(4.0), - noise(noiseParameters.getOrThrow(CAVE_LAYER), 1.0, 8.0).square() + noise(noiseParameters.getOrThrow(AylythNoiseParams.CAVE_LAYER), 1.0, 8.0).square() ), add( add( constant(0.27), - noise(noiseParameters.getOrThrow(CAVE_CHEESE), 2.0, 0.95) + noise(noiseParameters.getOrThrow(AylythNoiseParams.CAVE_CHEESE), 2.0, 0.95) ).clamp(-1.0, 1.0), add( constant(1.5), mul( constant(-0.64), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE)) ) ).clamp(0.0, 0.5) ) ), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES)) ), add( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_2D_FUNCTION_KEY)), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_2D)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_ROUGHNESS)) ) ), rangeChoice( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)), + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS)), -1000000.0, 0.03, constant(-1000000.0), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS)) ) ) ), @@ -370,7 +372,7 @@ private static DensityFunction finalDensity(RegistryEntryLookup 0, 24, 0.1171875 ) ), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_NOODLE_FUNCTION_KEY)) + AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_NOODLE)) ); } } diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java index f0d0e085..986ea70c 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java @@ -1,7 +1,7 @@ package moriyashiine.aylyth.datagen.common.world.terrain; import moriyashiine.aylyth.common.data.world.AylythBiomes; -import moriyashiine.aylyth.common.data.world.terrain.AylythNoises; +import moriyashiine.aylyth.common.data.world.terrain.AylythNoiseParams; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.registry.RegistryKey; @@ -21,8 +21,8 @@ public static MaterialRule create() { var grass = block(Blocks.GRASS_BLOCK); var onReplaceWithGrass = condition(water(0, 0), grass); - var commonPodzol = podzol(AylythNoises.PODZOL_COMMON, 0.3, Double.MAX_VALUE); - var rarePodzol = podzol(AylythNoises.PODZOL_RARE, 0.95, Double.MAX_VALUE); + var commonPodzol = podzol(AylythNoiseParams.PODZOL_COMMON, 0.3, Double.MAX_VALUE); + var rarePodzol = podzol(AylythNoiseParams.PODZOL_RARE, 0.95, Double.MAX_VALUE); var podzolDecoCommon = sequence(condition(biome(AylythBiomes.DEEPWOOD, AylythBiomes.CONIFEROUS_DEEPWOOD), commonPodzol)); var podzolDecoRare = condition(biome(AylythBiomes.COPSE, AylythBiomes.OVERGROWN_CLEARING), rarePodzol); var onSurface = condition( @@ -56,7 +56,7 @@ private static MaterialRule mireUnderwaterMud() { } private static MaterialRule bowels() { - return condition(biome(AylythBiomes.BOWELS), sequence(condition(stoneDepth(0, false, 0, VerticalSurfaceType.FLOOR), condition(water(0, 0), noiseBlock(AylythNoises.BOWELS_SOUL_SAND, Blocks.SOUL_SAND, 0.6, Double.MAX_VALUE))), condition(waterWithStoneDepth(-6, -1), condition(stoneDepth(0, true, 0, VerticalSurfaceType.FLOOR), block(Blocks.SOUL_SOIL))))); + return condition(biome(AylythBiomes.BOWELS), sequence(condition(stoneDepth(0, false, 0, VerticalSurfaceType.FLOOR), condition(water(0, 0), noiseBlock(AylythNoiseParams.BOWELS_SOUL_SAND, Blocks.SOUL_SAND, 0.6, Double.MAX_VALUE))), condition(waterWithStoneDepth(-6, -1), condition(stoneDepth(0, true, 0, VerticalSurfaceType.FLOOR), block(Blocks.SOUL_SOIL))))); } private static MaterialRule podzol(RegistryKey noise, double min, double max) { @@ -68,7 +68,7 @@ private static MaterialRule noiseBlock(RegistryKey context) { context.register(FLOODEDNESS, new NoiseParameters(-7, 1)); @@ -16,7 +16,7 @@ public static void bootstrap(Registerable context) { context.register(VEGETATION, new NoiseParameters(-8, 1, 1, 0, 0, 0, 0)); context.register(CONTINENTS, new NoiseParameters(-9, 1, 1, 2, 2, 2, 1, 1, 1, 1)); context.register(EROSION, new NoiseParameters(-9, 1, 1, 0, 0, 1, 1)); - context.register(RIDGE, new NoiseParameters(-7, 1, 2, 1, 0, 0, 0)); + context.register(RIDGES, new NoiseParameters(-7, 1, 2, 1, 0, 0, 0)); context.register(OFFSET, new NoiseParameters(-3, 1, 1, 1, 0)); context.register(JAGGED, new NoiseParameters(-16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)); @@ -28,10 +28,6 @@ public static void bootstrap(Registerable context) { context.register(SPAGHETTI_2D_ROUGHNESS, new NoiseParameters(-5, 1)); context.register(SPAGHETTI_2D_THICKNESS, new NoiseParameters(-11, 1)); context.register(SPAGHETTI_2D_ELEVATION, new NoiseParameters(-8, 1)); - context.register(SPAGHETTI_3D_1, new NoiseParameters(-7, 1)); - context.register(SPAGHETTI_3D_2, new NoiseParameters(-7, 1)); - context.register(SPAGHETTI_3D_RARITY, new NoiseParameters(-11, 1)); - context.register(SPAGHETTI_3D_THICKNESS, new NoiseParameters(-11, 1)); context.register(PILLAR, new NoiseParameters(-7, 1, 1)); context.register(PILLAR_RARENESS, new NoiseParameters(-8, 1)); context.register(PILLAR_THICKNESS, new NoiseParameters(-8, 1)); @@ -39,7 +35,6 @@ public static void bootstrap(Registerable context) { context.register(NOODLE_THICKNESS, new NoiseParameters(-8, 1)); context.register(NOODLE_RIDGE_A, new NoiseParameters(-7, 1)); context.register(NOODLE_RIDGE_B, new NoiseParameters(-7, 1)); - context.register(CAVE_ENTRANCES, new NoiseParameters(-7, 0.4, 0.5, 1)); context.register(SURFACE, new NoiseParameters(-6, 1, 1, 1)); context.register(PODZOL_COMMON, new NoiseParameters(-4, 1, 1)); diff --git a/src/main/generated/data/aylyth/worldgen/density_function/floodedness.json b/src/main/generated/data/aylyth/worldgen/density_function/aquifer_fluid_floodedness.json similarity index 100% rename from src/main/generated/data/aylyth/worldgen/density_function/floodedness.json rename to src/main/generated/data/aylyth/worldgen/density_function/aquifer_fluid_floodedness.json diff --git a/src/main/generated/data/aylyth/worldgen/density_function/fluid_spread.json b/src/main/generated/data/aylyth/worldgen/density_function/aquifer_fluid_spread.json similarity index 100% rename from src/main/generated/data/aylyth/worldgen/density_function/fluid_spread.json rename to src/main/generated/data/aylyth/worldgen/density_function/aquifer_fluid_spread.json diff --git a/src/main/generated/data/aylyth/worldgen/density_function/final_density.json b/src/main/generated/data/aylyth/worldgen/density_function/density_final.json similarity index 100% rename from src/main/generated/data/aylyth/worldgen/density_function/final_density.json rename to src/main/generated/data/aylyth/worldgen/density_function/density_final.json diff --git a/src/main/generated/data/aylyth/worldgen/density_function/initial_density_without_jaggedness.json b/src/main/generated/data/aylyth/worldgen/density_function/density_initial_without_jaggedness.json similarity index 100% rename from src/main/generated/data/aylyth/worldgen/density_function/initial_density_without_jaggedness.json rename to src/main/generated/data/aylyth/worldgen/density_function/density_initial_without_jaggedness.json diff --git a/src/main/generated/data/aylyth/worldgen/density_function/ridges.json b/src/main/generated/data/aylyth/worldgen/density_function/ridges.json index 3cf501ff..ef8038b6 100644 --- a/src/main/generated/data/aylyth/worldgen/density_function/ridges.json +++ b/src/main/generated/data/aylyth/worldgen/density_function/ridges.json @@ -2,7 +2,7 @@ "type": "minecraft:flat_cache", "argument": { "type": "minecraft:shifted_noise", - "noise": "aylyth:ridge", + "noise": "aylyth:ridges", "shift_x": "aylyth:shift_x", "shift_y": 0.0, "shift_z": "aylyth:shift_z", diff --git a/src/main/generated/data/aylyth/worldgen/noise/ridge.json b/src/main/generated/data/aylyth/worldgen/noise/ridges.json similarity index 100% rename from src/main/generated/data/aylyth/worldgen/noise/ridge.json rename to src/main/generated/data/aylyth/worldgen/noise/ridges.json diff --git a/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json b/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json index fad9c34e..1d072ac9 100644 --- a/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json +++ b/src/main/generated/data/aylyth/worldgen/noise_settings/aylyth_settings.json @@ -25,10 +25,10 @@ "continents": "aylyth:continents", "depth": "aylyth:depth", "erosion": "aylyth:erosion", - "final_density": "aylyth:final_density", - "fluid_level_floodedness": "aylyth:floodedness", - "fluid_level_spread": "aylyth:fluid_spread", - "initial_density_without_jaggedness": "aylyth:initial_density_without_jaggedness", + "final_density": "aylyth:density_final", + "fluid_level_floodedness": "aylyth:aquifer_fluid_floodedness", + "fluid_level_spread": "aylyth:aquifer_fluid_spread", + "initial_density_without_jaggedness": "aylyth:density_initial_without_jaggedness", "lava": 0.0, "ridges": "aylyth:ridges", "temperature": "aylyth:temperature", diff --git a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java index 0869cf34..2bffd5e4 100644 --- a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java +++ b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythDensityFunctions.java @@ -7,38 +7,38 @@ public interface AylythDensityFunctions { - RegistryKey FLOODEDNESS_FUNCTION_KEY = bind("floodedness"); - RegistryKey FLUID_SPREAD_FUNCTION_KEY = bind("fluid_spread"); + RegistryKey AQUIFER_FLUID_FLOODEDNESS = bind("aquifer_fluid_floodedness"); + RegistryKey AQUIFER_FLUID_SPREAD = bind("aquifer_fluid_spread"); - RegistryKey SHIFT_X_KEY = bind("shift_x"); - RegistryKey SHIFT_Z_KEY = bind("shift_z"); + RegistryKey SHIFT_X = bind("shift_x"); + RegistryKey SHIFT_Z = bind("shift_z"); - RegistryKey TEMPERATURE_FUNCTION_KEY = bind("temperature"); - RegistryKey VEGETATION_FUNCTION_KEY = bind("vegetation"); - RegistryKey CONTINENTS_FUNCTION_KEY = bind("continents"); - RegistryKey EROSION_FUNCTION_KEY = bind("erosion"); - RegistryKey RIDGES_FUNCTION_KEY = bind("ridges"); - RegistryKey RIDGES_FOLDED_FUNCTION_KEY = bind("ridges_folded"); + RegistryKey TEMPERATURE = bind("temperature"); + RegistryKey VEGETATION = bind("vegetation"); + RegistryKey CONTINENTS = bind("continents"); + RegistryKey EROSION = bind("erosion"); + RegistryKey RIDGES = bind("ridges"); + RegistryKey RIDGES_FOLDED = bind("ridges_folded"); - RegistryKey OFFSET_FUNCTION_KEY = bind("offset"); - RegistryKey DEPTH_FUNCTION_KEY = bind("depth"); + RegistryKey OFFSET = bind("offset"); + RegistryKey DEPTH = bind("depth"); - RegistryKey FACTOR_FUNCTION_KEY = bind("factor"); - RegistryKey JAGGEDNESS_FUNCTION_KEY = bind("jaggedness"); - RegistryKey SLOPED_CHEESE_FUNCTION_KEY = bind("sloped_cheese"); + RegistryKey FACTOR = bind("factor"); + RegistryKey JAGGEDNESS = bind("jaggedness"); + RegistryKey SLOPED_CHEESE = bind("sloped_cheese"); - RegistryKey CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR_FUNCTION_KEY = bind("caves/spaghetti_2d_thickness_modulator"); - RegistryKey CAVES_SPAGHETTI_2D_FUNCTION_KEY = bind("caves/spaghetti_2d"); - RegistryKey CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_KEY = bind("caves/spaghetti_roughness"); - RegistryKey CAVES_PILLARS_FUNCTION_KEY = bind("caves/pillars"); + RegistryKey CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR = bind("caves/spaghetti_2d_thickness_modulator"); + RegistryKey CAVES_SPAGHETTI_2D = bind("caves/spaghetti_2d"); + RegistryKey CAVES_SPAGHETTI_ROUGHNESS = bind("caves/spaghetti_roughness"); + RegistryKey CAVES_PILLARS = bind("caves/pillars"); - RegistryKey Y_FUNCTION_KEY = bind("y"); + RegistryKey Y = bind("y"); - RegistryKey CAVES_NOODLE_FUNCTION_KEY = bind("caves/noodle"); - RegistryKey CAVES_ENTRANCES_FUNCTION_KEY = bind("caves/entrances"); + RegistryKey CAVES_NOODLE = bind("caves/noodle"); + RegistryKey CAVES_ENTRANCES = bind("caves/entrances"); - RegistryKey INITIAL_DENSITY_WITHOUT_JAGGEDNESS_FUNCTION_KEY = bind("initial_density_without_jaggedness"); - RegistryKey FINAL_DENSITY_FUNCTION_KEY = bind("final_density"); + RegistryKey DENSITY_INITIAL_WITHOUT_JAGGEDNESS = bind("density_initial_without_jaggedness"); + RegistryKey DENSITY_FINAL = bind("density_final"); private static RegistryKey bind(String name) { return RegistryKey.of(RegistryKeys.DENSITY_FUNCTION, Aylyth.id(name)); diff --git a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoises.java b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoiseParams.java similarity index 96% rename from src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoises.java rename to src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoiseParams.java index c4ac6587..fa320b20 100644 --- a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoises.java +++ b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoiseParams.java @@ -5,7 +5,7 @@ import net.minecraft.registry.RegistryKeys; import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters; -public interface AylythNoises { +public interface AylythNoiseParams { RegistryKey FLOODEDNESS = bind("aquifer_fluid_level_floodedness"); RegistryKey FLUID_SPREAD = bind("aquifer_fluid_level_spread"); @@ -14,7 +14,7 @@ public interface AylythNoises { RegistryKey VEGETATION = bind("vegetation"); RegistryKey CONTINENTS = bind("continents"); RegistryKey EROSION = bind("erosion"); - RegistryKey RIDGE = bind("ridge"); + RegistryKey RIDGES = bind("ridges"); RegistryKey OFFSET = bind("offset"); RegistryKey JAGGED = bind("jagged"); From 155390260ceab47a12148fb44abd9ff36d11472b Mon Sep 17 00:00:00 2001 From: miyamashak Date: Thu, 17 Oct 2024 22:33:21 +0300 Subject: [PATCH 4/6] Parity density features with vanilla keeping the mod features (the mod seems to have missed a couple of wraps, see noodle.json and spaghetti_2d.json) --- .../AylythChunkGenSettingsBootstrap.java | 3 + .../AylythDensityFunctionBootstrap.java | 394 +++++------------- .../terrain/AylythNoiseParamsBootstrap.java | 9 +- .../density_function/caves/noodle.json | 29 +- .../density_function/caves/pillars.json | 2 +- .../density_function/caves/spaghetti_2d.json | 51 +-- .../spaghetti_2d_thickness_modulator.json | 2 +- .../caves/spaghetti_roughness.json | 4 +- ...illar_rareness.json => pillar_rarity.json} | 0 ...oughness.json => spaghetti_roughness.json} | 0 .../noise/spaghetti_roughness_modulator.json | 6 + .../data/world/terrain/AylythNoiseParams.java | 5 +- src/main/resources/aylyth.accesswidener | 10 + 13 files changed, 169 insertions(+), 346 deletions(-) rename src/main/generated/data/aylyth/worldgen/noise/{pillar_rareness.json => pillar_rarity.json} (100%) rename src/main/generated/data/aylyth/worldgen/noise/{spaghetti_2d_roughness.json => spaghetti_roughness.json} (100%) create mode 100644 src/main/generated/data/aylyth/worldgen/noise/spaghetti_roughness_modulator.json diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java index 49541a66..d8865601 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java @@ -22,6 +22,9 @@ private AylythChunkGenSettingsBootstrap() {} public static void bootstrap(Registerable context) { var densityFuns = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); + // VANILLACOPY ChunkGeneratorSettings.OVERWORLD + // Changed world height, gen vertical size 2 -> 1, no aquifer barriers, no lava, no big ore veins, sea level 63 -> 47 + var shapeConfig = new GenerationShapeConfig(MIN_HEIGHT, SHAPE_MAX_HEIGHT, 1, 1); var noiseRouter = new NoiseRouter( zero(), diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java index 1f87e9ae..20ef532a 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java @@ -2,377 +2,171 @@ import moriyashiine.aylyth.common.data.world.terrain.AylythNoiseParams; import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryEntryLookup; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; -import net.minecraft.util.math.noise.InterpolatedNoiseSampler; -import net.minecraft.world.biome.source.util.VanillaTerrainParametersCreator; +import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.densityfunction.DensityFunction; import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.RegistryEntryHolder; -import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.Spline; -import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.WeirdScaledSampler; +import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.Spline.DensityFunctionWrapper; +import net.minecraft.world.gen.densityfunction.DensityFunctionTypes.WeirdScaledSampler.RarityValueMapper; +import static java.lang.Math.floorDiv; import static moriyashiine.aylyth.common.data.world.AylythDimensionData.*; import static moriyashiine.aylyth.common.data.world.terrain.AylythDensityFunctions.*; +import static net.minecraft.util.math.noise.InterpolatedNoiseSampler.createBase3dNoiseFunction; +import static net.minecraft.world.biome.source.util.VanillaTerrainParametersCreator.*; import static net.minecraft.world.gen.densityfunction.DensityFunctionTypes.*; +import static net.minecraft.world.gen.densityfunction.DensityFunctions.*; public final class AylythDensityFunctionBootstrap { private AylythDensityFunctionBootstrap() {} + // VANILLACOPY DensityFunctions + + private static final double NOISE_XZ_SCALE = 0.25; + public static void bootstrap(Registerable context) { - var densityFuns = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); var noiseParams = context.getRegistryLookup(RegistryKeys.NOISE_PARAMETERS); - var floodedness = context.register(AQUIFER_FLUID_FLOODEDNESS, noise(noiseParams.getOrThrow(AylythNoiseParams.FLOODEDNESS), 1.0D, 0.67D)); - var fluidSpread = context.register(AQUIFER_FLUID_SPREAD, noise(noiseParams.getOrThrow(AylythNoiseParams.FLUID_SPREAD), 1.0D, 1D / 1.4D)); + var floodedness = context.register(AQUIFER_FLUID_FLOODEDNESS, noise(noiseParams.getOrThrow(AylythNoiseParams.FLOODEDNESS), 0.67)); + var fluidSpread = context.register(AQUIFER_FLUID_SPREAD, noise(noiseParams.getOrThrow(AylythNoiseParams.FLUID_SPREAD), 1 / 1.4)); var shiftX = context.register(SHIFT_X, flatCache(cache2d(shiftA(noiseParams.getOrThrow(AylythNoiseParams.OFFSET))))); var shiftZ = context.register(SHIFT_Z, flatCache(cache2d(shiftB(noiseParams.getOrThrow(AylythNoiseParams.OFFSET))))); - var temperature = context.register(TEMPERATURE, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.TEMPERATURE)))); - var vegetation = context.register(VEGETATION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.VEGETATION)))); - var continents = context.register(CONTINENTS, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.CONTINENTS)))); - var erosion = context.register(EROSION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.EROSION)))); - var ridges = context.register(RIDGES, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), 0.25, noiseParams.getOrThrow(AylythNoiseParams.RIDGES)))); - var ridgesFolded = context.register(RIDGES_FOLDED, mul(constant(-3.0), add(constant(-0.3333333333333333), add(constant(-0.6666666666666666), wrap(ridges).abs()).abs()))); + var temperature = context.register(TEMPERATURE, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.TEMPERATURE)))); + var vegetation = context.register(VEGETATION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.VEGETATION)))); + var continents = context.register(CONTINENTS, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.CONTINENTS)))); + var erosion = context.register(EROSION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.EROSION)))); + var ridges = context.register(RIDGES, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.RIDGES)))); + var ridgesFolded = context.register(RIDGES_FOLDED, createRidgesFoldedOverworldFunction(wrap(ridges))); var offset = context.register(OFFSET, offset(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridgesFolded))); var depth = context.register(DEPTH, add(yClampedGradient(MIN_HEIGHT, ACTUAL_MAX_HEIGHT, 1.5, -1.5), wrap(offset))); var factor = context.register(FACTOR, factor(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); var jaggedness = context.register(JAGGEDNESS, jaggedness(wrapSlidePos(continents), wrapSlidePos(erosion), wrapSlidePos(ridges), wrapSlidePos(ridgesFolded))); - var slopedCheese = context.register(SLOPED_CHEESE, slopedCheese(depth, jaggedness, factor, noiseParams)); - var caveSpaghetti2dThiknessModulator = context.register(CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR, cavesSpaghetti2dThickness(noiseParams)); - var cavesSpaghetti2d = context.register(CAVES_SPAGHETTI_2D, cavesSpaghetti2d(caveSpaghetti2dThiknessModulator, noiseParams)); - var cavesSpaghettiRoughness = context.register(CAVES_SPAGHETTI_ROUGHNESS, cavesSpaghettiRoughness(noiseParams)); - var cavesPillars = context.register(CAVES_PILLARS, cavesPillars(noiseParams)); + var base3dInlined = createBase3dNoiseFunction(NOISE_XZ_SCALE, 0.125, 80, 160, 8); + var slopedCheese = context.register(SLOPED_CHEESE, slopedCheese(base3dInlined, wrap(factor), wrap(depth), wrap(jaggedness), noiseParams.getOrThrow(AylythNoiseParams.JAGGED))); + + var caveSpaghetti2dThiknessModulator = context.register(CAVES_SPAGHETTI_2D_THICKNESS_MODULATOR, cacheOnce(noiseInRange(noiseParams.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_THICKNESS), 2, 1, -0.6, -1.3))); + + // Limit spaghetti caves to 80 height + var cavesSpaghetti2d = context.register(CAVES_SPAGHETTI_2D, cavesSpaghetti2d(noiseParams.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_MODULATOR), noiseParams.getOrThrow(AylythNoiseParams.SPAGHETTI_2D), noiseParams.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_ELEVATION), wrap(caveSpaghetti2dThiknessModulator), MIN_HEIGHT, 80)); // MAX_HEIGHT -> 80 + var cavesSpaghettiRoughness = context.register(CAVES_SPAGHETTI_ROUGHNESS, cacheOnce(mul(noiseInRange(noiseParams.getOrThrow(AylythNoiseParams.SPAGHETTI_ROUGHNESS_MODULATOR), 0, -0.1), add(noise(noiseParams.getOrThrow(AylythNoiseParams.SPAGHETTI_ROUGHNESS)).abs(), constant(-0.4))))); + var cavesPillars = context.register(CAVES_PILLARS, cavesPillars(noiseParams.getOrThrow(AylythNoiseParams.PILLAR), noiseParams.getOrThrow(AylythNoiseParams.PILLAR_RARITY), noiseParams.getOrThrow(AylythNoiseParams.PILLAR_THICKNESS))); int fromY = DimensionType.MIN_HEIGHT * 2; int toY = DimensionType.MAX_COLUMN_HEIGHT * 2; var y = context.register(Y, yClampedGradient(fromY, toY, fromY, toY)); - var cavesNoodle = context.register(CAVES_NOODLE, cavesNoodle(y, noiseParams)); - var cavesEntrances = context.register(CAVES_ENTRANCES, constant(1)); + // Limit noodle caves to 20 height + var cavesNoodle = context.register(CAVES_NOODLE, cavesNoodle(wrap(y), noiseParams.getOrThrow(AylythNoiseParams.NOODLE), noiseParams.getOrThrow(AylythNoiseParams.NOODLE_THICKNESS), noiseParams.getOrThrow(AylythNoiseParams.NOODLE_RIDGE_A), noiseParams.getOrThrow(AylythNoiseParams.NOODLE_RIDGE_B), MIN_HEIGHT + 4, 20)); // MAX_HEIGHT -> 20 + var cavesEntrances = context.register(CAVES_ENTRANCES, constant(1)); // changed to constant + + var initialDensityWithoutJaggedness = context.register(DENSITY_INITIAL_WITHOUT_JAGGEDNESS, densityInitialWithoutJaggedness(wrap(factor), wrap(depth), MIN_HEIGHT, ACTUAL_MAX_HEIGHT)); - var initialDensityWithoutJaggedness = context.register(DENSITY_INITIAL_WITHOUT_JAGGEDNESS, initialDensity(densityFuns)); - var finalDensity = context.register(DENSITY_FINAL, finalDensity(densityFuns, noiseParams)); + var cavesFinalInlined = caves(noiseParams.getOrThrow(AylythNoiseParams.CAVE_LAYER), noiseParams.getOrThrow(AylythNoiseParams.CAVE_CHEESE), wrap(slopedCheese), wrap(cavesSpaghetti2d), wrap(cavesSpaghettiRoughness), wrap(cavesEntrances), wrap(cavesPillars)); + var finalDensity = context.register(DENSITY_FINAL, densityFinal(wrap(slopedCheese), wrap(cavesEntrances), wrap(cavesNoodle), cavesFinalInlined, MIN_HEIGHT, ACTUAL_MAX_HEIGHT)); } static DensityFunction wrap(RegistryEntry fun) { return new RegistryEntryHolder(fun); } - private static Spline.DensityFunctionWrapper wrapSlidePos(RegistryEntry fun) { - return new Spline.DensityFunctionWrapper(fun); + private static DensityFunctionWrapper wrapSlidePos(RegistryEntry fun) { + return new DensityFunctionWrapper(fun); } - private static DensityFunction offset(Spline.DensityFunctionWrapper continentsCoordinate, Spline.DensityFunctionWrapper erosionCoordinate, Spline.DensityFunctionWrapper ridgesFoldedCoordinate) { - return withBlending( - add( - constant(-0.50375f), - spline( - VanillaTerrainParametersCreator.createOffsetSpline(continentsCoordinate, erosionCoordinate, ridgesFoldedCoordinate, false) - ) - ), - blendOffset()); + private static DensityFunction offset(DensityFunctionWrapper continentsSplinePos, DensityFunctionWrapper erosionSplinePos, DensityFunctionWrapper ridgesFoldedSplinePos) { + return applyBlending( + add(constant(field_37690), spline(createOffsetSpline(continentsSplinePos, erosionSplinePos, ridgesFoldedSplinePos, false))), + blendOffset() + ); } - private static DensityFunction factor(Spline.DensityFunctionWrapper continentsCoordinate, Spline.DensityFunctionWrapper erosionCoordinate, Spline.DensityFunctionWrapper ridgesCoordinate, Spline.DensityFunctionWrapper ridgesFoldedCoordinate) { - return withBlending( - spline(VanillaTerrainParametersCreator.createFactorSpline(continentsCoordinate, erosionCoordinate, ridgesCoordinate, ridgesFoldedCoordinate, false)), + private static DensityFunction factor(DensityFunctionWrapper continentsSplinePos, DensityFunctionWrapper erosionSplinePos, DensityFunctionWrapper ridgesSplinePos, DensityFunctionWrapper ridgesFoldedSplinePos) { + return applyBlending( + spline(createFactorSpline(continentsSplinePos, erosionSplinePos, ridgesSplinePos, ridgesFoldedSplinePos, false)), constant(10) ); } - private static DensityFunction jaggedness(Spline.DensityFunctionWrapper continentsCoordinate, Spline.DensityFunctionWrapper erosionCoordinate, Spline.DensityFunctionWrapper ridgesCoordinate, Spline.DensityFunctionWrapper ridgesFoldedCoordinate) { - return withBlending( - spline(VanillaTerrainParametersCreator.createJaggednessSpline(continentsCoordinate, erosionCoordinate, ridgesCoordinate, ridgesFoldedCoordinate, false)), - constant(0) + private static DensityFunction jaggedness(DensityFunctionWrapper continentsSplinePos, DensityFunctionWrapper erosionSplinePos, DensityFunctionWrapper ridgesSplinePos, DensityFunctionWrapper ridgesFoldedSplinePos) { + return applyBlending( + spline(createJaggednessSpline(continentsSplinePos, erosionSplinePos, ridgesSplinePos, ridgesFoldedSplinePos, false)), + zero() ); } - private static DensityFunction slopedCheese(RegistryEntry depth, RegistryEntry jaggednes, RegistryEntry factor, RegistryEntryLookup noiseParameters) { + private static DensityFunction slopedCheese(DensityFunction base3dNoise, DensityFunction factor, DensityFunction depth, DensityFunction jaggedness, RegistryEntry jaggedNoise) { return add( - mul( - constant(4.0), - mul( - add( - wrap(depth), - mul( - wrap(jaggednes), - noise(noiseParameters.getOrThrow(AylythNoiseParams.JAGGED), 1500.0, 0.0).halfNegative() - ) - ), - wrap(factor) - ).quarterNegative() - ), - InterpolatedNoiseSampler.createBase3dNoiseFunction(0.25, 0.125, 80.0, 160.0, 8.0) + createInitialDensityFunction(factor, add(depth, mul(jaggedness, noise(jaggedNoise, 1500, 0).halfNegative()))), + base3dNoise ); } - private static DensityFunction cavesSpaghetti2dThickness(RegistryEntryLookup noiseParameters) { - return cacheOnce( - add( - constant(-0.95), - mul( - constant(-0.35), - noise(noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_THICKNESS), 2.0, 1.0) - ) - ) - ); - } + private static DensityFunction cavesSpaghetti2d(RegistryEntry spaghetti2dModulator, RegistryEntry spaghetti2d, RegistryEntry spaghetti2dElevation, DensityFunction spaghetti2dThicknessModulator, int minHeight, int maxHeight) { + var scaledSpaghetti2dModulator = weirdScaledSampler(noise(spaghetti2dModulator, 2, 1), spaghetti2d, RarityValueMapper.TYPE2); + var spaghetti2d1 = add(scaledSpaghetti2dModulator, mul(constant(0.083), spaghetti2dThicknessModulator)); - private static DensityFunction cavesSpaghetti2d(RegistryEntry caveSpaghetti2dThicknessModulator, RegistryEntryLookup noiseParameters) { - return max( - add( - weirdScaledSampler( - noise(noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_MODULATOR), 2.0, 1.0), - noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D), - WeirdScaledSampler.RarityValueMapper.TYPE2 - ), - mul( - constant(0.083), - wrap(caveSpaghetti2dThicknessModulator) - ) - ), - add( - add( - add( - constant(0.0), - mul( - constant(8.0), - noise(noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_ELEVATION), 1.0, 0.0) - ) - ), - yClampedGradient( - -64, - 80, - 8.0, - -40.0 - ) - ).abs(), - wrap(caveSpaghetti2dThicknessModulator) - ) - ).clamp(-1.0, 1.0); - } + var clampedSpaghetti2dElevation = noiseInRange(spaghetti2dElevation, 0, floorDiv(-64, 8), 8); + var heightedSpaghetti2dElevation = add(clampedSpaghetti2dElevation, yClampedGradient(minHeight, maxHeight, 8, -40)).abs(); + var spaghetti2d2 = add(heightedSpaghetti2dElevation, spaghetti2dThicknessModulator).cube(); - private static DensityFunction cavesSpaghettiRoughness(RegistryEntryLookup noiseParameters) { - return cacheOnce( - mul( - add( - constant(-0.05), - mul( - constant(-0.05), - noise(noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_MODULATOR)) - ) - ), - add( - constant(-0.4), - noise(noiseParameters.getOrThrow(AylythNoiseParams.SPAGHETTI_2D_ROUGHNESS)).abs() - ) - ) - ); + return max(spaghetti2d1, spaghetti2d2).clamp(-1, 1); } - private static DensityFunction cavesPillars(RegistryEntryLookup noiseParameters) { - return cacheOnce( - mul( - add( - mul( - constant(2.0), - noise(noiseParameters.getOrThrow(AylythNoiseParams.PILLAR), 25.0, 0.3) - ), - add( - constant(-1.0), - mul( - constant(-1.0), - noise(noiseParameters.getOrThrow(AylythNoiseParams.PILLAR_RARENESS)) - ) - ) - ), - add( - constant(0.55), - mul( - constant(0.55), - noise(noiseParameters.getOrThrow(AylythNoiseParams.PILLAR_THICKNESS)) - ) - ).cube() - ) - ); - } + private static DensityFunction cavesPillars(RegistryEntry pillarNoise, RegistryEntry pillarRarityNoise, RegistryEntry pillarsThicknessNoise) { + var pillar = noise(pillarNoise, 25, 0.3); + var pillarRarity = noiseInRange(pillarRarityNoise, 0, -2); + var basePillar = add(mul(pillar, constant(2)), pillarRarity); - private static DensityFunction cavesNoodle(RegistryEntry y, RegistryEntryLookup noiseParameters) { // NOTE: This is the cave type that sucks and I hate - return rangeChoice( - interpolated( - rangeChoice( - wrap(y), - -60.0, - 21.0, - noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE)), - constant(-1.0) - ) - ), - -1000000.0, - 0.0, - constant(64.0), - add( - interpolated( - rangeChoice( - wrap(y), - -60.0, - 21.0, - add( - constant(-0.075), - mul( - constant(-0.025), - noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE_THICKNESS)) - ) - ), - constant(0.0) - ) - ), - mul( - constant(1.5), - max( - interpolated( - rangeChoice( - wrap(y), - -60.0, - 21.0, - noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE_RIDGE_A), 2.6666666666666665, 2.6666666666666665), - constant(0.0) - ) - ).abs(), - interpolated( - rangeChoice( - wrap(y), - -60.0, - 21.0, - noise(noiseParameters.getOrThrow(AylythNoiseParams.NOODLE_RIDGE_B), 2.6666666666666665, 2.6666666666666665), - constant(0.0) - ) - ) - ) - ) - ) - ); + var clampedPillarThickness = noiseInRange(pillarsThicknessNoise, 0, 1.1); + + return cacheOnce(mul(basePillar, clampedPillarThickness.cube())); } - private static DensityFunction withBlending(DensityFunction end, DensityFunction start) { - return flatCache(cache2d(lerp(blendAlpha(), start, end))); + private static DensityFunction cavesNoodle(DensityFunction y, RegistryEntry noodle, RegistryEntry noodleThickness, RegistryEntry noodleRidgeA, RegistryEntry noodleRidgeB, int minHeight, int maxHeight) { + var heightedNoodle = verticalRangeChoice(y, noise(noodle, 1, 1), minHeight, maxHeight, -1); + + var heightedNoodleThickness = verticalRangeChoice(y, noiseInRange(noodleThickness, 1, 1, -0.05, -0.1), minHeight, maxHeight, 0); + + var heightedNoodleRidgeA = verticalRangeChoice(y, noise(noodleRidgeA, 2.6666666666666665, 2.6666666666666665), minHeight, maxHeight, 0); + var heightedNoodleRidgeB = verticalRangeChoice(y, noise(noodleRidgeB, 2.6666666666666665, 2.6666666666666665), minHeight, maxHeight, 0); + var heightedNoodleRidgeFinal = mul(constant(1.5), max(heightedNoodleRidgeA.abs(), heightedNoodleRidgeB.abs())); + + return rangeChoice(heightedNoodle, -1000000, 0, constant(64), add(heightedNoodleThickness, heightedNoodleRidgeFinal)); } - private static DensityFunction slide(DensityFunction densityFunction, int i, int j, int k, int l, double d, int m, int n, double e) { - DensityFunction densityFunction2 = densityFunction; - DensityFunction densityFunction3 = yClampedGradient(i + j - k, i + j - l, 1.0, 0.0); - densityFunction2 = lerp(densityFunction3, constant(d), densityFunction2); - DensityFunction densityFunction4 = yClampedGradient(i + m, i + n, 0.0, 1.0); - densityFunction2 = lerp(densityFunction4, constant(e), densityFunction2); - return densityFunction2; + private static DensityFunction caves(RegistryEntry cavesLayerNoise, RegistryEntry cavesCheeseNoise, DensityFunction slopedCheese, DensityFunction cavesSpaghetti2d, DensityFunction cavesSpaghettiRoughness, DensityFunction cavesEntrances, DensityFunction cavesPillars) { + var cavesLayer = mul(constant(4), noise(cavesLayerNoise, 8).square()); + var cavesCheese = add( + add(constant(0.27), noise(cavesCheeseNoise, 2, 0.95)).clamp(-1, 1), // 1 -> 2; 0.6666666666666666 -> 0.95 + add(constant(1.5), mul(constant(-0.64), slopedCheese)).clamp(0, 0.5) + ); + var finaleCavesEntrances = min(min(add(cavesLayer, cavesCheese), cavesEntrances), add(cavesSpaghetti2d, cavesSpaghettiRoughness)); + var clampedCavesPillars = rangeChoice(cavesPillars, -1000000, 0.03, constant(-1000000), cavesPillars); + + return max(finaleCavesEntrances, clampedCavesPillars); } - private static DensityFunction postProcess(DensityFunction densityFunction) { - DensityFunction densityFunction2 = blendDensity(densityFunction); - return mul(interpolated(densityFunction2), constant(0.64)).squeeze(); + private static DensityFunction applySurfaceSlides(DensityFunction fun, int minHeight, int maxHeight) { + return applySlides(fun, minHeight, maxHeight, 80, 64, -0.078125, 0, 24, 0.1171875); } - private static DensityFunction initialDensity(RegistryEntryLookup functions) { - return slide( - add( - constant(-0.703125), - mul( - constant(4), - mul( - wrap(functions.getOrThrow(DEPTH)), - cache2d(wrap(functions.getOrThrow(FACTOR))) - ).quarterNegative() - ) - ).clamp(-64, 64), - MIN_HEIGHT, - ACTUAL_MAX_HEIGHT, - 80, 64, -0.078125, - 0, 24, 0.1171875 + private static DensityFunction densityInitialWithoutJaggedness(DensityFunction factor, DensityFunction depth, int minHeight, int maxHeight) { + return applySurfaceSlides( + add(createInitialDensityFunction(cache2d(factor), depth), constant(field_38250)).clamp(-field_37691, field_37691), minHeight, maxHeight ); -// return slide( -// add( -// constant(-0.703125), -// mul( -// constant(4.0), -// mul( -// , -// ).quarterNegative() -// ) -// ).clamp(-64.0, 64.0), -// MIN_HEIGHT, -// ACTUAL_MAX_HEIGHT, -// 80, 64, -0.078125, -// 0, 24, 0.1171875 -// ); } - private static DensityFunction finalDensity(RegistryEntryLookup functions, RegistryEntryLookup noiseParameters) { + private static DensityFunction densityFinal(DensityFunction slopedCheese, DensityFunction cavesEntrances, DensityFunction cavesNoodle, DensityFunction caves, int minHeight, int maxHeight) { return min( - AylythDensityFunctionBootstrap.postProcess( - AylythDensityFunctionBootstrap.slide( - rangeChoice( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE)), - -1000000.0, - 1.5625, - min( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE)), - mul( - constant(5.0), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES)) - ) - ), - max( - min( - min( - add( - mul( - constant(4.0), - noise(noiseParameters.getOrThrow(AylythNoiseParams.CAVE_LAYER), 1.0, 8.0).square() - ), - add( - add( - constant(0.27), - noise(noiseParameters.getOrThrow(AylythNoiseParams.CAVE_CHEESE), 2.0, 0.95) - ).clamp(-1.0, 1.0), - add( - constant(1.5), - mul( - constant(-0.64), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(SLOPED_CHEESE)) - ) - ).clamp(0.0, 0.5) - ) - ), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_ENTRANCES)) - ), - add( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_2D)), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_SPAGHETTI_ROUGHNESS)) - ) - ), - rangeChoice( - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS)), - -1000000.0, - 0.03, - constant(-1000000.0), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_PILLARS)) - ) - ) - ), - MIN_HEIGHT, - ACTUAL_MAX_HEIGHT, - 80, 64, -0.078125, - 0, 24, 0.1171875 - ) - ), - AylythDensityFunctionBootstrap.wrap(functions.getOrThrow(CAVES_NOODLE)) + applyBlendDensity(applySurfaceSlides(rangeChoice(slopedCheese, -1000000, field_36617, min(slopedCheese, mul(constant(5), cavesEntrances)), caves), minHeight, maxHeight)), + cavesNoodle ); } } diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java index c55a5f05..c71a9fb9 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java @@ -9,6 +9,8 @@ public final class AylythNoiseParamsBootstrap { private AylythNoiseParamsBootstrap() {} public static void bootstrap(Registerable context) { + // VANILLACOPY BuiltinNoiseParameters + context.register(FLOODEDNESS, new NoiseParameters(-7, 1)); context.register(FLUID_SPREAD, new NoiseParameters(-5, 1)); @@ -20,16 +22,17 @@ public static void bootstrap(Registerable context) { context.register(OFFSET, new NoiseParameters(-3, 1, 1, 1, 0)); context.register(JAGGED, new NoiseParameters(-16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)); - + context.register(CAVE_LAYER, new NoiseParameters(-8, 1)); context.register(CAVE_CHEESE, new NoiseParameters(-8, 0.5, 1, 2, 1, 2, 1, 0, 2, 0)); context.register(SPAGHETTI_2D, new NoiseParameters(-7, 1)); context.register(SPAGHETTI_2D_MODULATOR, new NoiseParameters(-11, 1)); - context.register(SPAGHETTI_2D_ROUGHNESS, new NoiseParameters(-5, 1)); context.register(SPAGHETTI_2D_THICKNESS, new NoiseParameters(-11, 1)); context.register(SPAGHETTI_2D_ELEVATION, new NoiseParameters(-8, 1)); + context.register(SPAGHETTI_ROUGHNESS, new NoiseParameters(-5, 1)); + context.register(SPAGHETTI_ROUGHNESS_MODULATOR, new NoiseParameters(-8, 1)); context.register(PILLAR, new NoiseParameters(-7, 1, 1)); - context.register(PILLAR_RARENESS, new NoiseParameters(-8, 1)); + context.register(PILLAR_RARITY, new NoiseParameters(-8, 1)); context.register(PILLAR_THICKNESS, new NoiseParameters(-8, 1)); context.register(NOODLE, new NoiseParameters(-8, 1)); context.register(NOODLE_THICKNESS, new NoiseParameters(-8, 1)); diff --git a/src/main/generated/data/aylyth/worldgen/density_function/caves/noodle.json b/src/main/generated/data/aylyth/worldgen/density_function/caves/noodle.json index c306d519..a796686d 100644 --- a/src/main/generated/data/aylyth/worldgen/density_function/caves/noodle.json +++ b/src/main/generated/data/aylyth/worldgen/density_function/caves/noodle.json @@ -30,7 +30,7 @@ "min_inclusive": -60.0, "when_in_range": { "type": "minecraft:add", - "argument1": -0.075, + "argument1": -0.07500000000000001, "argument2": { "type": "minecraft:mul", "argument1": -0.025, @@ -70,19 +70,22 @@ } }, "argument2": { - "type": "minecraft:interpolated", + "type": "minecraft:abs", "argument": { - "type": "minecraft:range_choice", - "input": "aylyth:y", - "max_exclusive": 21.0, - "min_inclusive": -60.0, - "when_in_range": { - "type": "minecraft:noise", - "noise": "aylyth:noodle_ridge_b", - "xz_scale": 2.6666666666666665, - "y_scale": 2.6666666666666665 - }, - "when_out_of_range": 0.0 + "type": "minecraft:interpolated", + "argument": { + "type": "minecraft:range_choice", + "input": "aylyth:y", + "max_exclusive": 21.0, + "min_inclusive": -60.0, + "when_in_range": { + "type": "minecraft:noise", + "noise": "aylyth:noodle_ridge_b", + "xz_scale": 2.6666666666666665, + "y_scale": 2.6666666666666665 + }, + "when_out_of_range": 0.0 + } } } } diff --git a/src/main/generated/data/aylyth/worldgen/density_function/caves/pillars.json b/src/main/generated/data/aylyth/worldgen/density_function/caves/pillars.json index 8a0895a2..5af8ccde 100644 --- a/src/main/generated/data/aylyth/worldgen/density_function/caves/pillars.json +++ b/src/main/generated/data/aylyth/worldgen/density_function/caves/pillars.json @@ -22,7 +22,7 @@ "argument1": -1.0, "argument2": { "type": "minecraft:noise", - "noise": "aylyth:pillar_rareness", + "noise": "aylyth:pillar_rarity", "xz_scale": 1.0, "y_scale": 1.0 } diff --git a/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d.json b/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d.json index a71ea1ab..ee619cf5 100644 --- a/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d.json +++ b/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d.json @@ -22,35 +22,38 @@ } }, "argument2": { - "type": "minecraft:add", - "argument1": { - "type": "minecraft:abs", - "argument": { - "type": "minecraft:add", - "argument1": { + "type": "minecraft:cube", + "argument": { + "type": "minecraft:add", + "argument1": { + "type": "minecraft:abs", + "argument": { "type": "minecraft:add", - "argument1": 0.0, - "argument2": { - "type": "minecraft:mul", - "argument1": 8.0, + "argument1": { + "type": "minecraft:add", + "argument1": 0.0, "argument2": { - "type": "minecraft:noise", - "noise": "aylyth:spaghetti_2d_elevation", - "xz_scale": 1.0, - "y_scale": 0.0 + "type": "minecraft:mul", + "argument1": 8.0, + "argument2": { + "type": "minecraft:noise", + "noise": "aylyth:spaghetti_2d_elevation", + "xz_scale": 1.0, + "y_scale": 0.0 + } } + }, + "argument2": { + "type": "minecraft:y_clamped_gradient", + "from_value": 8.0, + "from_y": -64, + "to_value": -40.0, + "to_y": 80 } - }, - "argument2": { - "type": "minecraft:y_clamped_gradient", - "from_value": 8.0, - "from_y": -64, - "to_value": -40.0, - "to_y": 80 } - } - }, - "argument2": "aylyth:caves/spaghetti_2d_thickness_modulator" + }, + "argument2": "aylyth:caves/spaghetti_2d_thickness_modulator" + } } }, "max": 1.0, diff --git a/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d_thickness_modulator.json b/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d_thickness_modulator.json index 610b91a0..7bea3132 100644 --- a/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d_thickness_modulator.json +++ b/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_2d_thickness_modulator.json @@ -5,7 +5,7 @@ "argument1": -0.95, "argument2": { "type": "minecraft:mul", - "argument1": -0.35, + "argument1": -0.35000000000000003, "argument2": { "type": "minecraft:noise", "noise": "aylyth:spaghetti_2d_thickness", diff --git a/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_roughness.json b/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_roughness.json index 0ebfad15..6c488d3c 100644 --- a/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_roughness.json +++ b/src/main/generated/data/aylyth/worldgen/density_function/caves/spaghetti_roughness.json @@ -10,7 +10,7 @@ "argument1": -0.05, "argument2": { "type": "minecraft:noise", - "noise": "aylyth:spaghetti_2d_modulator", + "noise": "aylyth:spaghetti_roughness_modulator", "xz_scale": 1.0, "y_scale": 1.0 } @@ -23,7 +23,7 @@ "type": "minecraft:abs", "argument": { "type": "minecraft:noise", - "noise": "aylyth:spaghetti_2d_roughness", + "noise": "aylyth:spaghetti_roughness", "xz_scale": 1.0, "y_scale": 1.0 } diff --git a/src/main/generated/data/aylyth/worldgen/noise/pillar_rareness.json b/src/main/generated/data/aylyth/worldgen/noise/pillar_rarity.json similarity index 100% rename from src/main/generated/data/aylyth/worldgen/noise/pillar_rareness.json rename to src/main/generated/data/aylyth/worldgen/noise/pillar_rarity.json diff --git a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_2d_roughness.json b/src/main/generated/data/aylyth/worldgen/noise/spaghetti_roughness.json similarity index 100% rename from src/main/generated/data/aylyth/worldgen/noise/spaghetti_2d_roughness.json rename to src/main/generated/data/aylyth/worldgen/noise/spaghetti_roughness.json diff --git a/src/main/generated/data/aylyth/worldgen/noise/spaghetti_roughness_modulator.json b/src/main/generated/data/aylyth/worldgen/noise/spaghetti_roughness_modulator.json new file mode 100644 index 00000000..897544f9 --- /dev/null +++ b/src/main/generated/data/aylyth/worldgen/noise/spaghetti_roughness_modulator.json @@ -0,0 +1,6 @@ +{ + "amplitudes": [ + 1.0 + ], + "firstOctave": -8 +} \ No newline at end of file diff --git a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoiseParams.java b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoiseParams.java index fa320b20..ae6be1e3 100644 --- a/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoiseParams.java +++ b/src/main/java/moriyashiine/aylyth/common/data/world/terrain/AylythNoiseParams.java @@ -21,11 +21,12 @@ public interface AylythNoiseParams { RegistryKey SPAGHETTI_2D = bind("spaghetti_2d"); RegistryKey SPAGHETTI_2D_MODULATOR = bind("spaghetti_2d_modulator"); - RegistryKey SPAGHETTI_2D_ROUGHNESS = bind("spaghetti_2d_roughness"); RegistryKey SPAGHETTI_2D_THICKNESS = bind("spaghetti_2d_thickness"); RegistryKey SPAGHETTI_2D_ELEVATION = bind("spaghetti_2d_elevation"); + RegistryKey SPAGHETTI_ROUGHNESS = bind("spaghetti_roughness"); + RegistryKey SPAGHETTI_ROUGHNESS_MODULATOR = bind("spaghetti_roughness_modulator"); RegistryKey PILLAR = bind("pillar"); - RegistryKey PILLAR_RARENESS = bind("pillar_rareness"); + RegistryKey PILLAR_RARITY = bind("pillar_rarity"); RegistryKey PILLAR_THICKNESS = bind("pillar_thickness"); RegistryKey NOODLE = bind("noodle"); RegistryKey NOODLE_THICKNESS = bind("noodle_thickness"); diff --git a/src/main/resources/aylyth.accesswidener b/src/main/resources/aylyth.accesswidener index 6f062f77..a6366cd7 100644 --- a/src/main/resources/aylyth.accesswidener +++ b/src/main/resources/aylyth.accesswidener @@ -1,4 +1,5 @@ accessWidener v1 named + accessible class net/minecraft/client/render/RenderLayer$MultiPhase accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters accessible class net/minecraft/client/render/RenderPhase$ShaderProgram @@ -10,6 +11,15 @@ accessible method net/minecraft/client/particle/FlameParticle (Lnet/minec accessible class net/minecraft/client/gui/hud/InGameHud$HeartType accessible class net/minecraft/world/gen/densityfunction/DensityFunctionTypes$WeirdScaledSampler +accessible field net/minecraft/world/gen/densityfunction/DensityFunctions field_38250 D +accessible field net/minecraft/world/gen/densityfunction/DensityFunctions field_36617 D +accessible method net/minecraft/world/gen/densityfunction/DensityFunctions createRidgesFoldedOverworldFunction (Lnet/minecraft/world/gen/densityfunction/DensityFunction;)Lnet/minecraft/world/gen/densityfunction/DensityFunction; +accessible method net/minecraft/world/gen/densityfunction/DensityFunctions createInitialDensityFunction (Lnet/minecraft/world/gen/densityfunction/DensityFunction;Lnet/minecraft/world/gen/densityfunction/DensityFunction;)Lnet/minecraft/world/gen/densityfunction/DensityFunction; +accessible method net/minecraft/world/gen/densityfunction/DensityFunctions applyBlending (Lnet/minecraft/world/gen/densityfunction/DensityFunction;Lnet/minecraft/world/gen/densityfunction/DensityFunction;)Lnet/minecraft/world/gen/densityfunction/DensityFunction; +accessible method net/minecraft/world/gen/densityfunction/DensityFunctions applyBlendDensity (Lnet/minecraft/world/gen/densityfunction/DensityFunction;)Lnet/minecraft/world/gen/densityfunction/DensityFunction; +accessible method net/minecraft/world/gen/densityfunction/DensityFunctions applySlides (Lnet/minecraft/world/gen/densityfunction/DensityFunction;IIIIDIID)Lnet/minecraft/world/gen/densityfunction/DensityFunction; +accessible method net/minecraft/world/gen/densityfunction/DensityFunctions applySurfaceSlides (ZLnet/minecraft/world/gen/densityfunction/DensityFunction;)Lnet/minecraft/world/gen/densityfunction/DensityFunction; +accessible method net/minecraft/world/gen/densityfunction/DensityFunctions verticalRangeChoice (Lnet/minecraft/world/gen/densityfunction/DensityFunction;Lnet/minecraft/world/gen/densityfunction/DensityFunction;III)Lnet/minecraft/world/gen/densityfunction/DensityFunction; extendable class net/minecraft/world/gen/foliage/FoliagePlacer$TreeNode extendable class net/minecraft/world/biome/BiomeEffects$GrassColorModifier accessible field net/minecraft/world/biome/GenerationSettings$LookupBackedBuilder placedFeatureLookup Lnet/minecraft/registry/RegistryEntryLookup; From b979b72d479700157cbd20df1c5e5b28af3907cc Mon Sep 17 00:00:00 2001 From: miyamashak Date: Thu, 17 Oct 2024 23:23:11 +0300 Subject: [PATCH 5/6] Reduce the size and number of oceans --- .../AylythDensityFunctionBootstrap.java | 12 +++++++- .../worldgen/density_function/continents.json | 29 ++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java index 20ef532a..817d339a 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java @@ -4,6 +4,7 @@ import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.util.math.Spline; import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.densityfunction.DensityFunction; @@ -37,7 +38,7 @@ public static void bootstrap(Registerable context) { var temperature = context.register(TEMPERATURE, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.TEMPERATURE)))); var vegetation = context.register(VEGETATION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.VEGETATION)))); - var continents = context.register(CONTINENTS, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.CONTINENTS)))); + var continents = context.register(CONTINENTS, continents(wrap(shiftX), wrap(shiftZ), noiseParams.getOrThrow(AylythNoiseParams.CONTINENTS))); var erosion = context.register(EROSION, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.EROSION)))); var ridges = context.register(RIDGES, flatCache(shiftedNoise(wrap(shiftX), wrap(shiftZ), NOISE_XZ_SCALE, noiseParams.getOrThrow(AylythNoiseParams.RIDGES)))); var ridgesFolded = context.register(RIDGES_FOLDED, createRidgesFoldedOverworldFunction(wrap(ridges))); @@ -80,6 +81,15 @@ private static DensityFunctionWrapper wrapSlidePos(RegistryEntry continentsNoise) { + // Reduce the size and number of oceans + + var vanillaContinents = new DensityFunctionWrapper(RegistryEntry.of(flatCache(shiftedNoise(shiftX, shiftZ, NOISE_XZ_SCALE, continentsNoise)))); + + // Perhaps a more correct way would be to change the OFFSET function, see VanillaTerrainParametersCreator::createOffsetSpline + return flatCache(spline(Spline.builder(vanillaContinents).add(-0.2f, 0, 0.8f).build())); // added + } + private static DensityFunction offset(DensityFunctionWrapper continentsSplinePos, DensityFunctionWrapper erosionSplinePos, DensityFunctionWrapper ridgesFoldedSplinePos) { return applyBlending( add(constant(field_37690), spline(createOffsetSpline(continentsSplinePos, erosionSplinePos, ridgesFoldedSplinePos, false))), diff --git a/src/main/generated/data/aylyth/worldgen/density_function/continents.json b/src/main/generated/data/aylyth/worldgen/density_function/continents.json index b675f237..a4b2d30d 100644 --- a/src/main/generated/data/aylyth/worldgen/density_function/continents.json +++ b/src/main/generated/data/aylyth/worldgen/density_function/continents.json @@ -1,12 +1,27 @@ { "type": "minecraft:flat_cache", "argument": { - "type": "minecraft:shifted_noise", - "noise": "aylyth:continents", - "shift_x": "aylyth:shift_x", - "shift_y": 0.0, - "shift_z": "aylyth:shift_z", - "xz_scale": 0.25, - "y_scale": 0.0 + "type": "minecraft:spline", + "spline": { + "coordinate": { + "type": "minecraft:flat_cache", + "argument": { + "type": "minecraft:shifted_noise", + "noise": "aylyth:continents", + "shift_x": "aylyth:shift_x", + "shift_y": 0.0, + "shift_z": "aylyth:shift_z", + "xz_scale": 0.25, + "y_scale": 0.0 + } + }, + "points": [ + { + "derivative": 0.8, + "location": -0.2, + "value": 0.0 + } + ] + } } } \ No newline at end of file From b47148da275eaf9bae76048c0afc566729ab0d8d Mon Sep 17 00:00:00 2001 From: miyamashak Date: Thu, 17 Oct 2024 23:31:21 +0300 Subject: [PATCH 6/6] Final misc cleanup --- .../aylyth/datagen/AylythDatagen.java | 28 +++++++++---------- .../AylythChunkGenSettingsBootstrap.java | 4 +-- .../AylythDensityFunctionBootstrap.java | 2 +- .../terrain/AylythNoiseParamsBootstrap.java | 6 ++-- ...s.java => AylythSurfaceMaterialRules.java} | 6 ++-- 5 files changed, 24 insertions(+), 22 deletions(-) rename src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/{AylythMaterialRules.java => AylythSurfaceMaterialRules.java} (97%) diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java b/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java index 2399e84d..4188a8f2 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/AylythDatagen.java @@ -61,23 +61,23 @@ public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) { } @Override - public void buildRegistry(RegistryBuilder registryBuilder) { - registryBuilder.addRegistry(RegistryKeys.NOISE_PARAMETERS, AylythNoiseParamsBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.DENSITY_FUNCTION, AylythDensityFunctionBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.CHUNK_GENERATOR_SETTINGS, AylythChunkGenSettingsBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.CONFIGURED_CARVER, AylythConfiguredCarverBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, AylythConfiguredFeatureBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, AylythPlacedFeatureBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.TEMPLATE_POOL, AylythStructurePoolBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.STRUCTURE, AylythStructureBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.STRUCTURE_SET, AylythStructureSetBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.BIOME, AylythBiomeBootstrap::bootstrap); - registryBuilder.addRegistry(RegistryKeys.DAMAGE_TYPE, AylythDamageTypeBootstrap::bootstrap); - registryBuilder.addRegistry(AylythRegistryKeys.LOOT_TABLE_DISPLAY, LootDisplayBootstrap::bootstrap); + public void buildRegistry(RegistryBuilder builder) { + builder.addRegistry(RegistryKeys.NOISE_PARAMETERS, AylythNoiseParamsBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.DENSITY_FUNCTION, AylythDensityFunctionBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.CHUNK_GENERATOR_SETTINGS, AylythChunkGenSettingsBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.CONFIGURED_CARVER, AylythConfiguredCarverBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, AylythConfiguredFeatureBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.PLACED_FEATURE, AylythPlacedFeatureBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.TEMPLATE_POOL, AylythStructurePoolBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.STRUCTURE, AylythStructureBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.STRUCTURE_SET, AylythStructureSetBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.BIOME, AylythBiomeBootstrap::bootstrap); + builder.addRegistry(RegistryKeys.DAMAGE_TYPE, AylythDamageTypeBootstrap::bootstrap); + builder.addRegistry(AylythRegistryKeys.LOOT_TABLE_DISPLAY, LootDisplayBootstrap::bootstrap); } @Override - public @Nullable String getEffectiveModId() { + public String getEffectiveModId() { return Aylyth.MOD_ID; } } diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java index d8865601..3dd66463 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythChunkGenSettingsBootstrap.java @@ -23,7 +23,7 @@ public static void bootstrap(Registerable context) { var densityFuns = context.getRegistryLookup(RegistryKeys.DENSITY_FUNCTION); // VANILLACOPY ChunkGeneratorSettings.OVERWORLD - // Changed world height, gen vertical size 2 -> 1, no aquifer barriers, no lava, no big ore veins, sea level 63 -> 47 + // Changed world height, vertical size 2 -> 1, no aquifer barriers, no lava, no ore veins, sea level 63 -> 47 var shapeConfig = new GenerationShapeConfig(MIN_HEIGHT, SHAPE_MAX_HEIGHT, 1, 1); var noiseRouter = new NoiseRouter( @@ -43,7 +43,7 @@ public static void bootstrap(Registerable context) { zero(), zero() ); - var surfaceMaterialRules = AylythMaterialRules.create(); + var surfaceMaterialRules = AylythSurfaceMaterialRules.build(); var spawnTarget = List.of(); var seaLevel = 47; diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java index 817d339a..6c25597d 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythDensityFunctionBootstrap.java @@ -23,7 +23,7 @@ public final class AylythDensityFunctionBootstrap { private AylythDensityFunctionBootstrap() {} - // VANILLACOPY DensityFunctions + // VANILLACOPY DensityFunctions::bootstrap & DensityFunctions::createSurfaceNoiseRouter private static final double NOISE_XZ_SCALE = 0.25; diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java index c71a9fb9..39d5d979 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythNoiseParamsBootstrap.java @@ -9,7 +9,7 @@ public final class AylythNoiseParamsBootstrap { private AylythNoiseParamsBootstrap() {} public static void bootstrap(Registerable context) { - // VANILLACOPY BuiltinNoiseParameters + // VANILLACOPY BuiltinNoiseParameters::bootstrap context.register(FLOODEDNESS, new NoiseParameters(-7, 1)); context.register(FLUID_SPREAD, new NoiseParameters(-5, 1)); @@ -17,7 +17,7 @@ public static void bootstrap(Registerable context) { context.register(TEMPERATURE, new NoiseParameters(-10, 1.5, 0, 1, 0, 0, 0)); context.register(VEGETATION, new NoiseParameters(-8, 1, 1, 0, 0, 0, 0)); context.register(CONTINENTS, new NoiseParameters(-9, 1, 1, 2, 2, 2, 1, 1, 1, 1)); - context.register(EROSION, new NoiseParameters(-9, 1, 1, 0, 0, 1, 1)); + context.register(EROSION, new NoiseParameters(-9, 1, 1, 0, 0, 1, 1)); // [1, 0, 1, 1] -> [1, 0, 0, 1, 1] context.register(RIDGES, new NoiseParameters(-7, 1, 2, 1, 0, 0, 0)); context.register(OFFSET, new NoiseParameters(-3, 1, 1, 1, 0)); @@ -39,6 +39,8 @@ public static void bootstrap(Registerable context) { context.register(NOODLE_RIDGE_A, new NoiseParameters(-7, 1)); context.register(NOODLE_RIDGE_B, new NoiseParameters(-7, 1)); + // Own + context.register(SURFACE, new NoiseParameters(-6, 1, 1, 1)); context.register(PODZOL_COMMON, new NoiseParameters(-4, 1, 1)); context.register(PODZOL_RARE, new NoiseParameters(-5, 1, 1, 1)); diff --git a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythSurfaceMaterialRules.java similarity index 97% rename from src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java rename to src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythSurfaceMaterialRules.java index 986ea70c..8bdeefe2 100644 --- a/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythMaterialRules.java +++ b/src/datagen/java/moriyashiine/aylyth/datagen/common/world/terrain/AylythSurfaceMaterialRules.java @@ -13,10 +13,10 @@ import static net.minecraft.world.gen.surfacebuilder.MaterialRules.*; -final class AylythMaterialRules { - private AylythMaterialRules() {} +final class AylythSurfaceMaterialRules { + private AylythSurfaceMaterialRules() {} - public static MaterialRule create() { + public static MaterialRule build() { var dirt = block(Blocks.DIRT); var grass = block(Blocks.GRASS_BLOCK);