From 1d11f870cf6d2d6e382b8639c4e1ba29841b4c75 Mon Sep 17 00:00:00 2001 From: aria1th <35677394+aria1th@users.noreply.github.com> Date: Fri, 17 Nov 2023 01:49:45 +0900 Subject: [PATCH] add missing mixin for displaying hotkeys --- .../litematicin/LitematicaMixinMod.java | 23 +++++++++++-------- .../mixin/Litematica/ConfigsMixin.java | 4 ++-- .../mixin/Litematica/GuiConfigsMixin.java | 8 +++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/eatmyvenom/litematicin/LitematicaMixinMod.java b/src/main/java/io/github/eatmyvenom/litematicin/LitematicaMixinMod.java index cc65be89..507a8b3f 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/LitematicaMixinMod.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/LitematicaMixinMod.java @@ -13,7 +13,6 @@ public class LitematicaMixinMod implements ModInitializer { public static ImmutableList.Builder originalList = new ImmutableList.Builder().addAll(Configs.Generic.OPTIONS); - public static ImmutableList.Builder hotkeyListBuilder = new ImmutableList.Builder().addAll(Hotkeys.HOTKEY_LIST); public static final ConfigBoolean USE_INVENTORY_CACHE = new ConfigBoolean("printerUseInventoryCache", true, "Uses Inventory cache instead of litematica's inventory utils."); public static final ConfigInteger INVENTORY_CACHE_TICKS = new ConfigInteger("printerInventoryCacheTicks", 20, 0, 100, "Ticks to wait before updating inventory cache."); public static final ConfigBoolean VERIFY_INVENTORY = new ConfigBoolean("verifierFindInventoryContents", true, "Schematic verifier will show blocks with inventory as wrong state."); @@ -78,15 +77,19 @@ public class LitematicaMixinMod implements ModInitializer { public static final ConfigHotkey PRINTER_CLEAR_FLUIDS_USE_COBBLESTONE_HOTKEY = new ConfigHotkey("printerClearFluidsUseCobblestoneToggleKey", "", "Printer clear fluids use cobblestone will be toggled ON/OFF"); public static final ConfigHotkey PRINTER_BEDROCK_BREAKING_HOTKEY = new ConfigHotkey("printerBedrockBreakingToggleKey", "", "Printer bedrock breaking will be toggled ON/OFF"); - public static final ImmutableList hotkeyList = hotkeyListBuilder.addAll(ImmutableList.of( - PRINTER_OFF_HOTKEY, - PRINTER_ALLOW_INVENTORY_OPERATIONS_HOTKEY, - PRINTER_BREAK_BLOCKS_HOTKEY, - PRINTER_CLEAR_FLUIDS_HOTKEY, - PRINTER_CLEAR_SNOW_LAYER_HOTKEY, - PRINTER_CLEAR_FLUIDS_USE_COBBLESTONE_HOTKEY, - PRINTER_BEDROCK_BREAKING_HOTKEY - )).build(); + public static ImmutableList getHotkeyList() { + ImmutableList.Builder hotkeyList = new ImmutableList.Builder().addAll(Hotkeys.HOTKEY_LIST); + hotkeyList.addAll(ImmutableList.of( + PRINTER_OFF_HOTKEY, + PRINTER_ALLOW_INVENTORY_OPERATIONS_HOTKEY, + PRINTER_BREAK_BLOCKS_HOTKEY, + PRINTER_CLEAR_FLUIDS_HOTKEY, + PRINTER_CLEAR_SNOW_LAYER_HOTKEY, + PRINTER_CLEAR_FLUIDS_USE_COBBLESTONE_HOTKEY, + PRINTER_BEDROCK_BREAKING_HOTKEY) + ); + return hotkeyList.build(); + } public static final ImmutableList betterList = originalList.addAll(ImmutableList.of( VERIFY_INVENTORY, PRINTER_SHOULD_SWING_HAND, diff --git a/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/ConfigsMixin.java b/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/ConfigsMixin.java index e954dff4..1dfa26ea 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/ConfigsMixin.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/ConfigsMixin.java @@ -20,7 +20,7 @@ private static ImmutableList moreOptions() { @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) private static List moreHotkeyOptions() { - return LitematicaMixinMod.hotkeyList; + return LitematicaMixinMod.getHotkeyList(); } @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) @@ -30,6 +30,6 @@ private static ImmutableList moreeOptions() { @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) private static List moreeHotkeyOptions() { - return LitematicaMixinMod.hotkeyList; + return LitematicaMixinMod.getHotkeyList(); } } diff --git a/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/GuiConfigsMixin.java b/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/GuiConfigsMixin.java index 25c4fe38..9f0bcc8e 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/GuiConfigsMixin.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/GuiConfigsMixin.java @@ -3,15 +3,23 @@ import com.google.common.collect.ImmutableList; import fi.dy.masa.litematica.gui.GuiConfigs; import fi.dy.masa.malilib.config.IConfigBase; +import fi.dy.masa.malilib.config.options.ConfigHotkey; import io.github.eatmyvenom.litematicin.LitematicaMixinMod; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +import java.util.List; + @Mixin(value = GuiConfigs.class, remap = false) public class GuiConfigsMixin { @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) private ImmutableList moreOptions() { return LitematicaMixinMod.betterList; } + + @Redirect(method="getConfigs", at=@At(value="FIELD", target="Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) + private static List moreHotkeyOptions() { + return LitematicaMixinMod.getHotkeyList(); + } }