diff --git a/CHANGELOG.md b/CHANGELOG.md index ce03a4b0..be1140bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ - Updated Simplified Chinese localization (#315) - fix restock amount also displaying in stacks in JEI (#318) +- add stow hotkey diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java index a3c29c76..8e2ad5fc 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java @@ -20,6 +20,7 @@ import de.mari_023.ae2wtlib.api.registration.WTDefinition; import de.mari_023.ae2wtlib.hotkeys.MagnetHotkeyAction; import de.mari_023.ae2wtlib.hotkeys.RestockHotkeyAction; +import de.mari_023.ae2wtlib.hotkeys.StowHotkeyAction; import de.mari_023.ae2wtlib.wat.WATMenu; import de.mari_023.ae2wtlib.wat.WATMenuHost; import de.mari_023.ae2wtlib.wat.WATScreen; @@ -63,6 +64,7 @@ public static void onAe2Initialized() { HotkeyActions.register(new RestockHotkeyAction(), "ae2wtlib_restock"); HotkeyActions.register(new MagnetHotkeyAction(), "ae2wtlib_magnet"); + HotkeyActions.register(new StowHotkeyAction(), "ae2wtlib_stow"); } static void addToCreativeTab() { diff --git a/src/main/java/de/mari_023/ae2wtlib/hotkeys/StowHotkeyAction.java b/src/main/java/de/mari_023/ae2wtlib/hotkeys/StowHotkeyAction.java new file mode 100644 index 00000000..2aacec2e --- /dev/null +++ b/src/main/java/de/mari_023/ae2wtlib/hotkeys/StowHotkeyAction.java @@ -0,0 +1,31 @@ +package de.mari_023.ae2wtlib.hotkeys; + +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; + +import appeng.api.config.Actionable; +import appeng.api.features.HotkeyAction; +import appeng.api.stacks.AEItemKey; +import appeng.me.helpers.PlayerSource; + +import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; + +public class StowHotkeyAction implements HotkeyAction { + @Override + public boolean run(Player player) { + var handler = CraftingTerminalHandler.getCraftingTerminalHandler(player); + if (!handler.inRange()) + return false; + var stack = player.getItemInHand(InteractionHand.MAIN_HAND); + if (stack.isEmpty()) + return false; + if (handler.getTargetGrid() == null) + return false; + if (stack.isNotReplaceableByPickAction(player, player.getInventory().selected)) + return false; + + stack.setCount(stack.getCount() - (int) handler.getTargetGrid().getStorageService().getInventory() + .insert(AEItemKey.of(stack), stack.getCount(), Actionable.MODULATE, new PlayerSource(player))); + return true; + } +} diff --git a/src/main/resources/assets/ae2wtlib/lang/de_de.json b/src/main/resources/assets/ae2wtlib/lang/de_de.json index 12fd4e7f..d2112bf4 100644 --- a/src/main/resources/assets/ae2wtlib/lang/de_de.json +++ b/src/main/resources/assets/ae2wtlib/lang/de_de.json @@ -45,5 +45,6 @@ "key.ae2.wireless_pattern_access_terminal": "Drahtlose Schablonenkonsole Öffnen", "key.ae2.wireless_pattern_encoding_terminal": "Drahtlose Schnittstellenkonsole Öffnen", "key.ae2.ae2wtlib_restock": "Nachfüllen umschalten", - "key.ae2.ae2wtlib_magnet": "Magnet Karte umschalten" + "key.ae2.ae2wtlib_magnet": "Magnet Karte umschalten", + "key.ae2.ae2wtlib_stow": "Hand in ME System lagern" } diff --git a/src/main/resources/assets/ae2wtlib/lang/en_ud.json b/src/main/resources/assets/ae2wtlib/lang/en_ud.json index 93f1cc12..1ea834a4 100644 --- a/src/main/resources/assets/ae2wtlib/lang/en_ud.json +++ b/src/main/resources/assets/ae2wtlib/lang/en_ud.json @@ -45,5 +45,6 @@ "key.ae2.wireless_pattern_access_terminal": "lɐuᴉɯɹǝ⟘ ssǝɔɔ∀ uɹǝʇʇɐԀ ssǝlǝɹᴉM uǝdO", "key.ae2.wireless_pattern_encoding_terminal": "lɐuᴉɯɹǝ⟘ ƃuᴉpoɔuƎ uɹǝʇʇɐԀ ssǝlǝɹᴉM uǝdO", "key.ae2.ae2wtlib_restock": "ʞɔoʇsǝᴚ ǝlƃƃo⟘", - "key.ae2.ae2wtlib_magnet": "pɹɐƆ ʇǝuƃɐW ǝlƃƃo⟘" + "key.ae2.ae2wtlib_magnet": "pɹɐƆ ʇǝuƃɐW ǝlƃƃo⟘", + "key.ae2.ae2wtlib_stow": "ɯǝʇsʎS ƎW oʇuᴉ puɐɥ uᴉ ʞɔɐʇs ʍoʇS" } diff --git a/src/main/resources/assets/ae2wtlib/lang/en_us.json b/src/main/resources/assets/ae2wtlib/lang/en_us.json index da78a209..af0d7dbb 100644 --- a/src/main/resources/assets/ae2wtlib/lang/en_us.json +++ b/src/main/resources/assets/ae2wtlib/lang/en_us.json @@ -45,5 +45,6 @@ "key.ae2.wireless_pattern_access_terminal": "Open Wireless Pattern Access Terminal", "key.ae2.wireless_pattern_encoding_terminal": "Open Wireless Pattern Encoding Terminal", "key.ae2.ae2wtlib_restock": "Toggle Restock", - "key.ae2.ae2wtlib_magnet": "Toggle Magnet Card" + "key.ae2.ae2wtlib_magnet": "Toggle Magnet Card", + "key.ae2.ae2wtlib_stow": "Stow stack in hand into ME System" }