File tree Expand file tree Collapse file tree
src/main/java/com/mitchej123/hodgepodge Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,6 +149,10 @@ public class FixesConfig {
149149 @ Config .DefaultBoolean (true )
150150 public static boolean fixImmobileFireballs ;
151151
152+ @ Config .Comment ("Fix crash in the controls menu when two keybind categories share the same localized name" )
153+ @ Config .DefaultBoolean (true )
154+ public static boolean fixKeybindCategorySorting ;
155+
152156 @ Config .Comment ("Fix Sugar Cane inability to replace replaceable blocks indirectly." )
153157 @ Config .DefaultBoolean (true )
154158 public static boolean fixSugarCanePlacement ;
Original file line number Diff line number Diff line change @@ -604,6 +604,11 @@ public enum Mixins implements IMixins {
604604 .setApplyIf (() -> FixesConfig .triggerAllConflictingKeybindings )
605605 .addExcludedMod (TargetedMod .MODERNKEYBINDING )
606606 .setPhase (Phase .EARLY )),
607+ FIX_KEYBIND_CATEGORY_SORTING (new MixinBuilder ("Fix controls menu crash on colliding localized category names" )
608+ .addClientMixins ("minecraft.MixinKeyBinding_FixComparison" )
609+ .setApplyIf (() -> FixesConfig .fixKeybindCategorySorting )
610+ .addExcludedMod (TargetedMod .MODERNKEYBINDING )
611+ .setPhase (Phase .EARLY )),
607612 REMOVE_SPAWN_MINECART_SOUND (new MixinBuilder ("Remove sound when spawning a minecart" )
608613 .addClientMixins ("minecraft.MixinWorldClient" )
609614 .setApplyIf (() -> TweaksConfig .removeSpawningMinecartSound )
Original file line number Diff line number Diff line change 1+ package com .mitchej123 .hodgepodge .mixins .early .minecraft ;
2+
3+ import net .minecraft .client .resources .I18n ;
4+ import net .minecraft .client .settings .KeyBinding ;
5+
6+ import org .spongepowered .asm .mixin .Final ;
7+ import org .spongepowered .asm .mixin .Mixin ;
8+ import org .spongepowered .asm .mixin .Overwrite ;
9+ import org .spongepowered .asm .mixin .Shadow ;
10+
11+ @ Mixin (KeyBinding .class )
12+ public class MixinKeyBinding_FixComparison {
13+
14+ @ Shadow
15+ @ Final
16+ private String keyDescription ;
17+ @ Shadow
18+ @ Final
19+ private String keyCategory ;
20+
21+ /**
22+ * @author Algent
23+ * @reason Fix controls menu crash when keybind categories share a localized name which can crash the game.
24+ */
25+ @ Overwrite (remap = false )
26+ public int compareTo (KeyBinding other ) {
27+ final MixinKeyBinding_FixComparison mixinOther = (MixinKeyBinding_FixComparison ) (Object ) other ;
28+ int result = I18n .format (this .keyCategory ).compareTo (I18n .format (mixinOther .keyCategory ));
29+ if (result == 0 ) {
30+ result = this .keyCategory .compareTo (mixinOther .keyCategory );
31+ if (result == 0 ) {
32+ result = I18n .format (this .keyDescription ).compareTo (I18n .format (mixinOther .keyDescription ));
33+ }
34+ }
35+ return result ;
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments