Probleme de touche
-
bha …. j’ai l’impressions que le isPressed marche pas quand le gui est ouvert.
public class ClientProxy extends CommonProxy{ public static KeyBinding keyScreen; private int lastKeyState = 0; public ClientProxy() { FMLCommonHandler.instance().bus().register(this); keyScreen = new KeyBinding("Screen", Keyboard.KEY_U, "Ushare"); ClientRegistry.registerKeyBinding(keyScreen); } @SubscribeEvent public void onClientTickEvent(ClientTickEvent event) { if(event.phase == Phase.END) { sendKeyUpdate(); //SendFile sfile = new SendFile("sendfile"); //sfile.start(); } } public void sendKeyUpdate() { int currentKeyState = (keyScreen.isPressed() ? 1 : 0) << 0; if(currentKeyState != this.lastKeyState) { lastKeyState = currentKeyState; System.out.println("ok"); } } } -
Sinon faut faire comme Minecraft :
public void dispatchKeypresses() { int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey(); if (i != 0 && !Keyboard.isRepeatEvent()) { if (!(this.currentScreen instanceof GuiControls) || ((GuiControls)this.currentScreen).time <= getSystemTime() - 20L) { if (Keyboard.getEventKeyState()) { if (i == this.gameSettings.keyBindStreamStartStop.getKeyCode()) { if (this.getTwitchStream().func_152934_n()) { this.getTwitchStream().func_152914_u(); } else if (this.getTwitchStream().func_152924_m()) { this.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() { private static final String __OBFID = "CL_00001852"; public void confirmClicked(boolean result, int id) { if (result) { Minecraft.this.getTwitchStream().func_152930_t(); } Minecraft.this.displayGuiScreen((GuiScreen)null); } }, I18n.format("stream.confirm_start", new Object[0]), "", 0)); } else if (this.getTwitchStream().func_152928_D() && this.getTwitchStream().func_152936_l()) { if (this.theWorld != null) { this.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("Not ready to start streaming yet!")); } } else { GuiStreamUnavailable.func_152321_a(this.currentScreen); } } else if (i == this.gameSettings.keyBindStreamPauseUnpause.getKeyCode()) { if (this.getTwitchStream().func_152934_n()) { if (this.getTwitchStream().isPaused()) { this.getTwitchStream().func_152933_r(); } else { this.getTwitchStream().func_152916_q(); } } } else if (i == this.gameSettings.keyBindStreamCommercials.getKeyCode()) { if (this.getTwitchStream().func_152934_n()) { this.getTwitchStream().func_152931_p(); } } else if (i == this.gameSettings.keyBindStreamToggleMic.getKeyCode()) { this.stream.func_152910_a(true); } else if (i == this.gameSettings.keyBindFullscreen.getKeyCode()) { this.toggleFullscreen(); } else if (i == this.gameSettings.keyBindScreenshot.getKeyCode()) // screenshot ici { this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir, this.displayWidth, this.displayHeight, this.framebufferMc)); } } else if (i == this.gameSettings.keyBindStreamToggleMic.getKeyCode()) { this.stream.func_152910_a(false); } } } } -
c’est ce que j’avais essayer de faire au début
-
Si tu utilises tickEvent + ces 3 conditions :
int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey(); if (i != 0 && !Keyboard.isRepeatEvent()) { if (!(this.currentScreen instanceof GuiControls) || ((GuiControls)this.currentScreen).time <= getSystemTime() - 20L) { if (Keyboard.getEventKeyState())- celle pour ta touche bien sûr
ça donne quoi ?
- celle pour ta touche bien sûr
-
ça marche mais ça spam toujours

-
Et avec un if(Keyboard.next()) en plus ?
-
ça ne marche plus apres je ne sais pas si ou il se trouve dans l’imbrication a de l’importance …
-
C’est bon affaire résulu, je bidouiller dans l’algo, j’ai trouver une solution merci pour votre aide !
-
Poste la solution au cas où quelqu’un en ait besoin

Sent from my GT-I9000 using Tapatalk 2
-
@SubscribeEvent public void onClientTickEvent(ClientTickEvent event) { if(event.phase == Phase.END) { int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey(); if(i != 0 && !Keyboard.isRepeatEvent()) { if(!(mc.currentScreen instanceof GuiControls) || ((GuiControls)mc.currentScreen).time <= Minecraft.getSystemTime() - 20L) { if(Keyboard.getEventKeyState()) { if(i == keyScreen.getKeyCode()) { if(!press) { //Action } } } else { this.press = false; } } } } }press un boolean init a false au début
