Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.4] Detect keypress only once
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Maciej916

[1.14.4] Detect keypress only once

By Maciej916, November 14 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Maciej916    0

Maciej916

Maciej916    0

  • Tree Puncher
  • Maciej916
  • Members
  • 0
  • 25 posts
Posted November 14

Hello I want to detect key press only once but when i use InputEvent.KeyInputEvents it detect press and hold. How can I detect keypress only once?

 

    @SubscribeEvent
    public static void clientKeyInput(InputEvent.KeyInputEvent event) {

    }

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45708 posts
Posted November 14

You should use a key binding.

  • Quote

Share this post


Link to post
Share on other sites

Maciej916    0

Maciej916

Maciej916    0

  • Tree Puncher
  • Maciej916
  • Members
  • 0
  • 25 posts
Posted November 14 (edited)

Where i can find any useful information how to do that? (I want to use already existing key for jump)

Edited November 14 by Maciej916
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45708 posts
Posted November 14
16 minutes ago, Maciej916 said:

I want to use already existing key for jump

In this case the key binding already exists, look at the GameSettings class, which is where Minecraft stores it's key bindings.

  • Quote

Share this post


Link to post
Share on other sites

Maciej916    0

Maciej916

Maciej916    0

  • Tree Puncher
  • Maciej916
  • Members
  • 0
  • 25 posts
Posted November 14

I already found that mc.gameSettings.keyBindJump there is a method isPressed() that should fire only once. But the porblem is how to handle this, because when i use event  KeyInputEvent i get true every tick.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45708 posts
Posted November 14

What are you trying to achieve, exactly?

  • Quote

Share this post


Link to post
Share on other sites

Maciej916    0

Maciej916

Maciej916    0

  • Tree Puncher
  • Maciej916
  • Members
  • 0
  • 25 posts
Posted November 14

Im making something like double jump and the thing is that it conflict with jumping when player holds space it fire multiple times. So I wanted to make it so player need to press space again to fire multi jump.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45708 posts
Posted November 14

Look at how Minecraft handles the double-tap to sprint functionality (search for GameSettings#keyBindSprint).

  • Quote

Share this post


Link to post
Share on other sites

Maciej916    0

Maciej916

Maciej916    0

  • Tree Puncher
  • Maciej916
  • Members
  • 0
  • 25 posts
Posted November 14

I'll check that but for now i managed to fix this by using capability and set it to true/false when space is pressed.

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Yanny7
      [1.14.4] TileEntityItemStackSpecialRenderer (TEISR)

      By Yanny7 · Posted 12 minutes ago

      you can check there how I does it: https://github.com/yanny7/StoneAge/blob/c9351e8050f6121256d587112a9f6071dbb61b11/src/main/java/com/yanny/age/stone/subscribers/BlockSubscriber.java#L57 it is working also for server side
    • diesieben07
      [1.14.4] Sync ItemStack Capability Data + Multi-Capability Provider casting error

      By diesieben07 · Posted 24 minutes ago

      ItemStack Capability data that you need on the client needs to be put in the share tag. Override Item#getShareTag and Item#readShareTag.
    • Barca
      cant use mods in survival 1.12.2

      By Barca · Posted 24 minutes ago

      Hi I download and setup mc forge server 1.12.2 and download some mods (tinkers construct, mekanism), but in survival i cannot use this mods - I follow everythig in this tut (and some others) only did not set port forwarding (because my first instaled  1.14 server work with this, I use server only on LAN) I have forge server for 1.14 (folow same videos) and mods like xeros mini/map, corpse, just enough items, and It works perfectly. But in when I join to 1.12 server I can see mod items in creative mode, but when have some in inventory and click on crafting table they dissapear, game did not give me book at start and I cannot craft things from mod. I tried play singleplayer with these mods and works fine. This means I have some problem in server - I see server with "V" (hover - vanilla server) in mc multiplayer list. Can it be this problem? I did not find how "unset" vanilla from minecraft server. Sorry for my english I hope it is possible to understand.  
    • DaemonUmbra
      Forge 28.1.10 won't show on launcher + 28.1.0 fails to work

      By DaemonUmbra · Posted 57 minutes ago

      Where are you looking in the launcher? I suspect you are looking at Profiles/Installations rather than Versions
    • Simon_kungen
      [1.14.4] Sync ItemStack Capability Data + Multi-Capability Provider casting error

      By Simon_kungen · Posted 1 hour ago

      So yeah... looks like none of my questions has been answered lately. Should I give up on capabilities for now?
  • Topics

    • Simon_kungen
      4
      [1.14.4] TileEntityItemStackSpecialRenderer (TEISR)

      By Simon_kungen
      Started Saturday at 02:50 PM

    • Simon_kungen
      2
      [1.14.4] Sync ItemStack Capability Data + Multi-Capability Provider casting error

      By Simon_kungen
      Started 23 hours ago

    • Barca
      0
      cant use mods in survival 1.12.2

      By Barca
      Started 24 minutes ago

    • TheGreenSquarez
      4
      Forge 28.1.10 won't show on launcher + 28.1.0 fails to work

      By TheGreenSquarez
      Started Yesterday at 11:21 AM

    • DragonITA
      33
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

  • Who's Online (See full list)

    • Legenes
    • Yanny7
    • Simon_kungen
    • tday93
    • Barca
    • brokenmaxXX
    • diesieben07
    • nachillodr
    • Oliviafrostpaw
    • solitone
    • adal2k
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.4] Detect keypress only once
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community