|
31 | 31 | import dev.xpple.seedmapper.util.WorldIdentifier; |
32 | 32 | import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; |
33 | 33 | import net.minecraft.core.BlockPos; |
| 34 | +import net.minecraft.core.QuartPos; |
34 | 35 | import net.minecraft.core.SectionPos; |
35 | 36 | import net.minecraft.network.chat.Component; |
| 37 | +import net.minecraft.util.Mth; |
36 | 38 | import net.minecraft.util.RandomSource; |
37 | 39 | import net.minecraft.world.level.ChunkPos; |
38 | 40 | import net.minecraft.world.level.Level; |
|
65 | 67 |
|
66 | 68 | public class LocateCommand { |
67 | 69 |
|
68 | | - private static final int BIOME_SEARCH_RADIUS = 6400; |
| 70 | + private static final int BIOME_SEARCH_RADIUS = 25600; |
| 71 | + private static final int BIOME_SEARCH_HORIZONTAL_STEP = 32; |
| 72 | + private static final int BIOME_SEARCH_VERTICAL_STEP = 64; |
69 | 73 |
|
70 | 74 | public static final Set<Integer> LOOT_SUPPORTED_STRUCTURES = Set.of(Cubiomes.Treasure(), Cubiomes.Desert_Pyramid(), Cubiomes.End_City(), Cubiomes.Igloo(), Cubiomes.Jungle_Pyramid(), Cubiomes.Ruined_Portal(), Cubiomes.Ruined_Portal_N(), Cubiomes.Fortress(), Cubiomes.Bastion(), Cubiomes.Outpost(), Cubiomes.Shipwreck()); |
71 | 75 |
|
@@ -101,18 +105,31 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc |
101 | 105 | private static int locateBiome(CustomClientCommandSource source, int biome) throws CommandSyntaxException { |
102 | 106 | SeedIdentifier seed = source.getSeed().getSecond(); |
103 | 107 | int dimension = source.getDimension(); |
| 108 | + int version = source.getVersion(); |
104 | 109 | if (Cubiomes.getDimension(biome) != dimension) { |
105 | 110 | throw CommandExceptions.INVALID_DIMENSION_EXCEPTION.create(); |
106 | 111 | } |
| 112 | + if (Cubiomes.biomeExists(version, biome) == 0) { |
| 113 | + throw CommandExceptions.BIOME_WRONG_VERSION_EXCEPTION.create(); |
| 114 | + } |
107 | 115 | try (Arena arena = Arena.ofConfined()) { |
108 | 116 | MemorySegment generator = Generator.allocate(arena); |
109 | | - Cubiomes.setupGenerator(generator, source.getVersion(), source.getGeneratorFlags()); |
| 117 | + Cubiomes.setupGenerator(generator, version, source.getGeneratorFlags()); |
110 | 118 | Cubiomes.applySeed(generator, dimension, seed.seed()); |
111 | 119 |
|
112 | 120 | BlockPos center = BlockPos.containing(source.getPosition()); |
113 | 121 |
|
114 | | - SpiralLoop.Coordinate pos = SpiralLoop.spiral(center.getX(), center.getZ(), BIOME_SEARCH_RADIUS, 32, (x, z) -> { |
115 | | - return Cubiomes.getBiomeAt(generator, 1, x, 63, z) == biome; |
| 122 | + int minY = version <= Cubiomes.MC_1_17_1() ? 0 : -64; |
| 123 | + int maxY = version <= Cubiomes.MC_1_17_1() ? 256 : 320; |
| 124 | + int[] ys = Mth.outFromOrigin(center.getY(), minY + 1, maxY + 1, BIOME_SEARCH_VERTICAL_STEP).toArray(); |
| 125 | + |
| 126 | + SpiralLoop.Coordinate pos = SpiralLoop.spiral(center.getX(), center.getZ(), BIOME_SEARCH_RADIUS, BIOME_SEARCH_HORIZONTAL_STEP, (x, z) -> { |
| 127 | + for (int y : ys) { |
| 128 | + if (Cubiomes.getBiomeAt(generator, 4, QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)) == biome) { |
| 129 | + return true; |
| 130 | + } |
| 131 | + } |
| 132 | + return false; |
116 | 133 | }); |
117 | 134 | if (pos == null) { |
118 | 135 | throw CommandExceptions.NO_BIOME_FOUND_EXCEPTION.create(BIOME_SEARCH_RADIUS); |
|
0 commit comments