Skip to content

Commit

Permalink
add stow hotkey (close #319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari023 committed Jan 5, 2025
1 parent f54fc08 commit 501ca2c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Updated Simplified Chinese localization (#315)
- fix restock amount also displaying in stacks in JEI (#318)
- add stow hotkey
2 changes: 2 additions & 0 deletions src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/de/mari_023/ae2wtlib/hotkeys/StowHotkeyAction.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 2 additions & 1 deletion src/main/resources/assets/ae2wtlib/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion src/main/resources/assets/ae2wtlib/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion src/main/resources/assets/ae2wtlib/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 501ca2c

Please sign in to comment.