mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 07:47:55 +00:00
Add keybinds for every universal terminal (#379)
Co-authored-by: iR3turnZ <ir3turnz@proton.me>
This commit is contained in:
1 parent
95dad4d305
commit
4cf54e7658
2 files changed
+56
-8
No files matched your search
@@ -9,8 +9,10 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.network.CPacketValueConfig;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
@@ -24,13 +26,43 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class KeybindLoader implements Runnable {
|
||||
|
||||
public static KeyBinding openTerminal;
|
||||
public static KeyBinding openCraftingTerminal;
|
||||
public static KeyBinding openLevelTerminal;
|
||||
public static KeyBinding openInterfaceTerminal;
|
||||
public static KeyBinding openPatternTerminal;
|
||||
public static KeyBinding openPatternExTerminal;
|
||||
public static KeyBinding restock;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
openTerminal = new KeyBinding(FluidCraft.MODID + ".key.OpenTerminal", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
|
||||
openCraftingTerminal = new KeyBinding(
|
||||
FluidCraft.MODID + ".key.OpenCraftingTerminal",
|
||||
Keyboard.CHAR_NONE,
|
||||
"itemGroup.ae2fc");
|
||||
openLevelTerminal = new KeyBinding(
|
||||
FluidCraft.MODID + ".key.OpenLevelTerminal",
|
||||
Keyboard.CHAR_NONE,
|
||||
"itemGroup.ae2fc");
|
||||
openInterfaceTerminal = new KeyBinding(
|
||||
FluidCraft.MODID + ".key.OpenInterfaceTerminal",
|
||||
Keyboard.CHAR_NONE,
|
||||
"itemGroup.ae2fc");
|
||||
openPatternTerminal = new KeyBinding(
|
||||
FluidCraft.MODID + ".key.OpenPatternTerminal",
|
||||
Keyboard.CHAR_NONE,
|
||||
"itemGroup.ae2fc");
|
||||
openPatternExTerminal = new KeyBinding(
|
||||
FluidCraft.MODID + ".key.OpenPatternExTerminal",
|
||||
Keyboard.CHAR_NONE,
|
||||
"itemGroup.ae2fc");
|
||||
restock = new KeyBinding(FluidCraft.MODID + ".key.Restock", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
|
||||
ClientRegistry.registerKeyBinding(openTerminal);
|
||||
ClientRegistry.registerKeyBinding(openCraftingTerminal);
|
||||
ClientRegistry.registerKeyBinding(openLevelTerminal);
|
||||
ClientRegistry.registerKeyBinding(openInterfaceTerminal);
|
||||
ClientRegistry.registerKeyBinding(openPatternTerminal);
|
||||
ClientRegistry.registerKeyBinding(openPatternExTerminal);
|
||||
ClientRegistry.registerKeyBinding(restock);
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
@@ -38,29 +70,40 @@ public class KeybindLoader implements Runnable {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
if (openTerminal.isPressed()) {
|
||||
handleOpenTerminalKey();
|
||||
} else if (restock.isPressed()) {
|
||||
handleRestockKey();
|
||||
}
|
||||
handleKeybindings();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onMouseInput(InputEvent.MouseInputEvent event) {
|
||||
handleKeybindings();
|
||||
}
|
||||
|
||||
private void handleKeybindings() {
|
||||
if (openTerminal.isPressed()) {
|
||||
handleOpenTerminalKey();
|
||||
handleOpenTerminalKey(null);
|
||||
} else if (openCraftingTerminal.isPressed()) {
|
||||
handleOpenTerminalKey(UltraTerminalModes.CRAFTING);
|
||||
} else if (openLevelTerminal.isPressed()) {
|
||||
handleOpenTerminalKey(UltraTerminalModes.LEVEL);
|
||||
} else if (openInterfaceTerminal.isPressed()) {
|
||||
handleOpenTerminalKey(UltraTerminalModes.INTERFACE);
|
||||
} else if (openPatternTerminal.isPressed()) {
|
||||
handleOpenTerminalKey(UltraTerminalModes.PATTERN);
|
||||
} else if (openPatternExTerminal.isPressed()) {
|
||||
handleOpenTerminalKey(UltraTerminalModes.PATTERN_EX);
|
||||
} else if (restock.isPressed()) {
|
||||
handleRestockKey();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleOpenTerminalKey() {
|
||||
private void handleOpenTerminalKey(UltraTerminalModes mode) {
|
||||
if (Minecraft.getMinecraft().currentScreen != null) return;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
ImmutablePair<Integer, ItemStack> temp = Util.getUltraWirelessTerm(player);
|
||||
if (temp == null) return;
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(null, true));
|
||||
if (mode != null) ItemWirelessUltraTerminal.setMode(temp.getRight(), mode);
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(mode, true));
|
||||
}
|
||||
|
||||
private void handleRestockKey() {
|
||||
|
||||
@@ -219,6 +219,11 @@ ae2fc.gui.color.StateError=FFFF5555
|
||||
error.unknown=Unknown
|
||||
|
||||
ae2fc.key.OpenTerminal=Open Wireless Universal Terminal
|
||||
ae2fc.key.OpenCraftingTerminal=Open Wireless Universal Crafting Terminal
|
||||
ae2fc.key.OpenLevelTerminal=Open Wireless Universal Level Terminal
|
||||
ae2fc.key.OpenInterfaceTerminal=Open Wireless Universal Interface Terminal
|
||||
ae2fc.key.OpenPatternTerminal=Open Wireless Universal Pattern Terminal
|
||||
ae2fc.key.OpenPatternExTerminal=Open Wireless Universal Processing Pattern Terminal
|
||||
ae2fc.key.Restock=Toggle Restock
|
||||
|
||||
itemGroup.ae2fc=Fluid Craft For AE2
|
||||
|
||||
Reference in new issue
Block a user