Botania

Botania

133M Downloads

Pressing any key repeatedly while moving right/left will activate ring of dexterous motion

Darinth opened this issue ยท 3 comments

commented

The onKeyDown event for the ring of dexterous motion is checking if the right/left keys are down, but not if they're the key which was pressed. The result is that when moving right/left, any key press can activate the ring of dexterous motion not just the right/left keys.

To reproduce, just hold down the right/left keys while pressing anything else on the keyboard.

commented

afaik the fml event doesn't tell you what key is pressed so idk how to handle this

commented

The old fashioned way I used to fix this issue on other projects was to track the state of a key, and only react if the key was up and now is down.

My apologies if the code isn't perfect as I don't have a dev environment setup (also, I avoid looking at minecraft code for professional reasons), but these should be roughly the changes needed.

In ItemDodgeRing.java add

bool oldLeftDown, oldRightDown

after

int leftDown, rightDown

at the end of onKeyDown add

oldLeftDown = mc.gameSettings.keyBindLeft.isKeyDown()
oldRightDown = mc.gameSettings.keyBindRight.isKeyDown()

and then change the conditions in the if statements to

if(mc.gameSettings.keyBindLeft.isKeyDown() && !oldLeftDown)
else if(mc.gameSettings.keyBindRight.isKeyDown() && !oldRightDown)

That should track the state of the left and right keys and only activate the dodge effect if the key was up on the last keypress and is now down.

commented

thanks!