Jump to content
  • Home
  • Files
  • Docs
Status Updates
  • All Content

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • romangraef

romangraef

Members
 View Profile  See their activity
  • Content Count

    1
  • Joined

    August 19, 2020
  • Last visited

    January 22

Community Reputation

0 Neutral

About romangraef

  • Rank
    Tree Puncher
  1. romangraef romangraef joined the community August 19, 2020
  2. romangraef

    [1.15.2] Keybinding won't trigger in ChestScreen

    romangraef replied to henne90gen's topic in Modder Support

    Disclaimer: I am not an expierenced forge dev, this is just what i found after digging through a bunch of code (aka Minecraft internals). Okay, this is just for future reference, if someone else finds this thread and tries implementing it themselves. For singular events (like an inventory sort) i think subscribing to a `GuiScreenEvent.KeyboardKeyEvent` or even just as `KeyInputEvent` and then checking for keycode and modifiers might be best, but for toggles (like holding a key to show a different UI screen) i found using InputMappings.isKeyDown better. private boolean isKeyBindDown(KeyBinding keyBinding) { if (keyBinding.isKeyDown()) return true; InputMappings.Input key = keyBinding.getKey(); int keyCode = key.getKeyCode(); // GL window handle long handle = Minecraft.getInstance().getMainWindow().getHandle(); return InputMappings.isKeyDown(handle, keyCode) && keyBinding.getKeyModifier().isActive(keyBinding.getKeyConflictContext()); } `InputMappings` is internally used by `KeyModifier#isActive` as well, so im fairly confident that this is at least a somewhat intended path. This should only work with Keyboard Keybinds and not Mousebindings, but i haven't found a way for that yet, and honestly even finding this took way to long. Short addendum after i already wrote most of this: `KeyModifier#isActive` doesn't actually check the passed `IKeyConflictContext` so one should maybe check that it is active, but i think, since this mostly concerns GUIs that should actually be already checked.
    • August 19, 2020
    • 5 replies
  • All Activity
  • Home
  • romangraef
  • Theme

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