@@ -247,6 +247,7 @@ public static void clearCachesForPresetChange() {
247247 private final int featureIconsCombinedWidth ;
248248
249249 private final ObjectSet <FeatureWidget > featureWidgets = new ObjectOpenHashSet <>();
250+ private final java .util .List <FeatureToggleWidget > featureToggleWidgets = new java .util .ArrayList <>();
250251
251252 private boolean allowFeatureIconRendering = true ;
252253 private boolean allowMarkerRendering = true ;
@@ -484,7 +485,9 @@ private void createFeatureTogglesInner(int row, int togglesPerRow, int maxToggle
484485 for (int toggle = 0 ; toggle < maxToggles ; toggle ++) {
485486 MapFeature feature = this .toggleableFeatures .get (row * togglesPerRow + toggle );
486487 MapFeature .Texture featureIcon = feature .getDefaultTexture ();
487- this .addRenderableWidget (new FeatureToggleWidget (feature , toggleMinX , toggleMinY ));
488+ FeatureToggleWidget w = new FeatureToggleWidget (feature , toggleMinX , toggleMinY );
489+ this .featureToggleWidgets .add (w );
490+ this .addRenderableWidget (w );
488491 toggleMinX += featureIcon .width () + HORIZONTAL_FEATURE_TOGGLE_SPACING ;
489492 }
490493 }
@@ -703,10 +706,9 @@ public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, doubl
703706 float currentScroll = Mth .clamp ((float ) Configs .PixelsPerBiome / MAX_PIXELS_PER_BIOME , 0.0F , 1.0F );
704707 currentScroll = Mth .clamp (currentScroll - (float ) (-scrollY / MAX_PIXELS_PER_BIOME ), 0.0F , 1.0F );
705708
706- Configs .PixelsPerBiome = Math .max ((int ) (currentScroll * MAX_PIXELS_PER_BIOME + 0.5 ), MIN_PIXELS_PER_BIOME );
707- if (this .markerWidget != null ) {
708- this .markerWidget .updatePosition ();
709- }
709+ int newPixels = Math .max ((int ) (currentScroll * MAX_PIXELS_PER_BIOME + 0.5 ), MIN_PIXELS_PER_BIOME );
710+ // use setter so all feature/widget positions are updated when zooming
711+ this .setPixelsPerBiome (newPixels );
710712 return true ;
711713 }
712714
@@ -1010,6 +1012,17 @@ public boolean withinBounds() {
10101012 return true ;
10111013 }
10121014
1015+ public boolean isMouseOver (int mouseX , int mouseY ) {
1016+ return mouseX >= this .x && mouseX <= this .x + this .width () && mouseY >= this .y && mouseY <= this .y + this .height ();
1017+ }
1018+
1019+ public net .minecraft .network .chat .Component getTooltip () {
1020+ // create a readable tooltip from the feature name (replace underscores)
1021+ String raw = this .feature .getName ().replace ('_' , ' ' );
1022+ String pretty = Character .toUpperCase (raw .charAt (0 )) + raw .substring (1 );
1023+ return net .minecraft .network .chat .Component .literal (pretty );
1024+ }
1025+
10131026 @ Override
10141027 public int hashCode () {
10151028 return Objects .hash (this .feature , this .featureTexture , this .featureLocation );
@@ -1240,6 +1253,11 @@ protected void renderSeedMap(GuiGraphics guiGraphics, int mouseX, int mouseY, fl
12401253 }
12411254
12421255 // draw hovered coordinates and biome
1256+ // show tooltip for top feature toggles first
1257+ this .renderFeatureToggleTooltip (guiGraphics , mouseX , mouseY );
1258+ if (this .showFeatureIconTooltips ()) {
1259+ this .renderFeatureIconTooltip (guiGraphics , mouseX , mouseY );
1260+ }
12431261 MutableComponent coordinates = accent ("x: %d, z: %d" .formatted (QuartPos .toBlock (this .mouseQuart .x ()), QuartPos .toBlock (this .mouseQuart .z ())));
12441262 OptionalInt optionalBiome = getBiome (this .mouseQuart );
12451263 if (optionalBiome .isPresent ()) {
@@ -1251,6 +1269,33 @@ protected void renderSeedMap(GuiGraphics guiGraphics, int mouseX, int mouseY, fl
12511269 guiGraphics .drawString (this .font , coordinates , HORIZONTAL_PADDING , VERTICAL_PADDING + this .seedMapHeight + 1 , -1 );
12521270 }
12531271
1272+ protected boolean showFeatureIconTooltips () { return true ; }
1273+
1274+ private void renderFeatureIconTooltip (GuiGraphics guiGraphics , int mouseX , int mouseY ) {
1275+ for (FeatureWidget widget : this .featureWidgets ) {
1276+ if (!widget .withinBounds ()) continue ;
1277+ if (widget .isMouseOver (mouseX , mouseY )) {
1278+ java .util .List <net .minecraft .client .gui .screens .inventory .tooltip .ClientTooltipComponent > tooltip = java .util .List .of (net .minecraft .client .gui .screens .inventory .tooltip .ClientTooltipComponent .create (widget .getTooltip ().getVisualOrderText ()));
1279+ int tooltipX = mouseX ;
1280+ int tooltipY = mouseY + this .font .lineHeight + 6 ;
1281+ guiGraphics .renderTooltip (this .font , tooltip , tooltipX , tooltipY , DefaultTooltipPositioner .INSTANCE , null );
1282+ return ;
1283+ }
1284+ }
1285+ }
1286+
1287+ private void renderFeatureToggleTooltip (GuiGraphics guiGraphics , int mouseX , int mouseY ) {
1288+ for (FeatureToggleWidget widget : this .featureToggleWidgets ) {
1289+ if (widget .isMouseOver (mouseX , mouseY )) {
1290+ java .util .List <net .minecraft .client .gui .screens .inventory .tooltip .ClientTooltipComponent > tooltip = java .util .List .of (net .minecraft .client .gui .screens .inventory .tooltip .ClientTooltipComponent .create (widget .getTooltip ().getVisualOrderText ()));
1291+ int tooltipX = mouseX ;
1292+ int tooltipY = mouseY + this .font .lineHeight + 6 ;
1293+ guiGraphics .renderTooltip (this .font , tooltip , tooltipX , tooltipY , DefaultTooltipPositioner .INSTANCE , null );
1294+ return ;
1295+ }
1296+ }
1297+ }
1298+
12541299 protected void drawCenteredPlayerDirectionArrow (GuiGraphics guiGraphics , double centerX , double centerY , double size , float partialTick ) {
12551300 LocalPlayer player = this .minecraft .player ;
12561301 if (player == null ) return ;
@@ -1296,6 +1341,17 @@ protected double getPixelsPerBiome() {
12961341 protected void setPixelsPerBiome (double pixelsPerBiome ) {
12971342 int p = (int ) Math .round (Math .max (MIN_PIXELS_PER_BIOME , Math .min (MAX_PIXELS_PER_BIOME , pixelsPerBiome )));
12981343 Configs .PixelsPerBiome = p ;
1344+ // update widget positions so icons move when zoom changes
1345+ try {
1346+ this .updateAllFeatureWidgetPositions ();
1347+ } catch (Throwable ignored ) {}
1348+ }
1349+
1350+ protected void updateAllFeatureWidgetPositions () {
1351+ if (this .markerWidget != null ) this .markerWidget .updatePosition ();
1352+ for (FeatureWidget w : this .featureWidgets ) {
1353+ try { w .updatePosition (); } catch (Throwable ignored ) {}
1354+ }
12991355 }
13001356
13011357 /* Default hooks for subclasses (minimap overrides some of these) */
0 commit comments