-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChestViewerKeyHandler.java
More file actions
30 lines (25 loc) · 1.14 KB
/
Copy pathChestViewerKeyHandler.java
File metadata and controls
30 lines (25 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package chestviewer;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.util.ChatComponentTranslation;
import org.lwjgl.input.Keyboard;
public class ChestViewerKeyHandler {
static KeyBinding toggleKeyBinding = new KeyBinding(ChestViewer.modid, Keyboard.KEY_P, ChestViewer.modid);
public ChestViewerKeyHandler() {
ClientRegistry.registerKeyBinding(toggleKeyBinding);
}
@SubscribeEvent
public void KeyInputEvent(InputEvent.KeyInputEvent event) {
if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) {
if(toggleKeyBinding.isPressed()) {
ChestViewer.instance.enabled = !ChestViewer.instance.enabled;
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("ChestViewer: " + (ChestViewer.instance.enabled ? "ON" : "OFF")));
}
}
}
}