Skip to content

Commit 63ab19d

Browse files
committed
Display portal room information when locating strongholds
1 parent 549723e commit 63ab19d

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/main/c/cubiomes

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,40 @@ private static int locateStronghold(CustomClientCommandSource source) throws Com
251251
TwoDTree tree = SeedMapScreen.strongholdDataCache.computeIfAbsent(new WorldIdentifier(seed.seed(), dimension, version, generatorFlags), _ -> calculateStrongholds(seed.seed(), dimension, version, generatorFlags));
252252

253253
BlockPos pos = tree.nearestTo(position.atY(0));
254+
assert pos != null;
254255

255256
source.getClient().schedule(() -> source.sendFeedback(Component.translatable("command.locate.feature.stronghold.success", ComponentUtils.formatXZ(pos.getX(), pos.getZ()))));
256-
return Command.SINGLE_SUCCESS;
257+
258+
try (Arena arena = Arena.ofConfined()) {
259+
MemorySegment pieces = Piece.allocateArray(StructureChecks.MAX_END_CITY_AND_FORTRESS_PIECES, arena);
260+
MemorySegment ssconf = StructureSaltConfig.allocate(arena);
261+
int numPieces;
262+
boolean lootSupported;
263+
// biome is not used for strongholds
264+
//noinspection AssignmentUsedAsCondition
265+
if (lootSupported = Cubiomes.getStructureSaltConfig(Cubiomes.Stronghold(), version, -1, ssconf) != 0) {
266+
numPieces = Cubiomes.getStrongholdLoot(pieces, StructureChecks.MAX_END_CITY_AND_FORTRESS_PIECES, ssconf, version, seed.seed(), pos.getX() >> 4, pos.getZ() >> 4);
267+
} else {
268+
numPieces = Cubiomes.getStrongholdPieces(pieces, StructureChecks.MAX_END_CITY_AND_FORTRESS_PIECES, version, seed.seed(), pos.getX() >> 4, pos.getZ() >> 4);
269+
}
270+
MemorySegment piece = IntStream.range(0, numPieces)
271+
.mapToObj(i -> Piece.asSlice(pieces, i))
272+
.filter(p -> Piece.type(p) == Cubiomes.SH_PORTAL_ROOM())
273+
.findAny().orElseThrow(); // every stronghold has a portal
274+
MemorySegment portalRoomPos = Piece.pos(piece);
275+
int portalRoomX = Pos3.x(portalRoomPos);
276+
int portalRoomZ = Pos3.z(portalRoomPos);
277+
if (lootSupported) {
278+
int eyesBitPack = Piece.additionalData(piece);
279+
int eyes = Integer.bitCount(eyesBitPack);
280+
source.getClient().schedule(() -> source.sendFeedback(Component.literal(" - ")
281+
.append(Component.translatable("command.locate.feature.stronghold.portal", ComponentUtils.formatXZ(portalRoomX, portalRoomZ), accent(Integer.toString(eyes))))));
282+
} else {
283+
source.getClient().schedule(() -> source.sendFeedback(Component.literal(" - ")
284+
.append(Component.translatable("command.locate.feature.stronghold.portalNoEyes", ComponentUtils.formatXZ(portalRoomX, portalRoomZ)))));
285+
}
286+
return numPieces;
287+
}
257288
}
258289

259290
public static TwoDTree calculateStrongholds(long seed, int dimension, int version, int generatorFlags) {

src/main/resources/assets/seedmapper/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
"command.locate.loot.foundAtStructure": "Found %s in %s at %s.",
7575
"command.locate.loot.totalFound": "Found %s of %s in total.",
7676
"command.locate.feature.stronghold.success": "Stronghold found at %s.",
77+
"command.locate.feature.stronghold.portal": "Portal is at %s and has %s eyes in it.",
78+
"command.locate.feature.stronghold.portalNoEyes": "Portal is at %s.",
7779
"command.locate.feature.slimeChunk.noneFound": "Couldn't locate a slime chunk within 6400 blocks.",
7880
"command.locate.feature.slimeChunk.foundAt": "Slime chunk found at %s (chunk %s).",
7981
"command.locate.feature.slimeChunk.copy": "Click to copy coordinates of this slime chunk",

0 commit comments

Comments
 (0)