mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 01:25:04 +00:00
1st commit
This commit is contained in:
1 parent
a7f00c1830
commit
e37a24a861
35 files changed
+1522
-71
No files matched your search
@@ -4,11 +4,15 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
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.CPacketValueConfig;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
@@ -22,11 +26,14 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class KeybindLoader implements Runnable {
|
||||
|
||||
public static KeyBinding openTerminal;
|
||||
public static KeyBinding restock;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
openTerminal = new KeyBinding("key.OpenTerminal", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
|
||||
openTerminal = new KeyBinding(FluidCraft.MODID + ".key.OpenTerminal", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
|
||||
restock = new KeyBinding(FluidCraft.MODID + ".key.Restock", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
|
||||
ClientRegistry.registerKeyBinding(openTerminal);
|
||||
ClientRegistry.registerKeyBinding(restock);
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@@ -35,6 +42,8 @@ public class KeybindLoader implements Runnable {
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
if (openTerminal.isPressed()) {
|
||||
handleOpenTerminalKey();
|
||||
} else if (restock.isPressed()) {
|
||||
handleRestockKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +52,8 @@ public class KeybindLoader implements Runnable {
|
||||
public void onMouseInput(InputEvent.MouseInputEvent event) {
|
||||
if (openTerminal.isPressed()) {
|
||||
handleOpenTerminalKey();
|
||||
} else if (restock.isPressed()) {
|
||||
handleRestockKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +71,23 @@ public class KeybindLoader implements Runnable {
|
||||
((ItemWirelessUltraTerminal) term.getRight().getItem()).guiGuiType(term.getRight()));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRestockKey() {
|
||||
if (Minecraft.getMinecraft().currentScreen != null) return;
|
||||
EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer;
|
||||
if (p.openContainer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(p);
|
||||
if (term != null) {
|
||||
p.addChatMessage(
|
||||
new ChatComponentText(
|
||||
NameConst.i18n(
|
||||
!Util.isRestock(term.getRight()) ? NameConst.TT_ULTRA_TERMINAL_RESTOCK_ON
|
||||
: NameConst.TT_ULTRA_TERMINAL_RESTOCK_OFF)));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(0, 1));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user