88
99import com .google .common .collect .Maps ;
1010
11+ import de .scribble .lp .tasmod .ClientProxy ;
1112import net .minecraft .client .Minecraft ;
1213import net .minecraft .client .gui .GuiChat ;
1314import net .minecraft .client .gui .GuiControls ;
@@ -31,7 +32,6 @@ public class VirtualKeybindings {
3132 private static long cooldown = 20 ;
3233 private static HashMap <KeyBinding , Long > cooldownHashMap = Maps .<KeyBinding , Long >newHashMap ();
3334 private static List <KeyBinding > blockedKeys = new ArrayList <>();
34- private static List <KeyBinding > blockedDuringRecordingKeys = new ArrayList <>();
3535 private static long cooldowntimer = 0 ;
3636 public static boolean focused = false ;
3737
@@ -45,7 +45,10 @@ public static void increaseCooldowntimer() {
4545 * @return
4646 */
4747 public static boolean isKeyDown (KeyBinding keybind ) {
48- boolean down = Keyboard .isKeyDown (keybind .getKeyCode ());
48+
49+ int keycode =keybind .getKeyCode ();
50+ boolean down = isKeyCodeAlwaysBlocked (keycode ) ? Keyboard .isKeyDown (keycode ) : ClientProxy .virtual .willKeyBeDown (keycode );
51+
4952 if (down ) {
5053 if (cooldownHashMap .containsKey (keybind )) {
5154 if (cooldown <= cooldowntimer - (long ) cooldownHashMap .get (keybind )) {
@@ -73,22 +76,7 @@ public static boolean isKeyDownExceptTextfield(KeyBinding keybind) {
7376 if (mc .currentScreen instanceof GuiChat || mc .currentScreen instanceof GuiEditSign || (focused && mc .currentScreen != null ) || mc .currentScreen instanceof GuiControls ) {
7477 return false ;
7578 }
76- boolean down = Keyboard .isKeyDown (keybind .getKeyCode ());
77- if (down ) {
78- if (cooldownHashMap .containsKey (keybind )) {
79- if (cooldown <= cooldowntimer - (long ) cooldownHashMap .get (keybind )) {
80- cooldownHashMap .put (keybind , cooldowntimer );
81- cooldown =Minecraft .getDebugFPS ()/3 ;
82- return true ;
83- }
84- return false ;
85- } else {
86- cooldownHashMap .put (keybind , cooldowntimer );
87- cooldown =Minecraft .getDebugFPS ()/3 ;
88- return true ;
89- }
90- }
91- return false ;
79+ return isKeyDown (keybind );
9280 }
9381
9482 /**
@@ -99,11 +87,6 @@ public static void registerBlockedKeyBinding(KeyBinding keybind) {
9987 blockedKeys .add (keybind );
10088 }
10189
102- @ Deprecated
103- public static void registerBlockedDuringRecordingKeyBinding (KeyBinding keybind ) {
104- blockedDuringRecordingKeys .add (keybind );
105- }
106-
10790 /**
10891 * Checks whether the keycode should not be recorded or played back in a TAS
10992 * @param keycode to block
@@ -116,18 +99,5 @@ public static boolean isKeyCodeAlwaysBlocked(int keycode) {
11699 }
117100 return false ;
118101 }
119- @ Deprecated
120- public static boolean isKeyCodeBlockedDuringRecording (int keycode ) {
121- for (KeyBinding keybind : blockedDuringRecordingKeys ) {
122- if (keycode == keybind .getKeyCode ()) {
123- blockedDuringRecordingKeys .remove (keybind );
124- return true ;
125- }
126- }
127- return false ;
128- }
129102
130- public static void setCooldown (long cooldown ) {
131- VirtualKeybindings .cooldown = cooldown ;
132- }
133103}
0 commit comments