1515import com .terraformersmc .modmenu .util .mod .Mod ;
1616import com .terraformersmc .modmenu .util .mod .ModBadgeRenderer ;
1717import net .fabricmc .loader .api .FabricLoader ;
18+ import net .minecraft .SharedConstants ;
1819import net .minecraft .client .gui .DrawContext ;
1920import net .minecraft .client .gui .screen .ConfirmLinkScreen ;
2021import net .minecraft .client .gui .screen .ConfirmScreen ;
2829import net .minecraft .screen .ScreenTexts ;
2930import net .minecraft .text .StringVisitable ;
3031import net .minecraft .text .Text ;
31- import net .minecraft .util .Formatting ;
32- import net .minecraft .util .Identifier ;
33- import net .minecraft .util .Language ;
34- import net .minecraft .util .Util ;
32+ import net .minecraft .util .*;
3533import org .jetbrains .annotations .Nullable ;
3634import org .slf4j .Logger ;
3735import org .slf4j .LoggerFactory ;
@@ -83,6 +81,9 @@ public class ModsScreen extends Screen {
8381 public final Map <String , Boolean > modHasConfigScreen = new HashMap <>();
8482 public final Map <String , Throwable > modScreenErrors = new HashMap <>();
8583
84+ private static final Text SEND_FEEDBACK_TEXT = Text .translatable ("menu.sendFeedback" );
85+ private static final Text REPORT_BUGS_TEXT = Text .translatable ("menu.reportBugs" );
86+
8687 public ModsScreen (Screen previousScreen ) {
8788 super (ModMenuScreenTexts .TITLE );
8889 this .previousScreen = previousScreen ;
@@ -108,7 +109,9 @@ protected void init() {
108109 Screen configScreen = ModMenu .getConfigScreen (id , this );
109110 modHasConfigScreen .put (id , configScreen != null );
110111 } catch (java .lang .NoClassDefFoundError e ) {
111- LOGGER .warn ("The '" + id + "' mod config screen is not available because " + e .getLocalizedMessage () + " is missing." );
112+ LOGGER .warn (
113+ "The '" + id + "' mod config screen is not available because " + e .getLocalizedMessage () +
114+ " is missing." );
112115 modScreenErrors .put (id , e );
113116 modHasConfigScreen .put (id , false );
114117 } catch (Throwable e ) {
@@ -166,8 +169,7 @@ protected void init() {
166169 this .updateFiltersX ();
167170
168171 if (!ModMenuConfig .CONFIG_MODE .getValue ()) {
169- this .filtersButton = LegacyTexturedButtonWidget .legacyTexturedBuilder (
170- ModMenuScreenTexts .TOGGLE_FILTER_OPTIONS ,
172+ this .filtersButton = LegacyTexturedButtonWidget .legacyTexturedBuilder (ModMenuScreenTexts .TOGGLE_FILTER_OPTIONS ,
171173 button -> {
172174 this .setFilterOptionsShown (!this .filterOptionsShown );
173175 }
@@ -221,12 +223,15 @@ protected void init() {
221223
222224 this .websiteButton = ButtonWidget .builder (ModMenuScreenTexts .WEBSITE , button -> {
223225 final Mod mod = Objects .requireNonNull (selected ).getMod ();
224- this .client .setScreen (new ConfirmLinkScreen (confirmed -> {
225- if (confirmed ) {
226- Util .getOperatingSystem ().open (mod .getWebsite ());
227- }
228- this .client .setScreen (this );
229- }, mod .getWebsite (), false ));
226+ boolean isMinecraft = selected .getMod ().getId ().equals ("minecraft" );
227+
228+ if (isMinecraft ) {
229+ var url = SharedConstants .getGameVersion ().isStable () ? Urls .JAVA_FEEDBACK : Urls .SNAPSHOT_FEEDBACK ;
230+ ConfirmLinkScreen .open (this , url , true );
231+ } else {
232+ var url = mod .getWebsite ();
233+ ConfirmLinkScreen .open (this , url , false );
234+ }
230235 })
231236 .position (this .rightPaneX + (urlButtonWidths / 2 ) - (cappedButtonWidth / 2 ), RIGHT_PANE_Y + 36 )
232237 .size (Math .min (urlButtonWidths , 200 ), 20 )
@@ -235,12 +240,14 @@ protected void init() {
235240 // Issues button
236241 this .issuesButton = ButtonWidget .builder (ModMenuScreenTexts .ISSUES , button -> {
237242 final Mod mod = Objects .requireNonNull (selected ).getMod ();
238- this .client .setScreen (new ConfirmLinkScreen (confirmed -> {
239- if (confirmed ) {
240- Util .getOperatingSystem ().open (mod .getIssueTracker ());
241- }
242- this .client .setScreen (this );
243- }, mod .getIssueTracker (), false ));
243+ boolean isMinecraft = selected .getMod ().getId ().equals ("minecraft" );
244+
245+ if (isMinecraft ) {
246+ ConfirmLinkScreen .open (this , Urls .SNAPSHOT_BUGS , true );
247+ } else {
248+ var url = mod .getIssueTracker ();
249+ ConfirmLinkScreen .open (this , url , false );
250+ }
244251 })
245252 .position (this .rightPaneX + urlButtonWidths + 4 + (urlButtonWidths / 2 ) - (cappedButtonWidth / 2 ),
246253 RIGHT_PANE_Y + 36
@@ -300,10 +307,8 @@ protected void init() {
300307
301308 @ Override
302309 public boolean keyPressed (int keyCode , int scanCode , int modifiers ) {
303- return super .keyPressed (keyCode , scanCode , modifiers ) || this .searchBox .keyPressed (keyCode ,
304- scanCode ,
305- modifiers
306- );
310+ return super .keyPressed (keyCode , scanCode , modifiers ) ||
311+ this .searchBox .keyPressed (keyCode , scanCode , modifiers );
307312 }
308313
309314 @ Override
@@ -340,7 +345,8 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
340345 Text fullModCount = this .computeModCountText (true );
341346 if (!ModMenuConfig .CONFIG_MODE .getValue () && this .updateFiltersX ()) {
342347 if (this .filterOptionsShown ) {
343- if (!ModMenuConfig .SHOW_LIBRARIES .getValue () || textRenderer .getWidth (fullModCount ) <= this .filtersX - 5 ) {
348+ if (!ModMenuConfig .SHOW_LIBRARIES .getValue () ||
349+ textRenderer .getWidth (fullModCount ) <= this .filtersX - 5 ) {
344350 DrawContext .drawText (textRenderer ,
345351 fullModCount .asOrderedText (),
346352 this .searchBoxX ,
@@ -365,7 +371,8 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
365371 );
366372 }
367373 } else {
368- if (!ModMenuConfig .SHOW_LIBRARIES .getValue () || textRenderer .getWidth (fullModCount ) <= modList .getWidth () - 5 ) {
374+ if (!ModMenuConfig .SHOW_LIBRARIES .getValue () ||
375+ textRenderer .getWidth (fullModCount ) <= modList .getWidth () - 5 ) {
369376 DrawContext .drawText (textRenderer ,
370377 fullModCount .asOrderedText (),
371378 this .searchBoxX ,
@@ -409,8 +416,7 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
409416 int maxNameWidth = this .width - (x + imageOffset );
410417 if (textRenderer .getWidth (name ) > maxNameWidth ) {
411418 StringVisitable ellipsis = StringVisitable .plain ("..." );
412- trimmedName = StringVisitable .concat (textRenderer .trimToWidth (
413- name ,
419+ trimmedName = StringVisitable .concat (textRenderer .trimToWidth (name ,
414420 maxNameWidth - textRenderer .getWidth (ellipsis )
415421 ), ellipsis );
416422 }
@@ -421,12 +427,14 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
421427 0xFFFFFF ,
422428 true
423429 );
424- if (mouseX > x + imageOffset && mouseY > RIGHT_PANE_Y + 1 && mouseY < RIGHT_PANE_Y + 1 + textRenderer .fontHeight && mouseX < x + imageOffset + textRenderer .getWidth (
425- trimmedName )) {
430+ if (mouseX > x + imageOffset && mouseY > RIGHT_PANE_Y + 1 &&
431+ mouseY < RIGHT_PANE_Y + 1 + textRenderer .fontHeight &&
432+ mouseX < x + imageOffset + textRenderer .getWidth (trimmedName )) {
426433 this .setTooltip (ModMenuScreenTexts .modIdTooltip (mod .getId ()));
427434 }
428435 if (this .init || modBadgeRenderer == null || modBadgeRenderer .getMod () != mod ) {
429- modBadgeRenderer = new ModBadgeRenderer (x + imageOffset + this .client .textRenderer .getWidth (trimmedName ) + 2 ,
436+ modBadgeRenderer = new ModBadgeRenderer (
437+ x + imageOffset + this .client .textRenderer .getWidth (trimmedName ) + 2 ,
430438 RIGHT_PANE_Y ,
431439 width - 28 ,
432440 selectedEntry .mod ,
@@ -528,13 +536,13 @@ public ModListEntry getSelectedEntry() {
528536 public void updateSelectedEntry (ModListEntry entry ) {
529537 if (entry != null ) {
530538 this .selected = entry ;
539+ String modId = selected .getMod ().getId ();
531540
532541 if (this .configureButton != null ) {
533- String modId = selected .getMod ().getId ();
534542
535543 this .configureButton .active = modHasConfigScreen .get (modId );
536- this .configureButton .visible = selected != null && modHasConfigScreen . get ( modId ) || modScreenErrors . containsKey (
537- modId );
544+ this .configureButton .visible =
545+ selected != null && modHasConfigScreen . get ( modId ) || modScreenErrors . containsKey ( modId );
538546
539547 if (modScreenErrors .containsKey (modId )) {
540548 Throwable e = modScreenErrors .get (modId );
@@ -544,11 +552,21 @@ public void updateSelectedEntry(ModListEntry entry) {
544552 }
545553 }
546554
555+ var isMinecraft = modId .equals ("minecraft" );
556+
557+ if (isMinecraft ) {
558+ this .websiteButton .setMessage (SEND_FEEDBACK_TEXT );
559+ this .issuesButton .setMessage (REPORT_BUGS_TEXT );
560+ } else {
561+ this .websiteButton .setMessage (ModMenuScreenTexts .WEBSITE );
562+ this .issuesButton .setMessage (ModMenuScreenTexts .ISSUES );
563+ }
564+
547565 this .websiteButton .visible = true ;
548- this .websiteButton .active = selected .getMod ().getWebsite () != null ;
566+ this .websiteButton .active = isMinecraft || selected .getMod ().getWebsite () != null ;
549567
550568 this .issuesButton .visible = true ;
551- this .issuesButton .active = selected .getMod ().getIssueTracker () != null ;
569+ this .issuesButton .active = isMinecraft || selected .getMod ().getIssueTracker () != null ;
552570 }
553571 }
554572
@@ -565,8 +583,10 @@ public String getSearchInput() {
565583 }
566584
567585 private boolean updateFiltersX () {
568- if ((this .filtersWidth + textRenderer .getWidth (this .computeModCountText (true )) + 20 ) >= this .searchRowWidth && ((this .filtersWidth + textRenderer .getWidth (
569- computeModCountText (false )) + 20 ) >= this .searchRowWidth || (this .filtersWidth + textRenderer .getWidth (this .computeLibraryCountText ()) + 20 ) >= this .searchRowWidth )) {
586+ if ((this .filtersWidth + textRenderer .getWidth (this .computeModCountText (true )) + 20 ) >= this .searchRowWidth &&
587+ ((this .filtersWidth + textRenderer .getWidth (computeModCountText (false )) + 20 ) >= this .searchRowWidth ||
588+ (this .filtersWidth + textRenderer .getWidth (this .computeLibraryCountText ()) + 20 ) >= this .searchRowWidth
589+ )) {
570590 this .filtersX = this .paneWidth / 2 - this .filtersWidth / 2 ;
571591 return !filterOptionsShown ;
572592 } else {
0 commit comments