| 1 | package net.minecraft.world.level.levelgen;
|
| 2 |
|
| 3 | import it.unimi.dsi.fastutil.floats.FloatList;
|
| 4 | import java.util.List;
|
| 5 | import java.util.stream.Stream;
|
| 6 | import net.minecraft.core.Holder;
|
| 7 | import net.minecraft.core.HolderGetter;
|
| 8 | import net.minecraft.core.Vec3i;
|
| 9 | import net.minecraft.core.registries.Registries;
|
| 10 | import net.minecraft.data.worldgen.BootstrapContext;
|
| 11 | import net.minecraft.data.worldgen.TerrainProvider;
|
| 12 | import net.minecraft.resources.Identifier;
|
| 13 | import net.minecraft.resources.ResourceKey;
|
| 14 | import net.minecraft.util.Mth;
|
| 15 | import net.minecraft.world.level.biome.OverworldBiomeBuilder;
|
| 16 | import net.minecraft.world.level.dimension.DimensionType;
|
| 17 | import net.minecraft.world.level.levelgen.densityfunction.DensityFunction;
|
| 18 | import net.minecraft.world.level.levelgen.densityfunction.DensityFunctions;
|
| 19 | import net.minecraft.world.level.levelgen.densityfunction.DistanceMetric;
|
| 20 | import net.minecraft.world.level.levelgen.densityfunction.op.SplineFunction;
|
| 21 | import net.minecraft.world.level.levelgen.material.rule.OreVeinRule;
|
| 22 | import net.minecraft.world.level.levelgen.synth.BlendedNoise;
|
| 23 | import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
| 24 |
|
| 25 | /**
|
| 26 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 27 | */
|
| 28 | public class NoiseRouterData {
|
| 29 | public static final float GLOBAL_OFFSET = -0.50375F;
|
| 30 | /**
|
| 31 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 32 | */
|
| 33 | public static final float ORE_THICKNESS = 0.08F;
|
| 34 | /**
|
| 35 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 36 | */
|
| 37 | public static final float VEININESS_FREQUENCY = 1.5F;
|
| 38 | /**
|
| 39 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 40 | */
|
| 41 | public static final float NOODLE_SPACING_AND_STRAIGHTNESS = 1.5F;
|
| 42 | /**
|
| 43 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 44 | */
|
| 45 | public static final float SURFACE_DENSITY_THRESHOLD = 1.5625F;
|
| 46 | /**
|
| 47 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 48 | */
|
| 49 | public static final float CHEESE_NOISE_TARGET = -0.703125F;
|
| 50 | public static final float NOISE_ZERO = 0.390625F;
|
| 51 | public static final int ISLAND_CHUNK_DISTANCE = 64;
|
| 52 | public static final long ISLAND_CHUNK_DISTANCE_SQR = 4096L;
|
| 53 | /**
|
| 54 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 55 | */
|
| 56 | public static final int DENSITY_Y_ANCHOR_BOTTOM = -64;
|
| 57 | /**
|
| 58 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 59 | */
|
| 60 | public static final int DENSITY_Y_ANCHOR_TOP = 320;
|
| 61 | /**
|
| 62 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 63 | */
|
| 64 | public static final float DENSITY_Y_BOTTOM = 1.5F;
|
| 65 | /**
|
| 66 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 67 | */
|
| 68 | public static final float DENSITY_Y_TOP = -1.5F;
|
| 69 | /**
|
| 70 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 71 | */
|
| 72 | public static final int OVERWORLD_BOTTOM_SLIDE_HEIGHT = 24;
|
| 73 | /**
|
| 74 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 75 | */
|
| 76 | public static final float BASE_DENSITY_MULTIPLIER = 4.0F;
|
| 77 | /**
|
| 78 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 79 | */
|
| 80 | public static final DensityFunction BLENDING_FACTOR = DensityFunctions.constant(10.0F);
|
| 81 | /**
|
| 82 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 83 | */
|
| 84 | public static final DensityFunction BLENDING_JAGGEDNESS = DensityFunctions.zero();
|
| 85 | /**
|
| 86 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 87 | */
|
| 88 | public static final ResourceKey<DensityFunction> ZERO = createKey("zero");
|
| 89 | /**
|
| 90 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 91 | */
|
| 92 | public static final ResourceKey<DensityFunction> Y = createKey("y");
|
| 93 | /**
|
| 94 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 95 | */
|
| 96 | public static final ResourceKey<DensityFunction> SHIFT_X = createKey("shift_x");
|
| 97 | /**
|
| 98 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 99 | */
|
| 100 | public static final ResourceKey<DensityFunction> SHIFT_Z = createKey("shift_z");
|
| 101 | /**
|
| 102 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 103 | */
|
| 104 | public static final ResourceKey<DensityFunction> BASE_3D_NOISE_OVERWORLD = createKey("overworld/base_3d_noise");
|
| 105 | /**
|
| 106 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 107 | */
|
| 108 | public static final ResourceKey<DensityFunction> BASE_3D_NOISE_NETHER = createKey("nether/base_3d_noise");
|
| 109 | /**
|
| 110 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 111 | */
|
| 112 | public static final ResourceKey<DensityFunction> BASE_3D_NOISE_END = createKey("end/base_3d_noise");
|
| 113 | public static final ResourceKey<DensityFunction> RIDGES = createKey("overworld/ridges");
|
| 114 | public static final ResourceKey<DensityFunction> RIDGES_FOLDED = createKey("overworld/ridges_folded");
|
| 115 | public static final OverworldFunctionSet<ResourceKey<DensityFunction>> OVERWORLD_FUNCTIONS = new OverworldFunctionSet<>(
|
| 116 | createKey("overworld/temperature"),
|
| 117 | createKey("overworld/vegetation"),
|
| 118 | createKey("overworld/continents"),
|
| 119 | createKey("overworld/erosion"),
|
| 120 | createKey("overworld/offset"),
|
| 121 | createKey("overworld/factor"),
|
| 122 | createKey("overworld/jaggedness"),
|
| 123 | createKey("overworld/depth"),
|
| 124 | createKey("overworld/sloped_cheese"),
|
| 125 | createKey("overworld/preliminary_surface_level"),
|
| 126 | createKey("overworld/chunk_surface_level"),
|
| 127 | createKey("overworld/final_density")
|
| 128 | );
|
| 129 | public static final OverworldFunctionSet<ResourceKey<DensityFunction>> AMPLIFIED_OVERWORLD_FUNCTIONS = new OverworldFunctionSet<>(
|
| 130 | OVERWORLD_FUNCTIONS.temperature(),
|
| 131 | OVERWORLD_FUNCTIONS.vegetation(),
|
| 132 | OVERWORLD_FUNCTIONS.continents(),
|
| 133 | OVERWORLD_FUNCTIONS.erosion(),
|
| 134 | createKey("overworld_amplified/offset"),
|
| 135 | createKey("overworld_amplified/factor"),
|
| 136 | createKey("overworld_amplified/jaggedness"),
|
| 137 | createKey("overworld_amplified/depth"),
|
| 138 | createKey("overworld_amplified/sloped_cheese"),
|
| 139 | createKey("overworld_amplified/preliminary_surface_level"),
|
| 140 | createKey("overworld_amplified/chunk_surface_level"),
|
| 141 | createKey("overworld_amplified/final_density")
|
| 142 | );
|
| 143 | public static final OverworldFunctionSet<ResourceKey<DensityFunction>> LARGE_OVERWORLD_FUNCTIONS = new OverworldFunctionSet<>(
|
| 144 | createKey("overworld_large_biomes/temperature"),
|
| 145 | createKey("overworld_large_biomes/vegetation"),
|
| 146 | createKey("overworld_large_biomes/continents"),
|
| 147 | createKey("overworld_large_biomes/erosion"),
|
| 148 | createKey("overworld_large_biomes/offset"),
|
| 149 | createKey("overworld_large_biomes/factor"),
|
| 150 | createKey("overworld_large_biomes/jaggedness"),
|
| 151 | createKey("overworld_large_biomes/depth"),
|
| 152 | createKey("overworld_large_biomes/sloped_cheese"),
|
| 153 | createKey("overworld_large_biomes/preliminary_surface_level"),
|
| 154 | createKey("overworld_large_biomes/chunk_surface_level"),
|
| 155 | createKey("overworld_large_biomes/final_density")
|
| 156 | );
|
| 157 | /**
|
| 158 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 159 | */
|
| 160 | public static final ResourceKey<DensityFunction> END_ISLANDS = createKey("end/islands");
|
| 161 | /**
|
| 162 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 163 | */
|
| 164 | public static final ResourceKey<DensityFunction> SLOPED_CHEESE_END = createKey("end/sloped_cheese");
|
| 165 | /**
|
| 166 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 167 | */
|
| 168 | public static final ResourceKey<DensityFunction> SPAGHETTI_ROUGHNESS_FUNCTION = createKey("overworld/caves/spaghetti_roughness_function");
|
| 169 | /**
|
| 170 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 171 | */
|
| 172 | public static final ResourceKey<DensityFunction> ENTRANCES = createKey("overworld/caves/entrances");
|
| 173 | /**
|
| 174 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 175 | */
|
| 176 | public static final ResourceKey<DensityFunction> NOODLE = createKey("overworld/caves/noodle");
|
| 177 | /**
|
| 178 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 179 | */
|
| 180 | public static final ResourceKey<DensityFunction> PILLARS = createKey("overworld/caves/pillars");
|
| 181 | /**
|
| 182 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 183 | */
|
| 184 | public static final ResourceKey<DensityFunction> SPAGHETTI_2D_THICKNESS_MODULATOR = createKey("overworld/caves/spaghetti_2d_thickness_modulator");
|
| 185 | /**
|
| 186 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 187 | */
|
| 188 | public static final ResourceKey<DensityFunction> SPAGHETTI_2D = createKey("overworld/caves/spaghetti_2d");
|
| 189 | /**
|
| 190 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 191 | */
|
| 192 | public static final ResourceKey<DensityFunction> ORE_VEIN_MASK = createKey("overworld/ore_vein/mask");
|
| 193 | /**
|
| 194 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 195 | */
|
| 196 | public static final ResourceKey<DensityFunction> ORE_VEIN_TOGGLE = createKey("overworld/ore_vein/toggle");
|
| 197 | public static final ResourceKey<DensityFunction> ORE_VEIN_RICHNESS = createKey("overworld/ore_vein/richness");
|
| 198 | public static final ResourceKey<DensityFunction> ORE_VEIN_COPPER_DENSITY = createKey("overworld/ore_vein/copper_density");
|
| 199 | public static final ResourceKey<DensityFunction> ORE_VEIN_IRON_DENSITY = createKey("overworld/ore_vein/iron_density");
|
| 200 | public static final ResourceKey<DensityFunction> ORE_VEIN_GAP = createKey("overworld/ore_vein/gap");
|
| 201 |
|
| 202 | private static ResourceKey<DensityFunction> createKey(final String name) {
|
| 203 | return ResourceKey.create(Registries.DENSITY_FUNCTION, Identifier.withDefaultNamespace(name));
|
| 204 | }
|
| 205 |
|
| 206 | public static void bootstrap(final BootstrapContext<DensityFunction> context) {
|
| 207 | HolderGetter<NormalNoise> noises = context.lookup(Registries.NOISE);
|
| 208 | HolderGetter<DensityFunction> functions = context.lookup(Registries.DENSITY_FUNCTION);
|
| 209 | context.register(ZERO, DensityFunctions.zero());
|
| 210 | int belowBottom = DimensionType.MIN_Y * 2;
|
| 211 | int aboveTop = DimensionType.MAX_Y * 2;
|
| 212 | context.register(Y, DensityFunctions.yClampedGradient(belowBottom, aboveTop, belowBottom, aboveTop));
|
| 213 | registerOreVeins(context);
|
| 214 | DensityFunction shiftX = registerAndWrap(context, SHIFT_X, DensityFunctions.cache(DensityFunctions.shiftA(noises.getOrThrow(Noises.SHIFT))));
|
| 215 | DensityFunction shiftZ = registerAndWrap(context, SHIFT_Z, DensityFunctions.cache(DensityFunctions.shiftB(noises.getOrThrow(Noises.SHIFT))));
|
| 216 | context.register(BASE_3D_NOISE_OVERWORLD, new BlendedNoise(0.25, 0.125, 80.0, 160.0, 8.0));
|
| 217 | context.register(BASE_3D_NOISE_NETHER, new BlendedNoise(0.25, 0.375, 80.0, 60.0, 8.0));
|
| 218 | context.register(BASE_3D_NOISE_END, new BlendedNoise(0.25, 0.25, 80.0, 160.0, 4.0));
|
| 219 | registerAndWrap(context, OVERWORLD_FUNCTIONS.temperature(), DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.TEMPERATURE)));
|
| 220 | registerAndWrap(
|
| 221 | context, LARGE_OVERWORLD_FUNCTIONS.temperature(), DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.TEMPERATURE_LARGE))
|
| 222 | );
|
| 223 | registerAndWrap(context, OVERWORLD_FUNCTIONS.vegetation(), DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.VEGETATION)));
|
| 224 | registerAndWrap(
|
| 225 | context, LARGE_OVERWORLD_FUNCTIONS.vegetation(), DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.VEGETATION_LARGE))
|
| 226 | );
|
| 227 | DensityFunction continents = registerAndWrap(
|
| 228 | context,
|
| 229 | OVERWORLD_FUNCTIONS.continents(),
|
| 230 | DensityFunctions.cache(DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.CONTINENTALNESS)))
|
| 231 | );
|
| 232 | DensityFunction erosion = registerAndWrap(
|
| 233 | context, OVERWORLD_FUNCTIONS.erosion(), DensityFunctions.cache(DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.EROSION)))
|
| 234 | );
|
| 235 | DensityFunction ridge = registerAndWrap(
|
| 236 | context, RIDGES, DensityFunctions.cache(DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.RIDGE)))
|
| 237 | );
|
| 238 | context.register(RIDGES_FOLDED, peaksAndValleys(ridge));
|
| 239 | DensityFunction jaggedNoise = DensityFunctions.noise(noises.getOrThrow(Noises.JAGGED), 1500.0, 0.0);
|
| 240 | registerTerrainNoises(context, functions, noises, jaggedNoise, continents, erosion, OVERWORLD_FUNCTIONS, false);
|
| 241 | DensityFunction continentsLarge = registerAndWrap(
|
| 242 | context,
|
| 243 | LARGE_OVERWORLD_FUNCTIONS.continents(),
|
| 244 | DensityFunctions.cache(DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.CONTINENTALNESS_LARGE)))
|
| 245 | );
|
| 246 | DensityFunction erosionLarge = registerAndWrap(
|
| 247 | context,
|
| 248 | LARGE_OVERWORLD_FUNCTIONS.erosion(),
|
| 249 | DensityFunctions.cache(DensityFunctions.shiftedNoise2d(shiftX, shiftZ, 0.25, noises.getOrThrow(Noises.EROSION_LARGE)))
|
| 250 | );
|
| 251 | registerTerrainNoises(context, functions, noises, jaggedNoise, continentsLarge, erosionLarge, LARGE_OVERWORLD_FUNCTIONS, false);
|
| 252 | registerTerrainNoises(context, functions, noises, jaggedNoise, continents, erosion, AMPLIFIED_OVERWORLD_FUNCTIONS, true);
|
| 253 | DensityFunction endIslands = registerAndWrap(context, END_ISLANDS, createEndIslands());
|
| 254 | context.register(SLOPED_CHEESE_END, DensityFunctions.add(endIslands, getFunction(functions, BASE_3D_NOISE_END)));
|
| 255 | context.register(SPAGHETTI_ROUGHNESS_FUNCTION, spaghettiRoughnessFunction(noises));
|
| 256 | context.register(
|
| 257 | SPAGHETTI_2D_THICKNESS_MODULATOR,
|
| 258 | DensityFunctions.cache(DensityFunctions.mappedNoise(noises.getOrThrow(Noises.SPAGHETTI_2D_THICKNESS), 2.0, 1.0, -0.6F, -1.3F))
|
| 259 | );
|
| 260 | context.register(SPAGHETTI_2D, spaghetti2D(functions, noises));
|
| 261 | context.register(ENTRANCES, entrances(functions, noises));
|
| 262 | context.register(NOODLE, noodle(functions, noises));
|
| 263 | context.register(PILLARS, pillars(noises));
|
| 264 | }
|
| 265 |
|
| 266 | /**
|
| 267 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 268 | */
|
| 269 | public static DensityFunction createEndIslands() {
|
| 270 | DensityFunction distanceToMainIsland = DensityFunctions.distanceToPoint(Vec3i.ZERO, DistanceMetric.EUCLIDEAN);
|
| 271 | DensityFunction mainIsland = DensityFunctions.sliceY(
|
| 272 | DensityFunctions.constant(100.0F).sub(distanceToMainIsland).clamp(-100.0F, 80.0F).sub(8.0F).mul(0.0078125F), 0
|
| 273 | );
|
| 274 | DensityFunction outerIslands = DensityFunctions.endOuterIslands();
|
| 275 | return DensityFunctions.cache(DensityFunctions.max(mainIsland, outerIslands));
|
| 276 | }
|
| 277 |
|
| 278 | /**
|
| 279 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 280 | */
|
| 281 | public static void registerTerrainNoises(
|
| 282 | final BootstrapContext<DensityFunction> context,
|
| 283 | final HolderGetter<DensityFunction> functions,
|
| 284 | final HolderGetter<NormalNoise> noises,
|
| 285 | final DensityFunction jaggedNoise,
|
| 286 | final DensityFunction continentsFunction,
|
| 287 | final DensityFunction erosionFunction,
|
| 288 | final OverworldFunctionSet<ResourceKey<DensityFunction>> names,
|
| 289 | final boolean amplified
|
| 290 | ) {
|
| 291 | SplineFunction.Coordinate continents = new SplineFunction.Coordinate(continentsFunction);
|
| 292 | SplineFunction.Coordinate erosion = new SplineFunction.Coordinate(erosionFunction);
|
| 293 | SplineFunction.Coordinate weirdness = new SplineFunction.Coordinate(getFunction(functions, RIDGES));
|
| 294 | SplineFunction.Coordinate ridges = new SplineFunction.Coordinate(getFunction(functions, RIDGES_FOLDED));
|
| 295 | DensityFunction offset = registerAndWrap(
|
| 296 | context,
|
| 297 | names.offset(),
|
| 298 | splineWithBlending(
|
| 299 | DensityFunctions.add(DensityFunctions.constant(-0.50375F), DensityFunctions.spline(TerrainProvider.overworldOffset(continents, erosion, ridges, amplified))),
|
| 300 | DensityFunctions.blendOffset()
|
| 301 | )
|
| 302 | );
|
| 303 | DensityFunction factor = registerAndWrap(
|
| 304 | context,
|
| 305 | names.factor(),
|
| 306 | splineWithBlending(DensityFunctions.spline(TerrainProvider.overworldFactor(continents, erosion, weirdness, ridges, amplified)), BLENDING_FACTOR)
|
| 307 | );
|
| 308 | DensityFunction depth = registerAndWrap(context, names.depth(), offsetToDepth(offset));
|
| 309 | DensityFunction unscaledJaggedness = registerAndWrap(
|
| 310 | context,
|
| 311 | names.jaggedness(),
|
| 312 | splineWithBlending(DensityFunctions.spline(TerrainProvider.overworldJaggedness(continents, erosion, weirdness, ridges, amplified)), BLENDING_JAGGEDNESS)
|
| 313 | );
|
| 314 | DensityFunction jaggedness = DensityFunctions.cache(DensityFunctions.mul(unscaledJaggedness, jaggedNoise.halfNegative()));
|
| 315 | DensityFunction initialDensity = noiseGradientDensity(factor, DensityFunctions.add(depth, jaggedness));
|
| 316 | DensityFunction slopedCheese = registerAndWrap(
|
| 317 | context, names.slopedCheese(), DensityFunctions.cache(DensityFunctions.add(initialDensity, getFunction(functions, BASE_3D_NOISE_OVERWORLD)))
|
| 318 | );
|
| 319 | DensityFunction surfaceLevel = registerAndWrap(context, names.preliminarySurfaceLevel(), preliminarySurfaceLevel(offset, factor, amplified));
|
| 320 | context.register(names.chunkSurfaceLevel(), DensityFunctions.interpolated(surfaceLevel, 16, 1));
|
| 321 | DensityFunction surfaceWithEntrances = DensityFunctions.min(slopedCheese, getFunction(functions, ENTRANCES).mul(5.0F));
|
| 322 | DensityFunction caves = DensityFunctions.rangeChoice(slopedCheese, -1000000.0F, 1.5625F, surfaceWithEntrances, underground(functions, noises, slopedCheese));
|
| 323 | context.register(
|
| 324 | names.finalDensity(),
|
| 325 | DensityFunctions.add(
|
| 326 | DensityFunctions.min(postProcess(slideOverworld(amplified, caves), 4, 8), getFunction(functions, NOODLE)), DensityFunctions.beardifier()
|
| 327 | )
|
| 328 | );
|
| 329 | }
|
| 330 |
|
| 331 | /**
|
| 332 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 333 | */
|
| 334 | public static DensityFunction offsetToDepth(final DensityFunction offset) {
|
| 335 | return DensityFunctions.add(DensityFunctions.yClampedGradient(-64, 320, 1.5F, -1.5F), offset);
|
| 336 | }
|
| 337 |
|
| 338 | /**
|
| 339 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 340 | */
|
| 341 | public static DensityFunction registerAndWrap(
|
| 342 | final BootstrapContext<DensityFunction> context, final ResourceKey<DensityFunction> name, final DensityFunction value
|
| 343 | ) {
|
| 344 | return new DensityFunctions.HolderHolder(context.register(name, value));
|
| 345 | }
|
| 346 |
|
| 347 | public static DensityFunction getFunction(final HolderGetter<DensityFunction> functions, final ResourceKey<DensityFunction> name) {
|
| 348 | return new DensityFunctions.HolderHolder(functions.getOrThrow(name));
|
| 349 | }
|
| 350 |
|
| 351 | public static DensityFunction peaksAndValleys(final DensityFunction weirdness) {
|
| 352 | return DensityFunctions.mul(
|
| 353 | DensityFunctions.add(DensityFunctions.add(weirdness.abs(), DensityFunctions.constant(-0.6666667F)).abs(), DensityFunctions.constant(-0.33333334F)),
|
| 354 | DensityFunctions.constant(-3.0F)
|
| 355 | );
|
| 356 | }
|
| 357 |
|
| 358 | public static float peaksAndValleys(final float weirdness) {
|
| 359 | return TerrainProvider.peaksAndValleys(weirdness);
|
| 360 | }
|
| 361 |
|
| 362 | /**
|
| 363 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 364 | */
|
| 365 | public static DensityFunction spaghettiRoughnessFunction(final HolderGetter<NormalNoise> noises) {
|
| 366 | DensityFunction spaghettiRoughnessNoise = DensityFunctions.noise(noises.getOrThrow(Noises.SPAGHETTI_ROUGHNESS));
|
| 367 | DensityFunction spaghettiRoughnessModulator = DensityFunctions.mappedNoise(noises.getOrThrow(Noises.SPAGHETTI_ROUGHNESS_MODULATOR), 0.0F, -0.1F);
|
| 368 | return DensityFunctions.cache(
|
| 369 | DensityFunctions.mul(spaghettiRoughnessModulator, DensityFunctions.add(spaghettiRoughnessNoise.abs(), DensityFunctions.constant(-0.4F)))
|
| 370 | );
|
| 371 | }
|
| 372 |
|
| 373 | /**
|
| 374 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 375 | */
|
| 376 | public static DensityFunction entrances(final HolderGetter<DensityFunction> functions, final HolderGetter<NormalNoise> noises) {
|
| 377 | DensityFunction spaghetti3DRarityModulator = DensityFunctions.cache(DensityFunctions.noise(noises.getOrThrow(Noises.SPAGHETTI_3D_RARITY), 2.0, 1.0));
|
| 378 | DensityFunction spaghetti3DThicknessModulator = DensityFunctions.mappedNoise(noises.getOrThrow(Noises.SPAGHETTI_3D_THICKNESS), -0.065F, -0.088F);
|
| 379 | DensityFunction spaghetti3DCave1 = NoiseRouterData.QuantizedSpaghettiRarity.wrapRarity3d(spaghetti3DRarityModulator, noises.getOrThrow(Noises.SPAGHETTI_3D_1));
|
| 380 | DensityFunction spaghetti3DCave2 = NoiseRouterData.QuantizedSpaghettiRarity.wrapRarity3d(spaghetti3DRarityModulator, noises.getOrThrow(Noises.SPAGHETTI_3D_2));
|
| 381 | DensityFunction spaghetti3DFunction = DensityFunctions.add(DensityFunctions.max(spaghetti3DCave1, spaghetti3DCave2), spaghetti3DThicknessModulator)
|
| 382 | .clamp(-1.0F, 1.0F);
|
| 383 | DensityFunction spaghettiRoughnessFunction = getFunction(functions, SPAGHETTI_ROUGHNESS_FUNCTION);
|
| 384 | DensityFunction bigEntranceNoiseSource = DensityFunctions.noise(noises.getOrThrow(Noises.CAVE_ENTRANCE), 0.75, 0.5);
|
| 385 | DensityFunction bigEntrancesFunction = DensityFunctions.add(bigEntranceNoiseSource.add(0.37F), DensityFunctions.yClampedGradient(-10, 30, 0.3F, 0.0F));
|
| 386 | return DensityFunctions.cache(DensityFunctions.min(bigEntrancesFunction, DensityFunctions.add(spaghettiRoughnessFunction, spaghetti3DFunction)));
|
| 387 | }
|
| 388 |
|
| 389 | /**
|
| 390 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 391 | */
|
| 392 | public static DensityFunction noodle(final HolderGetter<DensityFunction> functions, final HolderGetter<NormalNoise> noises) {
|
| 393 | DensityFunction y = getFunction(functions, Y);
|
| 394 | int minBlockY = -64;
|
| 395 | int noodleMinY = -60;
|
| 396 | int noodleMaxY = 320;
|
| 397 | int cellSizeXz = 4;
|
| 398 | int cellSizeY = 8;
|
| 399 | DensityFunction noodleToggle = yLimitedInterpolatable(y, DensityFunctions.noise(noises.getOrThrow(Noises.NOODLE), 1.0, 1.0), -60, 320, -1, 4, 8);
|
| 400 | DensityFunction noodleThickness = yLimitedInterpolatable(
|
| 401 | y, DensityFunctions.mappedNoise(noises.getOrThrow(Noises.NOODLE_THICKNESS), 1.0, 1.0, -0.05F, -0.1F), -60, 320, 0, 4, 8
|
| 402 | );
|
| 403 | double noodleRidgeFrequency = 2.6666666666666665;
|
| 404 | DensityFunction noodleRidgeA = yLimitedInterpolatable(
|
| 405 | y, DensityFunctions.noise(noises.getOrThrow(Noises.NOODLE_RIDGE_A), 2.6666666666666665, 2.6666666666666665), -60, 320, 0, 4, 8
|
| 406 | );
|
| 407 | DensityFunction noodleRidgeB = yLimitedInterpolatable(
|
| 408 | y, DensityFunctions.noise(noises.getOrThrow(Noises.NOODLE_RIDGE_B), 2.6666666666666665, 2.6666666666666665), -60, 320, 0, 4, 8
|
| 409 | );
|
| 410 | DensityFunction noodleRidged = DensityFunctions.max(noodleRidgeA.abs(), noodleRidgeB.abs()).mul(1.5F);
|
| 411 | return DensityFunctions.rangeChoice(noodleToggle, -1000000.0F, 0.0F, DensityFunctions.constant(64.0F), DensityFunctions.add(noodleThickness, noodleRidged));
|
| 412 | }
|
| 413 |
|
| 414 | /**
|
| 415 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 416 | */
|
| 417 | public static DensityFunction pillars(final HolderGetter<NormalNoise> noises) {
|
| 418 | double xzFrequency = 25.0;
|
| 419 | double yFrequency = 0.3;
|
| 420 | DensityFunction pillarNoiseSource = DensityFunctions.noise(noises.getOrThrow(Noises.PILLAR), 25.0, 0.3);
|
| 421 | DensityFunction pillarRarenessModulator = DensityFunctions.mappedNoise(noises.getOrThrow(Noises.PILLAR_RARENESS), 0.0F, -2.0F);
|
| 422 | DensityFunction pillarThicknessModulator = DensityFunctions.mappedNoise(noises.getOrThrow(Noises.PILLAR_THICKNESS), 0.0F, 1.1F);
|
| 423 | DensityFunction pillarsWithRareness = DensityFunctions.add(pillarNoiseSource.mul(2.0F), pillarRarenessModulator);
|
| 424 | return DensityFunctions.cache(DensityFunctions.mul(pillarsWithRareness, pillarThicknessModulator.cube()));
|
| 425 | }
|
| 426 |
|
| 427 | /**
|
| 428 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 429 | */
|
| 430 | public static DensityFunction spaghetti2D(final HolderGetter<DensityFunction> functions, final HolderGetter<NormalNoise> noises) {
|
| 431 | DensityFunction spaghetti2DRarityModulator = DensityFunctions.noise(noises.getOrThrow(Noises.SPAGHETTI_2D_MODULATOR), 2.0, 1.0);
|
| 432 | DensityFunction spaghetti2DCave = NoiseRouterData.QuantizedSpaghettiRarity.wrapRarity2d(spaghetti2DRarityModulator, noises.getOrThrow(Noises.SPAGHETTI_2D));
|
| 433 | DensityFunction spaghetti2DElevationModulator = DensityFunctions.mappedNoise(
|
| 434 | noises.getOrThrow(Noises.SPAGHETTI_2D_ELEVATION), 0.0, Math.floorDiv(-64, 8), 8.0F
|
| 435 | );
|
| 436 | DensityFunction spaghetti2DThicknessModulator = getFunction(functions, SPAGHETTI_2D_THICKNESS_MODULATOR);
|
| 437 | DensityFunction slopedSpaghetti = DensityFunctions.add(
|
| 438 | DensityFunctions.cache(spaghetti2DElevationModulator), DensityFunctions.yClampedGradient(-64, 320, 8.0F, -40.0F)
|
| 439 | )
|
| 440 | .abs();
|
| 441 | DensityFunction layerRidged = DensityFunctions.add(slopedSpaghetti, spaghetti2DThicknessModulator).cube();
|
| 442 | float ridgeOffset = 0.083F;
|
| 443 | DensityFunction caveNoise = DensityFunctions.add(spaghetti2DCave, spaghetti2DThicknessModulator.mul(0.083F));
|
| 444 | return DensityFunctions.max(caveNoise, layerRidged).clamp(-1.0F, 1.0F);
|
| 445 | }
|
| 446 |
|
| 447 | /**
|
| 448 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 449 | */
|
| 450 | public static DensityFunction underground(
|
| 451 | final HolderGetter<DensityFunction> functions, final HolderGetter<NormalNoise> noises, final DensityFunction slopedCheese
|
| 452 | ) {
|
| 453 | DensityFunction spaghetti2DFunction = getFunction(functions, SPAGHETTI_2D);
|
| 454 | DensityFunction spaghettiRoughnessFunction = getFunction(functions, SPAGHETTI_ROUGHNESS_FUNCTION);
|
| 455 | DensityFunction layerNoiseSource = DensityFunctions.noise(noises.getOrThrow(Noises.CAVE_LAYER), 8.0);
|
| 456 | DensityFunction layerizedCavernsFunction = layerNoiseSource.square().mul(4.0F);
|
| 457 | DensityFunction cheese = DensityFunctions.noise(noises.getOrThrow(Noises.CAVE_CHEESE), 0.6666666666666666);
|
| 458 | DensityFunction solidifedCheeseWithTopSlide = DensityFunctions.add(cheese.add(0.27F).clamp(-1.0F, 1.0F), slopedCheese.mul(-0.64F).add(1.5F).clamp(0.0F, 0.5F));
|
| 459 | DensityFunction baseCaveDensity = DensityFunctions.add(layerizedCavernsFunction, solidifedCheeseWithTopSlide);
|
| 460 | DensityFunction undergroundSubtractions = DensityFunctions.min(
|
| 461 | DensityFunctions.min(baseCaveDensity, getFunction(functions, ENTRANCES)), DensityFunctions.add(spaghetti2DFunction, spaghettiRoughnessFunction)
|
| 462 | );
|
| 463 | DensityFunction pillarsWithoutCutoff = getFunction(functions, PILLARS);
|
| 464 | DensityFunction pillars = DensityFunctions.rangeChoice(pillarsWithoutCutoff, -1000000.0F, 0.03F, DensityFunctions.constant(-1000000.0F), pillarsWithoutCutoff);
|
| 465 | return DensityFunctions.max(undergroundSubtractions, pillars);
|
| 466 | }
|
| 467 |
|
| 468 | /**
|
| 469 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 470 | */
|
| 471 | public static DensityFunction postProcess(final DensityFunction slide, final int cellSizeXz, final int cellSizeY) {
|
| 472 | DensityFunction blended = DensityFunctions.blendDensity(slide);
|
| 473 | return DensityFunctions.interpolated(DensityFunctions.mul(blended, DensityFunctions.constant(0.64F)), cellSizeXz, cellSizeY).squeeze();
|
| 474 | }
|
| 475 |
|
| 476 | /**
|
| 477 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 478 | */
|
| 479 | public static NoiseRouter overworld(final HolderGetter<DensityFunction> functions, final OverworldFunctionSet<ResourceKey<DensityFunction>> functionNames) {
|
| 480 | OverworldFunctionSet<DensityFunction> functionSet = functionNames.map(key -> getFunction(functions, key));
|
| 481 | return new NoiseRouter(
|
| 482 | functionSet.temperature(),
|
| 483 | functionSet.vegetation(),
|
| 484 | functionSet.continents(),
|
| 485 | functionSet.erosion(),
|
| 486 | functionSet.depth(),
|
| 487 | getFunction(functions, RIDGES),
|
| 488 | functionSet.chunkSurfaceLevel(),
|
| 489 | functionSet.finalDensity()
|
| 490 | );
|
| 491 | }
|
| 492 |
|
| 493 | /**
|
| 494 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 495 | */
|
| 496 | public static Aquifer.Config overworldAquifers(
|
| 497 | final HolderGetter<DensityFunction> functions, final HolderGetter<NormalNoise> noises, final OverworldFunctionSet<ResourceKey<DensityFunction>> names
|
| 498 | ) {
|
| 499 | DensityFunction barrierNoise = DensityFunctions.noise(noises.getOrThrow(Noises.AQUIFER_BARRIER), 0.5);
|
| 500 | DensityFunction fluidLevelFloodednessNoise = DensityFunctions.noise(noises.getOrThrow(Noises.AQUIFER_FLUID_LEVEL_FLOODEDNESS), 0.67);
|
| 501 | DensityFunction fluidLevelSpreadNoise = DensityFunctions.noise(noises.getOrThrow(Noises.AQUIFER_FLUID_LEVEL_SPREAD), 0.7142857142857143);
|
| 502 | DensityFunction lavaNoise = DensityFunctions.noise(noises.getOrThrow(Noises.AQUIFER_LAVA));
|
| 503 | DensityFunction exclusion = OverworldBiomeBuilder.deepDarkRegion(getFunction(functions, names.erosion()), getFunction(functions, names.depth()));
|
| 504 | return new Aquifer.Config(
|
| 505 | barrierNoise, fluidLevelFloodednessNoise, fluidLevelSpreadNoise, lavaNoise, exclusion, getFunction(functions, names.preliminarySurfaceLevel())
|
| 506 | );
|
| 507 | }
|
| 508 |
|
| 509 | /**
|
| 510 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 511 | */
|
| 512 | public static void registerOreVeins(final BootstrapContext<DensityFunction> context) {
|
| 513 | HolderGetter<DensityFunction> functions = context.lookup(Registries.DENSITY_FUNCTION);
|
| 514 | HolderGetter<NormalNoise> noises = context.lookup(Registries.NOISE);
|
| 515 | DensityFunction y = getFunction(functions, Y);
|
| 516 | int veinMinY = Stream.of(OreVeinRule.VeinType.values()).mapToInt(t -> t.minY).min().orElseThrow();
|
| 517 | int veinMaxY = Stream.of(OreVeinRule.VeinType.values()).mapToInt(t -> t.maxY).max().orElseThrow();
|
| 518 | int interpolatedCellHeight = 8;
|
| 519 | int interpolatedVeinMinY = Mth.floorDiv(veinMinY, 8) * 8;
|
| 520 | int interpolatedVeinMaxY = (Mth.floorDiv(veinMaxY, 8) + 1) * 8;
|
| 521 | DensityFunction veinToggle = registerAndWrap(
|
| 522 | context,
|
| 523 | ORE_VEIN_TOGGLE,
|
| 524 | DensityFunctions.cache(
|
| 525 | yLimitedInterpolatable(y, DensityFunctions.noise(noises.getOrThrow(Noises.ORE_VEININESS), 1.5, 1.5), interpolatedVeinMinY, interpolatedVeinMaxY, 0, 4, 8)
|
| 526 | )
|
| 527 | );
|
| 528 | context.register(ORE_VEIN_RICHNESS, DensityFunctions.clampedMap(veinToggle.abs(), 0.4F, 0.6F, 0.1F, 0.3F));
|
| 529 | DensityFunction veinMask = registerAndWrap(
|
| 530 | context, ORE_VEIN_MASK, DensityFunctions.cache(createBaseOreVeinMask(noises, y, veinToggle, interpolatedVeinMinY, interpolatedVeinMaxY))
|
| 531 | );
|
| 532 | context.register(ORE_VEIN_COPPER_DENSITY, createOreVeinDensity(OreVeinRule.VeinType.COPPER, y, veinToggle, veinMask, true));
|
| 533 | context.register(ORE_VEIN_IRON_DENSITY, createOreVeinDensity(OreVeinRule.VeinType.IRON, y, veinToggle, veinMask, false));
|
| 534 | context.register(ORE_VEIN_GAP, DensityFunctions.constant(-0.3F).sub(DensityFunctions.noise(noises.getOrThrow(Noises.ORE_GAP))));
|
| 535 | }
|
| 536 |
|
| 537 | /**
|
| 538 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 539 | */
|
| 540 | public static DensityFunction createBaseOreVeinMask(
|
| 541 | final HolderGetter<NormalNoise> noises, final DensityFunction y, final DensityFunction toggle, final int minY, final int maxY
|
| 542 | ) {
|
| 543 | float oreRidgeFrequency = 4.0F;
|
| 544 | int noVein = 1;
|
| 545 | int cellSizeXz = 4;
|
| 546 | int cellSizeY = 8;
|
| 547 | DensityFunction veinA = yLimitedInterpolatable(y, DensityFunctions.noise(noises.getOrThrow(Noises.ORE_VEIN_A), 4.0, 4.0), minY, maxY, 1, 4, 8).abs();
|
| 548 | DensityFunction veinB = yLimitedInterpolatable(y, DensityFunctions.noise(noises.getOrThrow(Noises.ORE_VEIN_B), 4.0, 4.0), minY, maxY, 1, 4, 8).abs();
|
| 549 | return DensityFunctions.rangeChoice(
|
| 550 | toggle, -0.4F, 0.4F, DensityFunctions.constant(-1.0F), DensityFunctions.constant(0.08F).sub(DensityFunctions.max(veinA, veinB))
|
| 551 | );
|
| 552 | }
|
| 553 |
|
| 554 | /**
|
| 555 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 556 | */
|
| 557 | public static DensityFunction createOreVeinDensity(
|
| 558 | final OreVeinRule.VeinType type, final DensityFunction y, final DensityFunction toggle, final DensityFunction baseVeinMask, final boolean whenTogglePositive
|
| 559 | ) {
|
| 560 | DensityFunction noVein = DensityFunctions.constant(-1.0F);
|
| 561 | DensityFunction distanceFromEdge = DensityFunctions.min(DensityFunctions.constant(type.maxY).sub(y), y.sub(type.minY));
|
| 562 | DensityFunction edgeRoundoff = DensityFunctions.clampedMap(distanceFromEdge, 0.0F, 20.0F, -0.2F, 0.0F);
|
| 563 | DensityFunction veininess = whenTogglePositive ? toggle : toggle.negate();
|
| 564 | return DensityFunctions.rangeChoice(
|
| 565 | y,
|
| 566 | type.minY,
|
| 567 | type.maxY,
|
| 568 | DensityFunctions.rangeChoice(
|
| 569 | baseVeinMask,
|
| 570 | 0.0F,
|
| 571 | 1000000.0F,
|
| 572 | DensityFunctions.rangeChoice(veininess.sub(0.4F).add(edgeRoundoff), 0.0F, 1000000.0F, DensityFunctions.constant(0.7F), noVein),
|
| 573 | noVein
|
| 574 | ),
|
| 575 | noVein
|
| 576 | );
|
| 577 | }
|
| 578 |
|
| 579 | /**
|
| 580 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 581 | */
|
| 582 | public static DensityFunction slideOverworld(final boolean isAmplified, final DensityFunction caves) {
|
| 583 | return slide(caves, -64, 384, isAmplified ? 16 : 80, isAmplified ? 0 : 64, -0.078125F, 0, 24, isAmplified ? 0.4F : 0.1171875F);
|
| 584 | }
|
| 585 |
|
| 586 | /**
|
| 587 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 588 | */
|
| 589 | public static DensityFunction slideNetherLike(final HolderGetter<DensityFunction> functions, final int minY, final int height) {
|
| 590 | return slide(getFunction(functions, BASE_3D_NOISE_NETHER), minY, height, 24, 0, 0.9375F, -8, 24, 2.5F);
|
| 591 | }
|
| 592 |
|
| 593 | /**
|
| 594 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 595 | */
|
| 596 | public static DensityFunction slideEndLike(final DensityFunction caves, final int minY, final int height) {
|
| 597 | return slide(caves, minY, height, 72, -184, -23.4375F, 4, 32, -0.234375F);
|
| 598 | }
|
| 599 |
|
| 600 | /**
|
| 601 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 602 | */
|
| 603 | public static NoiseRouter nether(final HolderGetter<DensityFunction> functions, final HolderGetter<NormalNoise> noises) {
|
| 604 | DensityFunction temperature = DensityFunctions.shiftedNoise2d(
|
| 605 | DensityFunctions.zero(), DensityFunctions.zero(), 0.25, noises.getOrThrow(Noises.TEMPERATURE_NETHER)
|
| 606 | );
|
| 607 | DensityFunction vegetation = DensityFunctions.shiftedNoise2d(
|
| 608 | DensityFunctions.zero(), DensityFunctions.zero(), 0.25, noises.getOrThrow(Noises.VEGETATION_NETHER)
|
| 609 | );
|
| 610 | DensityFunction slide = slideNetherLike(functions, 0, 128);
|
| 611 | DensityFunction fullNoise = DensityFunctions.add(postProcess(slide, 4, 8), DensityFunctions.beardifier());
|
| 612 | return new NoiseRouter(
|
| 613 | temperature,
|
| 614 | vegetation,
|
| 615 | DensityFunctions.zero(),
|
| 616 | DensityFunctions.zero(),
|
| 617 | DensityFunctions.zero(),
|
| 618 | DensityFunctions.zero(),
|
| 619 | DensityFunctions.zero(),
|
| 620 | fullNoise
|
| 621 | );
|
| 622 | }
|
| 623 |
|
| 624 | /**
|
| 625 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 626 | */
|
| 627 | public static NoiseRouter caves(final HolderGetter<DensityFunction> functions) {
|
| 628 | DensityFunction slide = slideNetherLike(functions, -64, 192);
|
| 629 | return simpleRouter(DensityFunctions.add(postProcess(slide, 4, 8), DensityFunctions.beardifier()));
|
| 630 | }
|
| 631 |
|
| 632 | /**
|
| 633 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 634 | */
|
| 635 | public static NoiseRouter floatingIslands(final HolderGetter<DensityFunction> functions, final HolderGetter<NormalNoise> noises) {
|
| 636 | DensityFunction slide = slideEndLike(getFunction(functions, BASE_3D_NOISE_END), 0, 256);
|
| 637 | return simpleRouter(DensityFunctions.add(postProcess(slide, 8, 4), DensityFunctions.beardifier()));
|
| 638 | }
|
| 639 |
|
| 640 | /**
|
| 641 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 642 | */
|
| 643 | public static DensityFunction slideEnd(final DensityFunction caves) {
|
| 644 | return slideEndLike(caves, 0, 128);
|
| 645 | }
|
| 646 |
|
| 647 | /**
|
| 648 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 649 | */
|
| 650 | public static NoiseRouter end(final HolderGetter<DensityFunction> functions) {
|
| 651 | DensityFunction islands = getFunction(functions, END_ISLANDS);
|
| 652 | DensityFunction fullNoise = DensityFunctions.add(postProcess(slideEnd(getFunction(functions, SLOPED_CHEESE_END)), 8, 4), DensityFunctions.beardifier());
|
| 653 | return new NoiseRouter(
|
| 654 | DensityFunctions.zero(),
|
| 655 | DensityFunctions.zero(),
|
| 656 | DensityFunctions.zero(),
|
| 657 | islands,
|
| 658 | DensityFunctions.zero(),
|
| 659 | DensityFunctions.zero(),
|
| 660 | DensityFunctions.zero(),
|
| 661 | fullNoise
|
| 662 | );
|
| 663 | }
|
| 664 |
|
| 665 | /**
|
| 666 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 667 | */
|
| 668 | public static NoiseRouter simpleRouter(final DensityFunction fullNoise) {
|
| 669 | return new NoiseRouter(
|
| 670 | DensityFunctions.zero(),
|
| 671 | DensityFunctions.zero(),
|
| 672 | DensityFunctions.zero(),
|
| 673 | DensityFunctions.zero(),
|
| 674 | DensityFunctions.zero(),
|
| 675 | DensityFunctions.zero(),
|
| 676 | DensityFunctions.zero(),
|
| 677 | fullNoise
|
| 678 | );
|
| 679 | }
|
| 680 |
|
| 681 | public static NoiseRouter none() {
|
| 682 | return simpleRouter(DensityFunctions.zero());
|
| 683 | }
|
| 684 |
|
| 685 | /**
|
| 686 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 687 | */
|
| 688 | public static DensityFunction splineWithBlending(final DensityFunction spline, final DensityFunction blendingTarget) {
|
| 689 | return DensityFunctions.cache(DensityFunctions.lerp(DensityFunctions.blendAlpha(), blendingTarget, spline));
|
| 690 | }
|
| 691 |
|
| 692 | /**
|
| 693 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 694 | */
|
| 695 | public static DensityFunction noiseGradientDensity(final DensityFunction factor, final DensityFunction depthWithJaggedness) {
|
| 696 | DensityFunction gradientUnscaled = DensityFunctions.mul(depthWithJaggedness, factor);
|
| 697 | return gradientUnscaled.quarterNegative().mul(4.0F);
|
| 698 | }
|
| 699 |
|
| 700 | /**
|
| 701 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 702 | */
|
| 703 | public static DensityFunction preliminarySurfaceLevel(final DensityFunction offset, final DensityFunction factor, final boolean amplified) {
|
| 704 | DensityFunction upperBound = DensityFunctions.remap(
|
| 705 | DensityFunctions.sub(DensityFunctions.div(DensityFunctions.constant(0.2734375F), factor), offset), 1.5F, -1.5F, -64.0F, 320.0F
|
| 706 | );
|
| 707 | upperBound = upperBound.clamp(-40.0F, 320.0F);
|
| 708 | DensityFunction density = DensityFunctions.add(
|
| 709 | slideOverworld(
|
| 710 | amplified, DensityFunctions.add(noiseGradientDensity(factor, offsetToDepth(offset)), DensityFunctions.constant(-0.703125F)).clamp(-64.0F, 64.0F)
|
| 711 | ),
|
| 712 | DensityFunctions.constant(-0.390625F)
|
| 713 | );
|
| 714 | return DensityFunctions.findTopSurface(density, upperBound, -64, 8);
|
| 715 | }
|
| 716 |
|
| 717 | /**
|
| 718 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 719 | */
|
| 720 | public static DensityFunction yLimitedInterpolatable(
|
| 721 | final DensityFunction y,
|
| 722 | final DensityFunction whenInRange,
|
| 723 | final int minYInclusive,
|
| 724 | final int maxYInclusive,
|
| 725 | final int whenOutOfRange,
|
| 726 | final int cellSizeXz,
|
| 727 | final int cellSizeY
|
| 728 | ) {
|
| 729 | return DensityFunctions.interpolated(
|
| 730 | DensityFunctions.rangeChoice(y, minYInclusive, maxYInclusive + 1, whenInRange, DensityFunctions.constant(whenOutOfRange)), cellSizeXz, cellSizeY
|
| 731 | );
|
| 732 | }
|
| 733 |
|
| 734 | /**
|
| 735 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 736 | */
|
| 737 | public static DensityFunction slide(
|
| 738 | final DensityFunction caves,
|
| 739 | final int minY,
|
| 740 | final int height,
|
| 741 | final int topStartY,
|
| 742 | final int topEndY,
|
| 743 | final float topTarget,
|
| 744 | final int bottomStartY,
|
| 745 | final int bottomEndY,
|
| 746 | final float bottomTarget
|
| 747 | ) {
|
| 748 | DensityFunction noiseValue = caves;
|
| 749 | DensityFunction topFactor = DensityFunctions.yClampedGradient(minY + height - topStartY, minY + height - topEndY, 1.0F, 0.0F);
|
| 750 | noiseValue = DensityFunctions.lerp(topFactor, topTarget, noiseValue);
|
| 751 | DensityFunction bottomFactor = DensityFunctions.yClampedGradient(minY + bottomStartY, minY + bottomEndY, 0.0F, 1.0F);
|
| 752 | return DensityFunctions.lerp(bottomFactor, bottomTarget, noiseValue);
|
| 753 | }
|
| 754 |
|
| 755 | protected static final class QuantizedSpaghettiRarity {
|
| 756 | public static DensityFunction wrapRarity2d(final DensityFunction input, final Holder<NormalNoise> noise) {
|
| 757 | return DensityFunctions.intervalSelect(
|
| 758 | input,
|
| 759 | FloatList.of(-0.75F, -0.5F, 0.5F, 0.75F),
|
| 760 | List.of(
|
| 761 | noiseFunctionForRarity(noise, 0.5F),
|
| 762 | noiseFunctionForRarity(noise, 0.75F),
|
| 763 | noiseFunctionForRarity(noise, 1.0F),
|
| 764 | noiseFunctionForRarity(noise, 2.0F),
|
| 765 | noiseFunctionForRarity(noise, 3.0F)
|
| 766 | )
|
| 767 | )
|
| 768 | .abs();
|
| 769 | }
|
| 770 |
|
| 771 | public static DensityFunction wrapRarity3d(final DensityFunction input, final Holder<NormalNoise> noise) {
|
| 772 | return DensityFunctions.intervalSelect(
|
| 773 | input,
|
| 774 | FloatList.of(-0.5F, 0.0F, 0.5F),
|
| 775 | List.of(
|
| 776 | noiseFunctionForRarity(noise, 0.75F), noiseFunctionForRarity(noise, 1.0F), noiseFunctionForRarity(noise, 1.5F), noiseFunctionForRarity(noise, 2.0F)
|
| 777 | )
|
| 778 | )
|
| 779 | .abs();
|
| 780 | }
|
| 781 |
|
| 782 | private static DensityFunction noiseFunctionForRarity(final Holder<NormalNoise> noise, final float rarity) {
|
| 783 | return DensityFunctions.noise(noise, 1.0 / rarity, 1.0 / rarity).mul(rarity);
|
| 784 | }
|
| 785 | }
|
| 786 | }
|
| 787 |
|