The behavior of the Potion Ring does not follow its tooltip
lonefelidae16 opened this issue · 1 comments
Describe the bug
As you know, we can change key bindings to different ones.
ExtraAlchemy/src/main/resources/assets/extraalchemy/lang/en_us.json
Lines 15 to 16 in 7b31ca9
When I follow this tooltip to activate the Potion Ring with Shift + Right Click, it doesn’t. After examining the code, I was able to figure out why it doesn’t.
That’s because my Shift key is assigned to Sprint and the Potion Ring checks for Sneaking at line 79.
To Reproduce
Steps to reproduce the behavior:
- Set the Sneak key from Shift to another on the key bind setting screen.
- Get the Potion Ring in the Hotbar.
- Shift + Right Click and it doesn’t activate.
Expected behavior
If it needs to sneak, I think the tooltip should to be changed to Right click while sneaking to enable/disable
. If not, it would be more awesome if it could determine if the Shift key is really being pressed.
I tried to implement this, but I found that it requires interaction between server and client using the packet behavior.
- Register a new receiver on the server side by executing
ServerPlayNetworking#registerGlobalReceiver
. - Register a new callback on the client side by executing
Event#register
inClientTickEvents#END_CLIENT_TICK
. - Send the packet to tell from the client side that the combination key is pressed or not using
ClientPlayNetworking#send
.
The state can be detected by callingInputUtil#isKeyPressed
. - When the packet is received on the server side, the state needs to be stored for each player.
- Get the state in the
use
method.
It works for me, but the statements get more complex, so I think it’s just enough to determine if the player is sneaking or not. Maybe there is another way or useful library to do this, but I could not find it, perhaps my search skills are not good enough.
Environment (please complete the following information):
- Mod Version: local build rev.7b31ca9b (1.9.2)
- MC Version: 1.19.3
- Fabric Version: 0.14.12
- Fabric API version: 0.72.0
- System: Ubuntu Linux 22.04 / Windows 11
- Installation type: “Open to LAN” on Integrated Server via
:runClient
Gradle task / Dedicated Server via:runServer
Gradle task