Skip to content

Commit

Permalink
add hotkeys - bump 7.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
aria1th committed Nov 16, 2023
1 parent 95500c3 commit ad36e5b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ org.gradle.jvmargs=-Xmx6G
loader_version=0.14.7

# Mod Properties
mod_version = 7.0.7
mod_version = 7.0.8
maven_group = aria1th.extensions
archives_base_name = litematica-printer
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import com.google.common.collect.ImmutableList;
import fi.dy.masa.litematica.config.Configs;
import fi.dy.masa.litematica.config.Hotkeys;
import fi.dy.masa.malilib.config.IConfigBase;
import fi.dy.masa.malilib.config.options.ConfigBoolean;
import fi.dy.masa.malilib.config.options.ConfigDouble;
import fi.dy.masa.malilib.config.options.ConfigHotkey;
import fi.dy.masa.malilib.config.options.ConfigInteger;
import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage;
import net.fabricmc.api.ModInitializer;

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 @@ -66,6 +70,23 @@ public class LitematicaMixinMod implements ModInitializer {
public static final ConfigBoolean PRINTER_FAKE_ROTATION = new ConfigBoolean("printerFakeRotation", true, "Printer will use fake rotations to place block correctly, at least in vanilla.");
public static final ConfigInteger PRINTER_FAKE_ROTATION_DELAY = new ConfigInteger("printerFakeRotationTicks", 1, 0, 1000000, "Ticks between fake block packets");
public static final ConfigInteger PRINTER_FAKE_ROTATION_LIMIT_PER_TICKS = new ConfigInteger("printerFakeRotationLimitPerTicks", 1, 1, 1000000, "Maximum fake placement per tick, prone to cause error(require:FakeRotationTick = 0)");
public static final ConfigHotkey PRINTER_OFF_HOTKEY = new ConfigHotkey("printerToggleKey", "", "Printer will be toggled ON/OFF");
public static final ConfigHotkey PRINTER_ALLOW_INVENTORY_OPERATIONS_HOTKEY = new ConfigHotkey("printerInventoryOperationsToggleKey", "", "Printer inventory operations will be toggled ON/OFF");
public static final ConfigHotkey PRINTER_BREAK_BLOCKS_HOTKEY = new ConfigHotkey("printerBreakBlocksToggleKey", "", "Printer break blocks will be toggled ON/OFF");
public static final ConfigHotkey PRINTER_CLEAR_FLUIDS_HOTKEY = new ConfigHotkey("printerClearFluidsToggleKey", "", "Printer clear fluids will be toggled ON/OFF");
public static final ConfigHotkey PRINTER_CLEAR_SNOW_LAYER_HOTKEY = new ConfigHotkey("printerClearSnowLayerToggleKey", "", "Printer clear snow layer will be toggled ON/OFF");
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 final ImmutableList<IConfigBase> betterList = originalList.addAll(ImmutableList.of(
VERIFY_INVENTORY,
PRINTER_SHOULD_SWING_HAND,
Expand Down Expand Up @@ -126,6 +147,13 @@ public class LitematicaMixinMod implements ModInitializer {

@Override
public void onInitialize() {
PRINTER_OFF_HOTKEY.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINTER_OFF));
PRINTER_ALLOW_INVENTORY_OPERATIONS_HOTKEY.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINTER_ALLOW_INVENTORY_OPERATIONS));
PRINTER_BREAK_BLOCKS_HOTKEY.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINTER_BREAK_BLOCKS));
PRINTER_CLEAR_FLUIDS_HOTKEY.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINTER_CLEAR_FLUIDS));
PRINTER_CLEAR_SNOW_LAYER_HOTKEY.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINTER_CLEAR_SNOW_LAYER));
PRINTER_CLEAR_FLUIDS_USE_COBBLESTONE_HOTKEY.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINTER_CLEAR_FLUIDS_USE_COBBLESTONE));
PRINTER_BEDROCK_BREAKING_HOTKEY.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINTER_BEDROCK_BREAKING));
System.out.println("[Printer] : YeeFuckinHaw");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@
import com.google.common.collect.ImmutableList;
import fi.dy.masa.litematica.config.Configs;
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 = Configs.class, remap = false)
public class ConfigsMixin {
@Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;"))
private static ImmutableList<IConfigBase> moreOptions() {
return LitematicaMixinMod.betterList;
}

@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;
}

@Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;"))
private static ImmutableList<IConfigBase> moreeOptions() {
return LitematicaMixinMod.betterList;
}

@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;
}
}

0 comments on commit ad36e5b

Please sign in to comment.