mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 13:09:53 +00:00
Update ArmorControls.java
Updates for NeK 2.0.1, and in the process fixing https://github.com/mod-warriors/NotEnoughKeys/issues/34 Requires testing.
This commit is contained in:
1 parent
ba18f02e94
commit
74b70e2122
1 file changed
+18
-12
@@ -4,12 +4,13 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import mantle.common.network.AbstractPacket;
|
||||
import modwarriors.notenoughkeys.api.Api;
|
||||
import modwarriors.notenoughkeys.api.KeyBindingPressedEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
@@ -85,30 +86,35 @@ public class ArmorControls {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void mouseEvent(InputEvent.MouseInputEvent event) {
|
||||
if (!Loader.isModLoaded("notenoughkeys"))
|
||||
this.checkKeys();
|
||||
public void mouseEvent(MouseEvent event) {
|
||||
if (!Loader.isModLoaded("notenoughkeys")) this.checkKeys(event.button + 100);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void keyEvent(InputEvent.KeyInputEvent event) {
|
||||
if (!Loader.isModLoaded("notenoughkeys"))
|
||||
this.checkKeys();
|
||||
public void keyEvent(KeyInputEvent event) {
|
||||
if (!Loader.isModLoaded("notenoughkeys")) this.checkKeys(-1);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "notenoughkeys")
|
||||
@SubscribeEvent
|
||||
public void keyEventSpecial(KeyBindingPressedEvent event) {
|
||||
this.keyPressed(event.keyBinding);
|
||||
this.sendPressed(event.keyBinding, event.isKeyBindingPressed);
|
||||
}
|
||||
|
||||
private void checkKeys() {
|
||||
private void checkKeys(int keycode) {
|
||||
for (KeyBinding key : this.keys) {
|
||||
if (key != null && this.isKeyActive(key.getKeyCode())) {
|
||||
this.keyPressed(key);
|
||||
}
|
||||
if (keycode < 0 || key.getKeyCode() == keycode)
|
||||
this.checkKeyAndSendPress(key);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkKeyAndSendPress(KeyBinding key) {
|
||||
this.sendPress(key, this.isKeyActive(key.getKeyCode()));
|
||||
}
|
||||
|
||||
private void sendPress(KeyBinding key, boolean isPressed) {
|
||||
if (isPressed) this.keyPressed(key);
|
||||
}
|
||||
|
||||
private boolean isKeyActive(int keyCode) {
|
||||
if (keyCode < 0)
|
||||
|
||||
Reference in new issue
Block a user