Document KeyBinding.isPressed and KeyBinding.wasPressed (#2393)

* Document KeyBinding.isPressed and KeyBinding.wasPressed

* Apply suggestions from code review

Co-authored-by: liach <7806504+liach@users.noreply.github.com>

Co-authored-by: liach <7806504+liach@users.noreply.github.com>
This commit is contained in:
enbrain 2021-05-13 15:10:36 +09:00 committed by GitHub
parent 4e9beace48
commit 4f1bb0a391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -51,9 +51,33 @@ CLASS net/minecraft/class_304 net/minecraft/client/option/KeyBinding
METHOD method_1433 matchesMouse (I)Z
ARG 1 code
METHOD method_1434 isPressed ()Z
COMMENT {@return if the key is being held down}
COMMENT
COMMENT <p>Note that if you are continuously calling this method (like every
COMMENT tick), it doesn't always catch all key presses. This is because the key
COMMENT can be pressed and released before the next check.
COMMENT
COMMENT @see #wasPressed()
METHOD method_1435 equals (Lnet/minecraft/class_304;)Z
ARG 1 other
METHOD method_1436 wasPressed ()Z
COMMENT {@return if the key was pressed}
COMMENT
COMMENT <p>A key binding counts the number of times the key is pressed. This
COMMENT method "consumes" it and returns {@code true} as many times as the key
COMMENT is pressed.
COMMENT
COMMENT <p>To consume all remaining key presses, while-loop idiom can be used:
COMMENT <pre>
COMMENT {@code
COMMENT while(keyBinding.wasPressed()) {
COMMENT // do your action
COMMENT }
COMMENT }
COMMENT </pre>
COMMENT
COMMENT @see #isPressed()
COMMENT @see <a href="https://bugs.mojang.com/browse/MC-118107">MC-118107</a>
METHOD method_1437 unpressAll ()V
METHOD method_16007 getBoundKeyLocalizedText ()Lnet/minecraft/class_2561;
METHOD method_23481 setPressed (Z)V