|
27 | 27 | import java.util.HashMap; |
28 | 28 | import java.util.List; |
29 | 29 | import java.util.Map; |
| 30 | +import java.util.stream.IntStream; |
30 | 31 |
|
31 | 32 | import static com.mojang.brigadier.arguments.IntegerArgumentType.*; |
32 | 33 | import static dev.xpple.seedmapper.command.arguments.BlockArgument.*; |
@@ -67,13 +68,23 @@ private static int highlightBlock(CustomClientCommandSource source, Pair<Integer |
67 | 68 | LevelChunk chunk = source.getWorld().getChunkSource().getChunk(chunkX, chunkZ, ChunkStatus.FULL, false); |
68 | 69 | boolean doAirCheck = Configs.OreAirCheck && chunk != null; |
69 | 70 | 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 | + } |
72 | 82 | 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)) |
74 | 84 | .<MemorySegment>mapMulti((oreType, consumer) -> { |
75 | 85 | 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) { |
77 | 88 | consumer.accept(oreConfig); |
78 | 89 | } |
79 | 90 | }) |
|
0 commit comments