Skip to content

Commit 4e78fa7

Browse files
committed
Update Cubiomes
1 parent 589701b commit 4e78fa7

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

includes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
--include-function getEndSurfaceHeight
2626
--include-function getNetherBiome
2727
--include-function getOldBetaBiome
28+
--include-function getSpline
2829
--include-function getVoronoiSrcRange
2930
--include-function initBiomeNoise
3031
--include-function initBlendedNoise
@@ -46,6 +47,7 @@
4647
--include-function sampleEntrances
4748
--include-function sampleFinalDensity
4849
--include-function sampleNoiseColumn
50+
--include-function sampleNoiseParameters
4951
--include-function sampleNoodle
5052
--include-function samplePillars
5153
--include-function samplePreliminarySurfaceLevel

src/main/c/cubiomes

src/main/java/dev/xpple/seedmapper/command/arguments/DensityFunctionArgument.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.xpple.seedmapper.command.arguments;
22

3+
import com.github.cubiomes.BiomeNoise;
34
import com.github.cubiomes.Cubiomes;
45
import com.github.cubiomes.TerrainNoiseParameters;
56
import com.google.common.collect.ImmutableMap;
@@ -13,6 +14,7 @@
1314
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
1415
import net.minecraft.commands.SharedSuggestionProvider;
1516

17+
import java.lang.foreign.Arena;
1618
import java.lang.foreign.MemorySegment;
1719
import java.util.Arrays;
1820
import java.util.Collection;
@@ -32,17 +34,17 @@ public class DensityFunctionArgument implements ArgumentType<DensityFunctionArgu
3234
.put("cave_entrance", Cubiomes::sampleCaveEntrance)
3335
.put("overworld.caves.entrances", (params, x, y, z) -> Cubiomes.sampleEntrances(params, x, y, z, Cubiomes.sampleSpaghettiRoughness(params, x, y, z)))
3436
.put("cave_layer", Cubiomes::sampleCaveLayer)
35-
.put("overworld.sloped_cheese", Cubiomes::sampleSlopedCheese)
36-
.put("cave_cheese", (params, x, y, z) -> Cubiomes.sampleCaveCheese(params, x, y, z, Cubiomes.sampleSlopedCheese(params, x, y, z)))
37+
.put("overworld.sloped_cheese", DensityFunctionArgument::computeSlopedCheese)
38+
.put("cave_cheese", (params, x, y, z) -> Cubiomes.sampleCaveCheese(params, x, y, z, computeSlopedCheese(params, x, y, z)))
3739
.put("overworld.caves.pillars", Cubiomes::samplePillars)
3840
.put("overworld.caves.noodle", Cubiomes::sampleNoodle)
3941
.put("underground", (params, x, y, z) -> {
4042
double spaghettiRoughness = Cubiomes.sampleSpaghettiRoughness(params, x, y, z);
41-
return Cubiomes.sampleUnderground(params, x, y, z, spaghettiRoughness, Cubiomes.sampleEntrances(params, x, y, z, spaghettiRoughness), Cubiomes.sampleSlopedCheese(params, x, y, z));
43+
return Cubiomes.sampleUnderground(params, x, y, z, spaghettiRoughness, Cubiomes.sampleEntrances(params, x, y, z, spaghettiRoughness), computeSlopedCheese(params, x, y, z));
4244
})
4345
.put("final_density", (params, x, y, z) -> {
4446
double spaghettiRoughness = Cubiomes.sampleSpaghettiRoughness(params, x, y, z);
45-
return Cubiomes.sampleFinalDensity(params, x, y, z, spaghettiRoughness, Cubiomes.sampleEntrances(params, x, y, z, spaghettiRoughness), Cubiomes.sampleSlopedCheese(params, x, y, z));
47+
return Cubiomes.sampleFinalDensity(params, x, y, z, spaghettiRoughness, Cubiomes.sampleEntrances(params, x, y, z, spaghettiRoughness), computeSlopedCheese(params, x, y, z));
4648
})
4749
.put("preliminary_surface_level", (params, x, _, z) -> Cubiomes.samplePreliminarySurfaceLevel(params, x, z))
4850
.build();
@@ -81,4 +83,17 @@ public Collection<String> getExamples() {
8183
public interface DensityFunction {
8284
double compute(MemorySegment terrainNoiseParameters, int x, int y, int z);
8385
}
86+
87+
private static double computeSlopedCheese(MemorySegment params, int x, int y, int z) {
88+
try (Arena arena = Arena.ofConfined()) {
89+
MemorySegment np_param = arena.allocate(Cubiomes.C_FLOAT, 4);
90+
Cubiomes.sampleNoiseParameters(TerrainNoiseParameters.bn(params), x >> 2, z >> 2, np_param);
91+
double depth = Cubiomes.getSpline(BiomeNoise.sp(TerrainNoiseParameters.bn(params)), np_param) - 0.50375f;
92+
double factor = Cubiomes.getSpline(TerrainNoiseParameters.factorSpline(params), np_param);
93+
double jagged = Cubiomes.sampleDoublePerlin(TerrainNoiseParameters.jagged(params), x * 1500.0, 0, z * 1500.0);
94+
jagged = jagged >= 0.0 ? jagged : jagged / 2.0;
95+
jagged *= Cubiomes.getSpline(TerrainNoiseParameters.jaggednessSpline(params), np_param);
96+
return Cubiomes.sampleSlopedCheese(params, x, y, z, depth, factor, jagged);
97+
}
98+
}
8499
}

0 commit comments

Comments
 (0)