Skip to content

Commit 776e698

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents b4c28ee + 461381c commit 776e698

11 files changed

Lines changed: 97 additions & 62 deletions

File tree

buildSrc/src/main/java/dev/xpple/seedmapper/buildscript/CreateJavaBindingsTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public abstract class CreateJavaBindingsTask extends Exec {
1313

1414
this.setWorkingDir(this.getProject().getRootDir());
1515
this.setStandardOutput(System.out);
16-
this.commandLine("./jextract/build/jextract/bin/jextract" + EXTENSION, "--include-dir", "src/main/c/cubiomes", "--output", "src/main/java", "--use-system-load-library", "--target-package", "com.github.cubiomes", "--header-class-name", "Cubiomes", "@src/main/c/cubiomes/includes.txt", "biomenoise.h", "biomes.h", "finders.h", "generator.h", "layers.h", "biomenoise.h", "biomes.h", "noise.h", "terrainnoise.h", "rng.h", "util.h", "quadbase.h", "xrms.h", "loot/items.h", "loot/logging.h", "loot/loot_functions.h", "loot/loot_table_context.h", "loot/loot_table_parser.h", "loot/loot_tables.h", "loot/mc_loot.h");
16+
this.commandLine("./jextract/build/jextract/bin/jextract" + EXTENSION, "--include-dir", "src/main/c/cubiomes", "--output", "src/main/java", "--use-system-load-library", "--target-package", "com.github.cubiomes", "--header-class-name", "Cubiomes", "@src/main/c/cubiomes/includes.txt", "biomenoise.h", "biomes.h", "finders.h", "generator.h", "layers.h", "biomenoise.h", "biomes.h", "noise.h", "terrainnoise.h", "rng.h", "util.h", "quadbase.h", "xrms.h", "features/stronghold.h", "loot/items.h", "loot/logging.h", "loot/loot_functions.h", "loot/loot_table_context.h", "loot/loot_table_parser.h", "loot/loot_tables.h", "loot/mc_loot.h");
1717
}
1818
}

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Changelog
2-
- Added 26.1.2 version argument.
2+
- Re-enabled Baritone integration.
3+
- Fixed carver highlighting on 1.17.1 and below.
34

45
## Mod compatibility
56
| | Mod JAR | Biomes | Structures | Loot | Ores | Slime chunks |

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G
33
org.gradle.parallel=true
44

55
# Mod Properties
6-
mod_version=2.22.2-CevAPI
7-
fork_release_version=v0.18
6+
mod_version=2.22.3-CevAPI
7+
fork_release_version=v0.19
88
maven_group=dev.xpple
99
archives_base_name=SeedMapper
1010

@@ -27,7 +27,7 @@ simplewaypoints_version=1.3.0
2727
mod_publish_plugin_version=1.1.0
2828

2929
# Optional library dependencies
30-
baritone_version=1.21.11-SNAPSHOT
30+
baritone_version=26.1-SNAPSHOT
3131

3232
devauth_version=1.2.2
3333

src/main/c/cubiomes

src/main/java/dev/xpple/seedmapper/SeedMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public class SeedMapper implements ClientModInitializer {
6060

6161
private static final Logger LOGGER = LogUtils.getLogger();
6262

63-
// FIXME
64-
public static final boolean BARITONE_AVAILABLE = false; // FabricLoader.getInstance().getModContainer("baritone-meteor").isPresent();
63+
public static final boolean BARITONE_AVAILABLE = FabricLoader.getInstance().getModContainer("baritone-meteor").isPresent();
6564

6665
static {
6766
String libraryName = System.mapLibraryName("cubiomes");

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ public class StructurePredicateArgument implements ArgumentType<StructurePredica
103103
.put("corridor_nether_wart", Cubiomes.CORRIDOR_NETHER_WART())
104104
.put("fortress_end", Cubiomes.FORTRESS_END())
105105
.build())
106+
.put(Cubiomes.Stronghold(), ImmutableMap.<String, Integer>builder()
107+
.put("straight", Cubiomes.SH_STRAIGHT())
108+
.put("prison_hall", Cubiomes.SH_PRISON_HALL())
109+
.put("left_turn", Cubiomes.SH_LEFT_TURN())
110+
.put("right_turn", Cubiomes.SH_RIGHT_TURN())
111+
.put("room_crossing", Cubiomes.SH_ROOM_CROSSING())
112+
.put("straight_stairs_down", Cubiomes.SH_STRAIGHT_STAIRS_DOWN())
113+
.put("stairs_down", Cubiomes.SH_STAIRS_DOWN())
114+
.put("five_crossing", Cubiomes.SH_FIVE_CROSSING())
115+
.put("chest_corridor", Cubiomes.SH_CHEST_CORRIDOR())
116+
.put("library", Cubiomes.SH_LIBRARY())
117+
.put("portal_room", Cubiomes.SH_PORTAL_ROOM())
118+
.put("filler_corridor", Cubiomes.SH_FILLER_CORRIDOR())
119+
.build())
106120
.build();
107121
//</editor-fold>
108122

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

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.github.cubiomes.OreVeinParameters;
99
import com.github.cubiomes.Pos3;
1010
import com.github.cubiomes.Pos3List;
11+
import com.github.cubiomes.Range;
1112
import com.github.cubiomes.SurfaceNoise;
1213
import com.github.cubiomes.TerrainNoise;
1314
import com.mojang.brigadier.CommandDispatcher;
@@ -46,7 +47,6 @@
4647
import java.util.Map;
4748
import java.util.Objects;
4849
import java.util.Set;
49-
import java.util.function.BiFunction;
5050
import java.util.stream.Collectors;
5151
import java.util.stream.IntStream;
5252

@@ -86,7 +86,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
8686
.requires(_ -> Configs.DevMode)
8787
.then(argument("cave", caveCarver())
8888
.executes(ctx -> highlightCave(CustomClientCommandSource.of(ctx.getSource()), getCaveCarver(ctx, "cave")))
89-
.then(argument("chunks", integer(0, 20))
89+
.then(argument("chunks", integer(0, 10))
9090
.executes(ctx -> submit(() -> highlightCave(CustomClientCommandSource.of(ctx.getSource()), getCaveCarver(ctx, "cave"), getInteger(ctx, "chunks"))))))));
9191
}
9292

@@ -330,13 +330,8 @@ private static int highlightCanyon(CustomClientCommandSource source, int canyonC
330330
if (CanyonCarverConfig.dim(ccc) != dimension) {
331331
throw CommandExceptions.INVALID_DIMENSION_EXCEPTION.create();
332332
}
333-
var biomeFunction = LocateCommand.getCarverBiomeFunction(arena, seed.seed(), dimension, version, source.getGeneratorFlags());
334-
return highlightCarver(source, chunkRange, Configs.CanyonESP, (chunkX, chunkZ) -> {
335-
int biome = biomeFunction.applyAsInt(chunkX, chunkZ);
336-
if (Cubiomes.isViableCanyonBiome(canyonCarver, biome) == 0) {
337-
return null;
338-
}
339-
return Cubiomes.carveCanyon(arena, seed.seed(), chunkX, chunkZ, ccc);
333+
return highlightCarver(source, chunkRange, Configs.CanyonESP, arena, (chunkX, chunkZ, biomes, poses) -> {
334+
Cubiomes.carveCanyon(seed.seed(), version, chunkX, chunkZ, ccc, canyonCarver, biomes, poses);
340335
});
341336
}
342337
}
@@ -359,34 +354,63 @@ private static int highlightCave(CustomClientCommandSource source, int caveCarve
359354
if (CaveCarverConfig.dim(ccc) != dimension) {
360355
throw CommandExceptions.INVALID_DIMENSION_EXCEPTION.create();
361356
}
362-
var biomeFunction = LocateCommand.getCarverBiomeFunction(arena, seed.seed(), dimension, version, source.getGeneratorFlags());
363-
return highlightCarver(source, chunkRange, Configs.CaveESP, (chunkX, chunkZ) -> {
364-
int biome = biomeFunction.applyAsInt(chunkX, chunkZ);
365-
if (Cubiomes.isViableCaveBiome(caveCarver, biome) == 0) {
366-
return null;
367-
}
368-
return Cubiomes.carveCave(arena, seed.seed(), chunkX, chunkZ, ccc);
357+
return highlightCarver(source, chunkRange, Configs.CaveESP, arena, (chunkX, chunkZ, biomes, poses) -> {
358+
Cubiomes.carveCave(seed.seed(), version, chunkX, chunkZ, ccc, caveCarver, biomes, poses);
369359
});
370360
}
371361
}
372362

373-
private static int highlightCarver(CustomClientCommandSource source, int chunkRange, EspStyle style, BiFunction<Integer, Integer, @Nullable MemorySegment> carverFunction) {
363+
private static int highlightCarver(CustomClientCommandSource source, int chunkRange, EspStyle style, Arena arena, CarverFunction carverFunction) throws CommandSyntaxException {
364+
SeedIdentifier seed = source.getSeed().getSecond();
365+
int dimension = source.getDimension();
366+
int version = source.getVersion();
367+
int generatorFlags = source.getGeneratorFlags();
368+
369+
@Nullable MemorySegment generator, range;
370+
MemorySegment biomes;
371+
if (version <= Cubiomes.MC_1_17_1()) {
372+
generator = Generator.allocate(arena);
373+
Cubiomes.setupGenerator(generator, version, generatorFlags);
374+
Cubiomes.applySeed(generator, dimension, seed.seed());
375+
376+
range = Range.allocate(arena);
377+
Range.scale(range, 16);
378+
Range.sx(range, 17);
379+
Range.sz(range, 17);
380+
Range.y(range, 0);
381+
Range.sy(range, 0);
382+
383+
long cacheSize = Cubiomes.getMinCacheSize(generator, Range.scale(range), Range.sx(range), Range.sy(range), Range.sz(range));
384+
biomes = arena.allocate(Cubiomes.C_INT, cacheSize);
385+
} else {
386+
generator = null;
387+
range = null;
388+
biomes = arena.allocate(MemoryLayout.sequenceLayout(17, MemoryLayout.sequenceLayout(17, Cubiomes.C_INT)));
389+
}
390+
391+
MemorySegment pos3List = Pos3List.allocate(arena);
392+
Cubiomes.createPos3List(pos3List, 1024);
393+
374394
ChunkPos center = ChunkPos.containing(BlockPos.containing(source.getPosition()));
375-
Set<BlockPos> blocks = new HashSet<>();
376395
SpiralLoop.spiral(center.x(), center.z(), chunkRange, (chunkX, chunkZ) -> {
377-
MemorySegment pos3List = carverFunction.apply(chunkX, chunkZ);
378-
if (pos3List == null) {
379-
return false;
380-
}
381-
int size = Pos3List.size(pos3List);
382-
MemorySegment pos3s = Pos3List.pos3s(pos3List);
383-
for (int i = 0; i < size; i++) {
384-
MemorySegment pos3 = Pos3.asSlice(pos3s, i);
385-
blocks.add(new BlockPos(Pos3.x(pos3), Pos3.y(pos3), Pos3.z(pos3)));
396+
if (version <= Cubiomes.MC_1_17_1()) {
397+
assert range != null;
398+
Range.x(range, chunkX - 8);
399+
Range.z(range, chunkZ - 8);
400+
Cubiomes.genBiomes(generator, biomes, range);
386401
}
387-
402+
carverFunction.carve(chunkX, chunkZ, biomes, pos3List);
388403
return false;
389404
});
405+
406+
Set<BlockPos> blocks = new HashSet<>();
407+
int size = Pos3List.size(pos3List);
408+
MemorySegment pos3s = Pos3List.pos3s(pos3List);
409+
for (int i = 0; i < size; i++) {
410+
MemorySegment pos3 = Pos3.asSlice(pos3s, i);
411+
blocks.add(new BlockPos(Pos3.x(pos3), Pos3.y(pos3), Pos3.z(pos3)));
412+
}
413+
Cubiomes.freePos3List(pos3List);
390414
RenderManager.drawBoxes(blocks, style, 0xFF_FF0000);
391415
source.getClient().schedule(() -> source.sendFeedback(Component.translatable("command.highlight.carver.success", accent(String.valueOf(blocks.size())))));
392416
return blocks.size();
@@ -396,4 +420,9 @@ private static boolean isAirOrLava(LevelChunk chunk, BlockPos pos) {
396420
var state = chunk.getBlockState(pos);
397421
return state.isAir() || state.is(Blocks.LAVA) || state.getFluidState().is(Fluids.LAVA);
398422
}
423+
424+
@FunctionalInterface
425+
private interface CarverFunction {
426+
void carve(int chunkX, int chunkZ, MemorySegment biomes, MemorySegment poses);
427+
}
399428
}

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class LocateCommand {
7171
private static final int BIOME_SEARCH_HORIZONTAL_STEP = 32;
7272
private static final int BIOME_SEARCH_VERTICAL_STEP = 64;
7373

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());
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(), Cubiomes.Stronghold());
7575

7676
public record LootStructureResult(String structureName, int count, List<BlockPos> positions) {}
7777
public record LootLocateResult(int totalFound, String itemName, BlockPos pos, BlockPos searchOrigin, List<LootStructureResult> structureResults) {}
@@ -550,7 +550,16 @@ private static int locateCanyon(CustomClientCommandSource source) throws Command
550550
}
551551
ChunkPos center = ChunkPos.containing(BlockPos.containing(source.getPosition()));
552552
try (Arena arena = Arena.ofConfined()) {
553-
ToIntBiFunction<Integer, Integer> biomeFunction = getCarverBiomeFunction(arena, seed.seed(), dimension, version, source.getGeneratorFlags());
553+
ToIntBiFunction<Integer, Integer> biomeFunction;
554+
int generatorFlags = source.getGeneratorFlags();
555+
if (version > Cubiomes.MC_1_17_1()) {
556+
biomeFunction = (_, _) -> -1;
557+
} else {
558+
MemorySegment generator = Generator.allocate(arena);
559+
Cubiomes.setupGenerator(generator, version, generatorFlags);
560+
Cubiomes.applySeed(generator, dimension, seed.seed());
561+
biomeFunction = (chunkX, chunkZ) -> Cubiomes.getBiomeAt(generator, 4, chunkX << 2, 0, chunkZ << 2);
562+
}
554563
MemorySegment ccc = CanyonCarverConfig.allocate(arena);
555564
MemorySegment rnd = arena.allocate(Cubiomes.C_LONG_LONG);
556565
SpiralLoop.Coordinate pos = SpiralLoop.spiral(center.x(), center.z(), 6400, (chunkX, chunkZ) -> {
@@ -576,14 +585,4 @@ private static int locateCanyon(CustomClientCommandSource source) throws Command
576585
return Command.SINGLE_SUCCESS;
577586
}
578587
}
579-
580-
static ToIntBiFunction<Integer, Integer> getCarverBiomeFunction(Arena arena, long seed, int dimension, int version, int generatorFlags) {
581-
if (version > Cubiomes.MC_1_17_1()) {
582-
return (_, _) -> -1;
583-
}
584-
MemorySegment generator = Generator.allocate(arena);
585-
Cubiomes.setupGenerator(generator, version, generatorFlags);
586-
Cubiomes.applySeed(generator, dimension, seed);
587-
return (chunkX, chunkZ) -> Cubiomes.getBiomeAt(generator, 4, chunkX << 2, 0, chunkZ << 2);
588-
}
589588
}

src/main/java/dev/xpple/seedmapper/feature/StructureChecks.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ private StructureChecks() {
4646
int numPieces = Cubiomes.getFortressPieces(pieces, MAX_END_CITY_AND_FORTRESS_PIECES, Generator.mc(generator), Generator.seed(generator), Pos.x(structurePos) >> 4, Pos.z(structurePos) >> 4);
4747
return piecesPredicate.test(numPieces, pieces);
4848
});
49+
} else if (structure == Cubiomes.Stronghold()) {
50+
tempPiecesPredicateChecks.put(structure, (piecesPredicate, pieces, generator, structurePos) -> {
51+
int numPieces = Cubiomes.getStrongholdPieces(pieces, MAX_END_CITY_AND_FORTRESS_PIECES, Generator.mc(generator), Generator.seed(generator), Pos.x(structurePos) >> 4, Pos.z(structurePos) >> 4);
52+
return piecesPredicate.test(numPieces, pieces);
53+
});
4954
} else {
5055
throw new AssertionError();
5156
}

src/main/java/dev/xpple/seedmapper/util/BaritoneIntegration.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,10 @@
1313
import java.util.List;
1414
import java.util.concurrent.ConcurrentHashMap;
1515

16-
// FIXME: update as soon as MeteorDevelopment/baritone is updated to 26.1
17-
1816
/*
1917
* This class should NOT be loaded if Baritone is not available.
2018
*/
2119
public class BaritoneIntegration {
22-
23-
// FIXME
24-
static {
25-
if (true) {
26-
throw new AssertionError();
27-
}
28-
}
29-
3020
/*
3121
* There probably exists a more efficient data structure, but I couldn't find one that really appealed to me.
3222
* Basically, you want a data structure that implements fast nearest-neighbour searches with popping (i.e. find the
@@ -59,8 +49,7 @@ public static void onGoalCompletion(Goal goal) {
5949
// check goal equality by reference, this makes sure it was the goal from SeedMapper that was completed
6050
synchronized (CURRENT_GOAL_LOCK) {
6151
if (goal == currentGoal) {
62-
// FIXME
63-
// minedBlocks.add(currentGoal.getGoalPos());
52+
minedBlocks.add(currentGoal.getGoalPos());
6453
setGoalForNextBlock();
6554
}
6655
}
@@ -78,8 +67,7 @@ private static void setGoalForNextBlock() {
7867
Vec3 playerPos = player.position();
7968
BlockPos closest = targetBlocks.stream().min(Comparator.comparingDouble(b -> b.distToLowCornerSqr(playerPos.x, playerPos.y, playerPos.z))).orElseThrow();
8069
targetBlocks.remove(closest);
81-
// FIXME
82-
// currentGoal = new GoalBlock(closest);
70+
currentGoal = new GoalBlock(closest);
8371
// delay configuring the goal until the next tick, otherwise the new goal won't be executed
8472
Minecraft.getInstance().schedule(() -> BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(currentGoal));
8573
}

0 commit comments

Comments
 (0)