Skip to content

Commit c943fbd

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0fe9e70 + e6c27cc commit c943fbd

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

includes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
--include-function genBiomeNoiseBetaScaled
1818
--include-function genBiomeNoiseChunkSection
1919
--include-function genBiomeNoiseScaled
20+
--include-function generateColumn
21+
--include-function generateRegion
2022
--include-function genEndScaled
2123
--include-function genNetherScaled
2224
--include-function getBiomeDepthAndScale
@@ -43,6 +45,7 @@
4345
--include-function sampleClimatePara
4446
--include-function sampleEntrances
4547
--include-function sampleFinalDensity
48+
--include-function sampleNoiseColumn
4649
--include-function sampleNoodle
4750
--include-function samplePillars
4851
--include-function samplePreliminarySurfaceLevel

src/main/java/dev/xpple/seedmapper/command/commands/HighlightCommand.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
import org.jetbrains.annotations.Nullable;
3333

3434
import java.lang.foreign.Arena;
35+
import java.lang.foreign.MemoryLayout;
3536
import java.lang.foreign.MemorySegment;
37+
import java.lang.foreign.SequenceLayout;
3638
import java.util.Comparator;
3739
import java.util.HashMap;
3840
import java.util.HashSet;
@@ -254,6 +256,14 @@ private static int highlightTerrain(CustomClientCommandSource source, int chunkR
254256
int version = source.getVersion();
255257

256258
ChunkPos center = new ChunkPos(BlockPos.containing(source.getPosition()));
259+
int minChunkX = center.x - chunkRange;
260+
int minChunkZ = center.z - chunkRange;
261+
int chunkW = chunkRange * 2 + 1;
262+
int chunkH = chunkRange * 2 + 1;
263+
int blockW = chunkW << 4;
264+
int blockH = chunkH << 4;
265+
int minX = minChunkX << 4;
266+
int minZ = minChunkZ << 4;
257267

258268
try (Arena arena = Arena.ofConfined()) {
259269
MemorySegment params = TerrainNoiseParameters.allocate(arena);
@@ -262,24 +272,23 @@ private static int highlightTerrain(CustomClientCommandSource source, int chunkR
262272
}
263273

264274
Set<BlockPos> blocks = new HashSet<>();
265-
SpiralLoop.spiral(center.x, center.z, chunkRange, (chunkX, chunkZ) -> {
266-
final int minChunkX = chunkX << 4;
267-
final int minChunkZ = chunkZ << 4;
268-
for (int x = minChunkX; x < minChunkX + 16; x++) {
269-
for (int z = minChunkZ; z < minChunkZ + 16; z++) {
270-
for (int y = -64; y < 320; y++) {
271-
double spaghettiRoughness = Cubiomes.sampleSpaghettiRoughness(params, x, y, z);
272-
double entrances = Cubiomes.sampleEntrances(params, x, y, z, spaghettiRoughness);
273-
double slopedCheese = Cubiomes.sampleSlopedCheese(params, x, y, z);
274-
double sample = Cubiomes.sampleFinalDensity(params, x, y, z, spaghettiRoughness, entrances, slopedCheese);
275-
if (sample <= 0) {
276-
blocks.add(new BlockPos(x, y, z));
277-
}
275+
SequenceLayout columnLayout = MemoryLayout.sequenceLayout(384, Cubiomes.C_INT);
276+
MemorySegment blockStates = arena.allocate(columnLayout, (long) blockW * blockH);
277+
Cubiomes.generateRegion(params, minChunkX, minChunkZ, chunkW, chunkH, blockStates, MemorySegment.NULL, 0);
278+
279+
for (int relX = 0; relX < blockW; relX++) {
280+
int x = minX + relX;
281+
for (int relZ = 0; relZ < blockH; relZ++) {
282+
int z = minZ + relZ;
283+
int columnIdx = (relX * blockH + relZ) * 384;
284+
for (int y = -64; y < 320; y++) {
285+
int block = blockStates.getAtIndex(Cubiomes.C_INT, columnIdx + y + 64);
286+
if (block == 1) {
287+
blocks.add(new BlockPos(x, y, z));
278288
}
279289
}
280290
}
281-
return false;
282-
});
291+
}
283292
RenderManager.drawBoxes(blocks, Configs.TerrainESP, 0xFF_FF0000);
284293
return blocks.size();
285294
}

src/main/java/dev/xpple/seedmapper/seedmap/SeedMapScreen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
import java.lang.foreign.Arena;
105105
import java.lang.foreign.MemoryLayout;
106106
import java.lang.foreign.MemorySegment;
107+
import java.lang.foreign.SequenceLayout;
107108
import java.lang.foreign.ValueLayout;
108109
import java.io.IOException;
109110
import java.net.InetAddress;
@@ -157,7 +158,7 @@ public class SeedMapScreen extends Screen {
157158

158159
static {
159160
// unsigned char color[3]
160-
MemoryLayout rgbLayout = MemoryLayout.sequenceLayout(3, Cubiomes.C_CHAR);
161+
SequenceLayout rgbLayout = MemoryLayout.sequenceLayout(3, Cubiomes.C_CHAR);
161162

162163
try (Arena arena = Arena.ofConfined()) {
163164
MemorySegment biomeColoursInternal = arena.allocate(rgbLayout, biomeColours.length);

0 commit comments

Comments
 (0)