@@ -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 ) {
0 commit comments