4646import dev .xpple .simplewaypoints .api .SimpleWaypointsAPI ;
4747import dev .xpple .simplewaypoints .api .Waypoint ;
4848import it .unimi .dsi .fastutil .ints .AbstractIntCollection ;
49- import it .unimi .dsi .fastutil .ints .Int2ObjectArrayMap ;
5049import it .unimi .dsi .fastutil .ints .IntArraySet ;
5150import it .unimi .dsi .fastutil .ints .IntSet ;
5251import it .unimi .dsi .fastutil .objects .Object2IntMap ;
@@ -460,6 +459,16 @@ private Tile createSlimeChunkTile(TilePos tilePos, BitSet slimeChunkData) {
460459 }
461460
462461 private @ Nullable FeatureWidget addFeatureWidget (GuiGraphics guiGraphics , MapFeature feature , MapFeature .Texture variantTexture , BlockPos pos ) {
462+ if (feature == MapFeature .END_CITY_SHIP ) {
463+ FeatureWidget toRemove = this .featureWidgets .stream ()
464+ .filter (widget -> widget .feature == MapFeature .END_CITY && widget .featureLocation .equals (pos ))
465+ .findFirst ()
466+ .orElse (null );
467+ if (toRemove != null ) {
468+ this .featureWidgets .remove (toRemove );
469+ }
470+ }
471+
463472 FeatureWidget widget = new FeatureWidget (feature , variantTexture , pos );
464473 if (!widget .withinBounds ()) {
465474 return null ;
@@ -470,14 +479,18 @@ private Tile createSlimeChunkTile(TilePos tilePos, BitSet slimeChunkData) {
470479 }
471480
472481 private void drawFeatureIcons (GuiGraphics guiGraphics ) {
473- if (!this .shouldDrawFeatureIcons ()) return ;
474- this .featureWidgets .stream ()
482+ if (!this .shouldDrawFeatureIcons ()) {
483+ return ;
484+ }
485+ List <FeatureWidget > widgets = this .featureWidgets .stream ()
475486 .filter (FeatureWidget ::withinBounds )
476- .filter (w -> Configs .ToggledFeatures .contains (w .feature ))
477- .forEach (w -> {
478- MapFeature .Texture t = w .texture ();
479- this .drawFeatureIcon (guiGraphics , t , w .x , w .y , t .width (), t .height (), 0xFF_FFFFFF );
480- });
487+ .filter (widget -> Configs .ToggledFeatures .contains (widget .feature ))
488+ .sorted (Comparator .comparingInt (widget -> widget .feature == MapFeature .END_CITY_SHIP ? 1 : 0 ))
489+ .toList ();
490+ for (FeatureWidget widget : widgets ) {
491+ MapFeature .Texture texture = widget .texture ();
492+ this .drawFeatureIcon (guiGraphics , texture , widget .x , widget .y , texture .width (), texture .height (), 0xFF_FFFFFF );
493+ }
481494 }
482495
483496 private void createFeatureToggles () {
@@ -563,6 +576,19 @@ private BitSet calculateSlimeChunkData(TilePos tilePos) {
563576 } else {
564577 texture = feature .getVariantTexture (this .worldIdentifier , pos .getX (), pos .getZ (), optionalBiome .getAsInt ());
565578 }
579+ if (feature == MapFeature .END_CITY_SHIP ) {
580+ try (Arena tempArena = Arena .ofConfined ()) {
581+ MemorySegment pieces = Piece .allocateArray (StructureChecks .MAX_END_CITY_AND_FORTRESS_PIECES , tempArena );
582+ int numPieces = Cubiomes .getEndCityPieces (pieces , this .worldIdentifier .seed (), pos .getX () >> 4 , pos .getZ () >> 4 );
583+ boolean hasShip = IntStream .range (0 , numPieces )
584+ .mapToObj (i -> Piece .asSlice (pieces , i ))
585+ .anyMatch (piece -> Piece .type (piece ) == Cubiomes .END_SHIP ());
586+ if (!hasShip ) {
587+ return null ;
588+ }
589+ texture = feature .getDefaultTexture ();
590+ }
591+ }
566592 return new StructureData (pos , texture );
567593 }
568594
@@ -1747,8 +1773,8 @@ protected void renderSeedMap(GuiGraphics guiGraphics, int mouseX, int mouseY, fl
17471773 }
17481774 ChunkPos chunkPos = new ChunkPos (SectionPos .blockToSectionCoord (Pos .x (structurePos )), SectionPos .blockToSectionCoord (Pos .z (structurePos )));
17491775
1750- ChunkStructureData chunkStructureData = this .structureCache .computeIfAbsent (chunkPos , _ -> new ChunkStructureData (chunkPos , new Int2ObjectArrayMap <>() ));
1751- StructureData data = chunkStructureData .structures ().computeIfAbsent (structure , _ -> this .calculateStructureData (feature , regionPos , structurePos , generationCheck ));
1776+ ChunkStructureData chunkStructureData = this .structureCache .computeIfAbsent (chunkPos , _ -> ChunkStructureData . create (chunkPos ));
1777+ StructureData data = chunkStructureData .structures ().computeIfAbsent (feature . getName () , _ -> this .calculateStructureData (feature , regionPos , structurePos , generationCheck ));
17521778 if (data == null ) {
17531779 continue ;
17541780 }
0 commit comments