Fix inability to attack while holding modifier keys

This commit is contained in:
mezz 2016-04-03 13:15:18 -07:00
parent 21d39f6558
commit bc2b5ad517
3 changed files with 33 additions and 4 deletions

View file

@ -53,7 +53,7 @@
public boolean func_151470_d() public boolean func_151470_d()
{ {
- return this.field_74513_e; - return this.field_74513_e;
+ return this.field_74513_e && getKeyConflictContext().isActive() && (!allowsKeyModifiers || getKeyModifier().isActive()); + return this.field_74513_e && getKeyConflictContext().isActive() && getKeyModifier().isActive();
} }
public String func_151466_e() public String func_151466_e()
@ -110,7 +110,7 @@
+ */ + */
+ public boolean isActiveAndMatches(int keyCode) + public boolean isActiveAndMatches(int keyCode)
+ { + {
+ return keyCode == this.func_151463_i() && getKeyConflictContext().isActive() && (!allowsKeyModifiers || getKeyModifier().isActive()); + return keyCode == this.func_151463_i() && getKeyConflictContext().isActive() && getKeyModifier().isActive();
+ } + }
+ +
+ public void setKeyConflictContext(net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext) + public void setKeyConflictContext(net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext)
@ -136,7 +136,7 @@
+ } + }
+ else + else
+ { + {
+ return net.minecraftforge.client.settings.KeyModifier.NONE; + return net.minecraftforge.client.settings.KeyModifier.NOT_SUPPORTED;
+ } + }
+ } + }
+ +

View file

@ -22,7 +22,17 @@ public class KeyBindingMap
public KeyBinding lookupActive(int keyCode) public KeyBinding lookupActive(int keyCode)
{ {
KeyModifier activeModifier = KeyModifier.isKeyCodeModifier(keyCode) ? KeyModifier.NONE : KeyModifier.getActiveModifier(); KeyModifier activeModifier = KeyModifier.isKeyCodeModifier(keyCode) ? KeyModifier.NONE : KeyModifier.getActiveModifier();
Collection<KeyBinding> bindings = map.get(activeModifier).lookup(keyCode); KeyBinding binding = getBinding(keyCode, activeModifier);
if (binding != null)
{
return binding;
}
return getBinding(keyCode, KeyModifier.NOT_SUPPORTED);
}
private KeyBinding getBinding(int keyCode, KeyModifier keyModifier)
{
Collection<KeyBinding> bindings = map.get(keyModifier).lookup(keyCode);
if (bindings != null) if (bindings != null)
{ {
for (KeyBinding binding : bindings) for (KeyBinding binding : bindings)

View file

@ -83,6 +83,25 @@ public enum KeyModifier {
return !SHIFT.isActive() && !CONTROL.isActive() && !ALT.isActive(); return !SHIFT.isActive() && !CONTROL.isActive() && !ALT.isActive();
} }
@Override
public String getLocalizedComboName(String keyName)
{
return keyName;
}
},
NOT_SUPPORTED {
@Override
protected boolean matches(int keyCode)
{
return true;
}
@Override
public boolean isActive()
{
return true;
}
@Override @Override
public String getLocalizedComboName(String keyName) public String getLocalizedComboName(String keyName)
{ {