1717package dev .terminalmc .clientsort .client ;
1818
1919import com .mojang .blaze3d .platform .InputConstants ;
20+ import dev .terminalmc .clientsort .client .gui .ControlButtonManager ;
2021import dev .terminalmc .clientsort .client .order .SortOrder ;
2122import dev .terminalmc .clientsort .client .config .Config ;
2223import dev .terminalmc .clientsort .client .network .InteractionManager ;
24+ import dev .terminalmc .clientsort .util .ModLogger ;
2325import net .minecraft .client .KeyMapping ;
2426import net .minecraft .client .Minecraft ;
27+ import net .minecraft .client .gui .screens .Screen ;
2528import net .minecraft .resources .ResourceLocation ;
2629
27- import java .util .ArrayList ;
2830import java .util .List ;
2931
3032import static dev .terminalmc .clientsort .util .Localization .translationKey ;
3133
3234public class ClientSort {
35+ public static final String MOD_ID = dev .terminalmc .clientsort .ClientSort .MOD_ID ;
36+ public static final String MOD_NAME = dev .terminalmc .clientsort .ClientSort .MOD_NAME ;
37+ public static final ModLogger LOG = dev .terminalmc .clientsort .ClientSort .LOG ;
38+
39+ public static final KeyMapping EDIT_KEY = new KeyMapping (
40+ translationKey ("key" , "group.edit" ), InputConstants .Type .KEYSYM ,
41+ InputConstants .UNKNOWN .getValue (), translationKey ("key" , "group" ));
3342 public static final KeyMapping SORT_KEY = new KeyMapping (
34- translationKey ("key" , "group.sort" ), InputConstants .Type .MOUSE ,
43+ translationKey ("key" , "group.op. sort" ), InputConstants .Type .MOUSE ,
3544 InputConstants .MOUSE_BUTTON_MIDDLE , translationKey ("key" , "group" ));
36- public static final KeyMapping TRANSFER_KEY = new KeyMapping (
37- translationKey ("key" , "group.transfer " ), InputConstants .Type .KEYSYM ,
45+ public static final KeyMapping STACK_FILL_KEY = new KeyMapping (
46+ translationKey ("key" , "group.op.stackFill " ), InputConstants .Type .KEYSYM ,
3847 InputConstants .UNKNOWN .getValue (), translationKey ("key" , "group" ));
39- public static final KeyMapping FILL_STACKS_KEY = new KeyMapping (
40- translationKey ("key" , "group.fillStacks " ), InputConstants .Type .KEYSYM ,
48+ public static final KeyMapping TRANSFER_KEY = new KeyMapping (
49+ translationKey ("key" , "group.op.transfer " ), InputConstants .Type .KEYSYM ,
4150 InputConstants .UNKNOWN .getValue (), translationKey ("key" , "group" ));
4251 public static final List <KeyMapping > KEYBINDS = List .of (
52+ EDIT_KEY ,
4353 SORT_KEY ,
44- TRANSFER_KEY ,
45- FILL_STACKS_KEY
54+ STACK_FILL_KEY ,
55+ TRANSFER_KEY
4656 );
4757
48- public static final List <ScheduledAction > SCHEDULED_ACTIONS = new ArrayList <>();
49- public static class ScheduledAction {
50- int ticks ;
51- final Runnable action ;
52-
53- public ScheduledAction (int ticks , Runnable action ) {
54- this .ticks = ticks ;
55- this .action = action ;
56- }
57- }
58+ public static long ticks = 0 ;
5859
5960 public static boolean searchOrderUpdated = false ;
6061
@@ -65,31 +66,24 @@ public static void init() {
6566 Config .getAndSave ();
6667 }
6768
68- public static void onEndTick (Minecraft mc ) {
69- SCHEDULED_ACTIONS .removeIf ((sa ) -> {
70- if (--sa .ticks <= 0 ) {
71- sa .action .run ();
72- return true ;
73- }
74- return false ;
75- });
69+ public static void afterClientTick (Minecraft mc ) {
70+ ticks ++;
71+ }
72+
73+ public static void afterScreenInit (Screen screen ) {
74+ ControlButtonManager .afterScreenInit (screen );
7675 }
7776
7877 public static void onConfigSaved (Config config ) {
7978 Config .Options options = config .options ;
79+ // Convert config sort order strings into enum values
8080 options .sortOrder = SortOrder .SORT_MODES .get (options .sortOrderStr );
8181 options .shiftSortOrder = SortOrder .SORT_MODES .get (options .shiftSortOrderStr );
8282 options .ctrlSortOrder = SortOrder .SORT_MODES .get (options .ctrlSortOrderStr );
8383 options .altSortOrder = SortOrder .SORT_MODES .get (options .altSortOrderStr );
84- options .sortSoundLoc = ResourceLocation .tryParse (options .sortSound );
85- setInteractionManagerTickRate (config .options );
86- }
87-
88- public static void setInteractionManagerTickRate (Config .Options options ) {
89- if (Minecraft .getInstance ().getSingleplayerServer () == null ) {
90- InteractionManager .setTickRate (options .interactionRateServer );
91- } else {
92- InteractionManager .setTickRate (options .interactionRateClient );
93- }
84+ // Parse sound location string
85+ options .sortSoundLoc = ResourceLocation .tryParse (options .interactionSound );
86+ // Update interaction manager tick rate
87+ InteractionManager .setTickRate (options .interactionInterval );
9488 }
9589}
0 commit comments