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 in ClientTickEvents#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 calling InputUtil#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):
Describe the bug
As you know, we can change key bindings to different ones.
https://github.com/zabi94/ExtraAlchemy/blob/7b31ca9be38ffc55f15bfe431ec9385653e4a703/src/main/resources/assets/extraalchemy/lang/en_us.json#L15-L16
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.
https://github.com/zabi94/ExtraAlchemy/blob/7b31ca9be38ffc55f15bfe431ec9385653e4a703/src/main/java/zabi/minecraft/extraalchemy/items/PotionRingItem.java#L76-L84
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:
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.
ServerPlayNetworking#registerGlobalReceiver
.Event#register
inClientTickEvents#END_CLIENT_TICK
.ClientPlayNetworking#send
. The state can be detected by callingInputUtil#isKeyPressed
.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):
:runClient
Gradle task / Dedicated Server via:runServer
Gradle task