@@ -1856,13 +1856,21 @@ private void drawSeedMapperFeatureStrip(GuiGraphicsExtractor graphics, int mouse
18561856 int x = startX + titleWidth + stripPad + 8 ;
18571857 int contentEnd = this .width - this .sideMargin - 6 ;
18581858 int perPage = Math .max (1 , (contentEnd - x ) / (iconSize + gap ));
1859- List <SeedMapperFeature > visibleFeatures = new ArrayList <>();
1859+ List <LegendEntry > visibleEntries = new ArrayList <>();
18601860 for (SeedMapperFeature feature : SeedMapperFeature .values ()) {
1861+ if (feature == SeedMapperFeature .DATAPACK_STRUCTURE ) {
1862+ continue ;
1863+ }
18611864 if (featureMatchesDimension (feature , currentDimension ) && isSeedMapperFeatureVisible (feature )) {
1862- visibleFeatures .add (feature );
1865+ visibleEntries .add (LegendEntry .feature (feature ));
1866+ }
1867+ }
1868+ if (seedMapperOptions .datapackEnabled && seedMapperOptions .isFeatureEnabled (SeedMapperFeature .DATAPACK_STRUCTURE )) {
1869+ for (String structureId : visibleDatapackLegendStructureIds ()) {
1870+ visibleEntries .add (LegendEntry .datapack (structureId ));
18631871 }
18641872 }
1865- SeedMapperFeature [] all = visibleFeatures .toArray (SeedMapperFeature []::new );
1873+ LegendEntry [] all = visibleEntries .toArray (LegendEntry []::new );
18661874 seedMapperLegendMaxPage = Math .max (0 , (all .length - 1 ) / perPage );
18671875 if (seedMapperLegendPage > seedMapperLegendMaxPage ) {
18681876 seedMapperLegendPage = seedMapperLegendMaxPage ;
@@ -1871,8 +1879,8 @@ private void drawSeedMapperFeatureStrip(GuiGraphicsExtractor graphics, int mouse
18711879 int startIndex = seedMapperLegendPage * perPage ;
18721880 int endIndex = Math .min (all .length , startIndex + perPage );
18731881 for (int i = startIndex ; i < endIndex ; i ++) {
1874- SeedMapperFeature feature = all [i ];
1875- seedMapperIconHitboxes .add (new FeatureIconHitbox (feature , x , y + (barHeight - iconSize ) / 2 , iconSize ));
1882+ LegendEntry entry = all [i ];
1883+ seedMapperIconHitboxes .add (new FeatureIconHitbox (entry . feature (), entry . datapackStructureId () , x , y + (barHeight - iconSize ) / 2 , iconSize ));
18761884 x += iconSize + gap ;
18771885 }
18781886
@@ -1918,13 +1926,19 @@ private void drawSeedMapperFeatureStrip(GuiGraphicsExtractor graphics, int mouse
19181926 if (!seedMapperIconHitboxes .isEmpty ()) {
19191927 for (FeatureIconHitbox hitbox : seedMapperIconHitboxes ) {
19201928 SeedMapperFeature feature = hitbox .feature ();
1921- boolean enabled = isFeatureEnabledInPanel (feature );
1929+ boolean datapackStructure = hitbox .datapackStructureId () != null ;
1930+ boolean enabled = datapackStructure || isFeatureEnabledInPanel (feature );
19221931 int color = enabled ? 0xFFFFFFFF : 0x55FFFFFF ;
1923- VoxelMapGuiGraphics .blitFloat (graphics , RenderPipelines .GUI_TEXTURED , feature .icon (), hitbox .x (), hitbox .y (), iconSize , iconSize , 0 , 1 , 0 , 1 , color );
1932+ if (datapackStructure ) {
1933+ drawDatapackLegendIcon (graphics , hitbox .datapackStructureId (), hitbox .x (), hitbox .y (), iconSize );
1934+ } else {
1935+ VoxelMapGuiGraphics .blitFloat (graphics , RenderPipelines .GUI_TEXTURED , feature .icon (), hitbox .x (), hitbox .y (), iconSize , iconSize , 0 , 1 , 0 , 1 , color );
1936+ }
19241937 if (mouseX >= hitbox .x () && mouseX <= hitbox .x () + iconSize && mouseY >= hitbox .y () && mouseY <= hitbox .y () + iconSize ) {
19251938 graphics .requestCursor (CursorTypes .CROSSHAIR );
1926- Component tooltip = Component .translatable (feature .translationKey ())
1927- .append (Component .literal (enabled ? " (ON)" : " (OFF)" ));
1939+ Component tooltip = datapackStructure
1940+ ? Component .literal (hitbox .datapackStructureId () + " (ON)" )
1941+ : Component .translatable (feature .translationKey ()).append (Component .literal (enabled ? " (ON)" : " (OFF)" ));
19281942 renderTooltip (graphics , tooltip , mouseX , mouseY );
19291943 }
19301944 }
@@ -1961,6 +1975,13 @@ private boolean handleSeedMapperIconClick(int mouseX, int mouseY) {
19611975 }
19621976 for (FeatureIconHitbox hitbox : seedMapperIconHitboxes ) {
19631977 if (hitbox .contains (mouseX , mouseY )) {
1978+ if (hitbox .datapackStructureId () != null ) {
1979+ seedMapperOptions .setDatapackStructureEnabled (currentSeedMapperWorldKey (), hitbox .datapackStructureId (), false );
1980+ seedMapperSavedToggles = null ;
1981+ seedMapperIsolatedFeature = null ;
1982+ MapSettingsManager .instance .saveAll ();
1983+ return true ;
1984+ }
19641985 boolean ctrlDown = isCtrlDown ();
19651986 SeedMapperFeature clicked = hitbox .feature ();
19661987 if (isPortalFeature (clicked )) {
@@ -2027,6 +2048,37 @@ private boolean isSeedMapperFeatureVisible(SeedMapperFeature feature) {
20272048 return true ;
20282049 }
20292050
2051+ private List <String > visibleDatapackLegendStructureIds () {
2052+ long seed ;
2053+ try {
2054+ seed = seedMapperOptions .resolveSeed (VoxelConstants .getVoxelMapInstance ().getWorldSeed ());
2055+ } catch (IllegalArgumentException ignored ) {
2056+ return List .of ();
2057+ }
2058+ String worldKey = currentSeedMapperWorldKey ();
2059+ Set <String > disabled = seedMapperOptions .getDisabledDatapackStructures (worldKey );
2060+ ArrayList <String > ids = new ArrayList <>();
2061+ for (String id : SeedMapperImportedDatapackManager .importedStructureIds (seedMapperOptions .datapackCachePath , seed )) {
2062+ if (!disabled .contains (id )) {
2063+ ids .add (id );
2064+ }
2065+ }
2066+ return ids ;
2067+ }
2068+
2069+ private void drawDatapackLegendIcon (GuiGraphicsExtractor graphics , String structureId , int x , int y , int iconSize ) {
2070+ int color = SeedMapperImportedDatapackManager .colorForStructureId (structureId );
2071+ if (SeedMapperImportedDatapackManager .usesPotionIcon ()) {
2072+ Identifier potion = SeedMapperImportedDatapackManager .iconForStructureId (structureId );
2073+ Identifier overlay = SeedMapperImportedDatapackManager .iconOverlayForStructureId (structureId );
2074+ VoxelMapGuiGraphics .blitFloat (graphics , RenderPipelines .GUI_TEXTURED , potion , x , y , iconSize , iconSize , 0 , 1 , 0 , 1 , 0xFFFFFFFF );
2075+ VoxelMapGuiGraphics .blitFloat (graphics , RenderPipelines .GUI_TEXTURED , overlay , x , y , iconSize , iconSize , 0 , 1 , 0 , 1 , color );
2076+ return ;
2077+ }
2078+ graphics .fill (x - 1 , y - 1 , x + iconSize + 1 , y + iconSize + 1 , 0xFF000000 );
2079+ graphics .fill (x , y , x + iconSize , y + iconSize , color );
2080+ }
2081+
20302082 private boolean isPortalFeature (SeedMapperFeature feature ) {
20312083 return feature == SeedMapperFeature .NETHER_PORTAL
20322084 || feature == SeedMapperFeature .END_PORTAL
@@ -2685,7 +2737,17 @@ private void centerOnWorldSpawn() {
26852737 }
26862738 }
26872739
2688- private record FeatureIconHitbox (SeedMapperFeature feature , int x , int y , int size ) {
2740+ private record LegendEntry (SeedMapperFeature feature , String datapackStructureId ) {
2741+ private static LegendEntry feature (SeedMapperFeature feature ) {
2742+ return new LegendEntry (feature , null );
2743+ }
2744+
2745+ private static LegendEntry datapack (String structureId ) {
2746+ return new LegendEntry (SeedMapperFeature .DATAPACK_STRUCTURE , structureId );
2747+ }
2748+ }
2749+
2750+ private record FeatureIconHitbox (SeedMapperFeature feature , String datapackStructureId , int x , int y , int size ) {
26892751 private boolean contains (int mouseX , int mouseY ) {
26902752 return mouseX >= x && mouseX <= x + size && mouseY >= y && mouseY <= y + size ;
26912753 }
0 commit comments