User Tools

Site Tools


tutorial:keybinds

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
tutorial:keybinds [2021/02/28 17:23] – Fixed a minor formatting issue sailkitetutorial:keybinds [2022/07/28 18:35] – [Responding to your Keybind] updated with 1.19 changes lightningtow
Line 64: Line 64:
 ==== Responding to your Keybind ==== ==== Responding to your Keybind ====
  
-The code here will print "Key 1 was pressed!" ingame.+The code here will print "Key 1 was pressed!" ingame. Keep note that this is entirely client-side. To have the server respond to a keybind, you'll need to send a custom packet and have the server handle it separately.
  
 +
 +For versions since 1.19:
 +<code java>
 +
 +ClientTickEvents.END_CLIENT_TICK.register(client -> {
 +    while (keyBinding.wasPressed()) {
 + client.player.sendMessage(Text.literal("Key 1 was pressed!"), false);
 +    }
 +});
 +</code>
 +
 +For versions below 1.19:
 <code java> <code java>
  
Line 75: Line 87:
 </code> </code>
      
-Keep note that this is entirely client-side. To have the server respond to a keybind, you'll need to send a custom packet and have the server handle it separately.+
tutorial/keybinds.txt · Last modified: 2023/12/27 13:14 by 2601:188:cb7c:25a0:19fa:9122:4e5a:fad1