11package org .taichiserver .taichitweaks .config ;
22
33import fi .dy .masa .malilib .config .IConfigBoolean ;
4+ import fi .dy .masa .malilib .config .options .ConfigBoolean ;
5+ import fi .dy .masa .malilib .config .options .ConfigBooleanHotkeyed ;
46import fi .dy .masa .malilib .gui .GuiBase ;
57import fi .dy .masa .malilib .hotkeys .IHotkeyCallback ;
68import fi .dy .masa .malilib .hotkeys .IKeybind ;
79import fi .dy .masa .malilib .hotkeys .KeyAction ;
8- import fi .dy .masa .malilib .util .InfoUtils ;
9- import fi .dy .masa .malilib .util .StringUtils ;
10- import fi .dy .masa .minihud .util .DataStorage ;
10+ import fi .dy .masa .malilib .interfaces .IValueChangeCallback ;
1111import net .minecraft .client .MinecraftClient ;
12- import net .minecraft .util .math .BlockPos ;
1312import org .taichiserver .taichitweaks .features .AimAngle ;
14- import org .taichiserver .taichitweaks .features .OverlayRendererBeaconRange ;
1513
1614public class ConfigCallbacks {
1715 public static void init () {
18- Callbacks callback = new Callbacks ();
16+ HotkeyCallbacks hotkeyCallback = new HotkeyCallbacks ();
1917
20- Configs .Hotkeys .OPEN_CONFIG_GUI .getKeybind ().setCallback (callback );
21- Configs .Hotkeys .SNAPAIM_ANGLE1_KEYBIND .getKeybind ().setCallback (callback );
22- Configs .Hotkeys .SNAPAIM_ANGLE2_KEYBIND .getKeybind ().setCallback (callback );
23- Configs .Hotkeys .SNAPAIM_ANGLE3_KEYBIND .getKeybind ().setCallback (callback );
24- Configs .Hotkeys .SNAPAIM_ANGLE4_KEYBIND .getKeybind ().setCallback (callback );
18+ Configs .Generic .AUTOFILL_SCHEMATIC_INVENTORY .getKeybind ().setCallback (hotkeyCallback );
19+ Configs .Generic .AUTO_VOID_TRADE .getKeybind ().setCallback (hotkeyCallback );
20+ Configs .Generic .SCHEMATIC_BLOCK_PLACEMENT_RESTRICTION_SMART_CHECK .getKeybind ().setCallback (hotkeyCallback );
2521
26- Configs .Renders .OVERLAY_LIGHTNING_ROD_COLOR .setValueChangeCallback ((config ) -> OverlayRendererBeaconRange .INSTANCE .setNeedsUpdate ());
27- Configs .Renders .OVERLAY_LIGHTNING_ROD_RANGE .setValueChangeCallback (RendererCallbacks ::onBeaconRangeToggled );
22+ Configs .Hotkeys .OPEN_CONFIG_GUI .getKeybind ().setCallback (hotkeyCallback );
23+ Configs .Hotkeys .SNAPAIM_ANGLE1_KEYBIND .getKeybind ().setCallback (hotkeyCallback );
24+ Configs .Hotkeys .SNAPAIM_ANGLE2_KEYBIND .getKeybind ().setCallback (hotkeyCallback );
25+ Configs .Hotkeys .SNAPAIM_ANGLE3_KEYBIND .getKeybind ().setCallback (hotkeyCallback );
26+ Configs .Hotkeys .SNAPAIM_ANGLE4_KEYBIND .getKeybind ().setCallback (hotkeyCallback );
27+
28+ Configs .Fixes .GAMMA_OVERRIDE_FIX .getKeybind ().setCallback (hotkeyCallback );
29+
30+ Configs .Disables .DISABLE_MASSCRAFT_PLAYER_INVENTORY .getKeybind ().setCallback (hotkeyCallback );
31+
32+ // Configs.Renders.OVERLAY_LIGHTNING_ROD_COLOR.setValueChangeCallback((config) -> OverlayRendererBeaconRange.INSTANCE.setNeedsUpdate());
33+ // Configs.Renders.OVERLAY_LIGHTNING_ROD_RANGE.setValueChangeCallback(RendererCallbacks::onBeaconRangeToggled);
2834 }
2935
30- public static class Callbacks implements IHotkeyCallback {
36+ public static class HotkeyCallbacks implements IHotkeyCallback {
3137 @ Override
3238 public boolean onKeyAction (KeyAction action , IKeybind key ) {
3339 MinecraftClient mc = MinecraftClient .getInstance ();
@@ -48,30 +54,49 @@ public boolean onKeyAction(KeyAction action, IKeybind key) {
4854 } else if (key == Configs .Hotkeys .SNAPAIM_ANGLE4_KEYBIND .getKeybind ()) {
4955 AimAngle .init (mc .player , Configs .Generic .SNAPAIM_ANGLE4 .getStringValue ());
5056 return true ;
57+ } else if (key == Configs .Generic .AUTOFILL_SCHEMATIC_INVENTORY .getKeybind ()) {
58+ valueChange (Configs .Generic .AUTOFILL_SCHEMATIC_INVENTORY );
59+ return true ;
60+ } else if (key == Configs .Generic .AUTO_VOID_TRADE .getKeybind ()) {
61+ valueChange (Configs .Generic .AUTO_VOID_TRADE );
62+ return true ;
63+ } else if (key == Configs .Generic .SCHEMATIC_BLOCK_PLACEMENT_RESTRICTION_SMART_CHECK .getKeybind ()) {
64+ valueChange (Configs .Generic .SCHEMATIC_BLOCK_PLACEMENT_RESTRICTION_SMART_CHECK );
65+ return true ;
66+ } else if (key == Configs .Fixes .GAMMA_OVERRIDE_FIX .getKeybind ()) {
67+ valueChange (Configs .Fixes .GAMMA_OVERRIDE_FIX );
68+ return true ;
69+ } else if (key == Configs .Disables .DISABLE_MASSCRAFT_PLAYER_INVENTORY .getKeybind ()) {
70+ valueChange (Configs .Disables .DISABLE_MASSCRAFT_PLAYER_INVENTORY );
71+ return true ;
5172 }
5273 return false ;
5374 }
5475 }
5576
56- public static class RendererCallbacks {
57- public static void onSpawnChunksRealToggled (IConfigBoolean config ) {
58- if (config .getBooleanValue ()) {
59-
60- BlockPos spawn = DataStorage .getInstance ().getWorldSpawn ();
61- String green = GuiBase .TXT_GREEN ;
62- String rst = GuiBase .TXT_RST ;
63- String strStatus = green + StringUtils .translate ("malilib.message.value.on" ) + rst ;
64- String strPos = String .format ("x: %d, y: %d, z: %d" , spawn .getX (), spawn .getY (), spawn .getZ ());
65- String message = StringUtils .translate ("minihud.message.toggled_using_world_spawn" , config .getPrettyName (), strStatus , strPos );
66-
67- InfoUtils .printActionbarMessage (message );
68- }
69- }
70-
71- public static void onBeaconRangeToggled (IConfigBoolean config ) {
72- if (config .getBooleanValue ()) {
73- OverlayRendererBeaconRange .INSTANCE .setNeedsUpdate ();
74- }
75- }
77+ public static void valueChange (ConfigBoolean config ) {
78+ config .setBooleanValue (!config .getBooleanValue ());
7679 }
80+
81+ // public static class RendererCallbacks {
82+ // public static void onSpawnChunksRealToggled(IConfigBoolean config) {
83+ // if (config.getBooleanValue()) {
84+ //
85+ // BlockPos spawn = DataStorage.getInstance().getWorldSpawn();
86+ // String green = GuiBase.TXT_GREEN;
87+ // String rst = GuiBase.TXT_RST;
88+ // String strStatus = green + StringUtils.translate("malilib.message.value.on") + rst;
89+ // String strPos = String.format("x: %d, y: %d, z: %d", spawn.getX(), spawn.getY(), spawn.getZ());
90+ // String message = StringUtils.translate("minihud.message.toggled_using_world_spawn", config.getPrettyName(), strStatus, strPos);
91+ //
92+ // InfoUtils.printActionbarMessage(message);
93+ // }
94+ // }
95+ //
96+ // public static void onBeaconRangeToggled(IConfigBoolean config) {
97+ // if (config.getBooleanValue()) {
98+ // OverlayRendererBeaconRange.INSTANCE.setNeedsUpdate();
99+ // }
100+ // }
101+ // }
77102}
0 commit comments