Skip to content

Commit 09bdfca

Browse files
committed
Check for biomes at different altitudes for ore generation
1 parent c813284 commit 09bdfca

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/main/c

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.HashMap;
2828
import java.util.List;
2929
import java.util.Map;
30+
import java.util.stream.IntStream;
3031

3132
import static com.mojang.brigadier.arguments.IntegerArgumentType.*;
3233
import static dev.xpple.seedmapper.command.arguments.BlockArgument.*;
@@ -67,13 +68,23 @@ private static int highlightBlock(CustomClientCommandSource source, Pair<Integer
6768
LevelChunk chunk = source.getWorld().getChunkSource().getChunk(chunkX, chunkZ, ChunkStatus.FULL, false);
6869
boolean doAirCheck = Configs.OreAirCheck && chunk != null;
6970
Map<BlockPos, Integer> generatedOres = new HashMap<>();
70-
// TODO: check biome at multiple altitudes (technically should check 3x3 square of chunks)
71-
int biome = Cubiomes.getBiomeForOreGen(generator, chunkX, chunkZ);
71+
List<Integer> biomes;
72+
if (version <= Cubiomes.MC_1_17()) {
73+
biomes = List.of(Cubiomes.getBiomeForOreGen(generator, chunkX, chunkZ, 0));
74+
} else {
75+
// check certain Y-coordinates that matter for ore generation
76+
// Minecraft checks _all_ biomes in a 3x3 square of chunks, which is not necessary
77+
biomes = IntStream.of(-30, 64, 120)
78+
.map(y -> Cubiomes.getBiomeForOreGen(generator, chunkX, chunkZ, y))
79+
.boxed()
80+
.toList();
81+
}
7282
OreTypes.ORE_TYPES.stream()
73-
.filter(oreType -> Cubiomes.isViableOreBiome(version, oreType, biome) != 0)
83+
.filter(oreType -> biomes.stream().anyMatch(biome -> Cubiomes.isViableOreBiome(version, oreType, biome) != 0))
7484
.<MemorySegment>mapMulti((oreType, consumer) -> {
7585
MemorySegment oreConfig = OreConfig.allocate(arena);
76-
if (Cubiomes.getOreConfig(oreType, version, biome, oreConfig) != 0) {
86+
// just do biomes.getFirst() because in 1.17 there is only one, and in 1.18 it does not matter
87+
if (Cubiomes.getOreConfig(oreType, version, biomes.getFirst(), oreConfig) != 0) {
7788
consumer.accept(oreConfig);
7889
}
7990
})

0 commit comments

Comments
 (0)