Skip to content

Commit

Permalink
add missing mixin for displaying hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
aria1th committed Nov 16, 2023
1 parent ad36e5b commit 1d11f87
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

public class LitematicaMixinMod implements ModInitializer {
public static ImmutableList.Builder<IConfigBase> originalList = new ImmutableList.Builder<IConfigBase>().addAll(Configs.Generic.OPTIONS);
public static ImmutableList.Builder<ConfigHotkey> hotkeyListBuilder = new ImmutableList.Builder<ConfigHotkey>().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.");
Expand Down Expand Up @@ -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<ConfigHotkey> 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<ConfigHotkey> getHotkeyList() {
ImmutableList.Builder<ConfigHotkey> hotkeyList = new ImmutableList.Builder<ConfigHotkey>().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<IConfigBase> betterList = originalList.addAll(ImmutableList.of(
VERIFY_INVENTORY,
PRINTER_SHOULD_SWING_HAND,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private static ImmutableList<IConfigBase> moreOptions() {

@Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;"))
private static List<ConfigHotkey> 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;"))
Expand All @@ -30,6 +30,6 @@ private static ImmutableList<IConfigBase> moreeOptions() {

@Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;"))
private static List<ConfigHotkey> moreeHotkeyOptions() {
return LitematicaMixinMod.hotkeyList;
return LitematicaMixinMod.getHotkeyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<IConfigBase> 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<ConfigHotkey> moreHotkeyOptions() {
return LitematicaMixinMod.getHotkeyList();
}
}

0 comments on commit 1d11f87

Please sign in to comment.