Describe the bug
When holding down the throw key (LAUNCHER/THROW), the grappling hook is launched
repeatedly / continuously instead of just once. This also increases the chance of
related instability, including a NullPointerException crash in
GrapplehookEntity.tick() (com.yyon.grapplinghook.utils.Vec.positionVec) when the
hook entity loses its owner reference during rapid re-throwing.
Root cause (found via decompilation): in ClientEventHandlers.onClientTick(),
the key-down handler drains the entire click queue every tick without checking
whether the key is already marked as held:
for (HeldKey keyState : this.keyStates) {
while (keyState.mapping.consumeClick()) {
keyState.held = true;
this.triggerKeyDown(player, keyState);
}
...
}
If more than one click gets queued between ticks (e.g. due to network/frame
timing variance), triggerKeyDown (and therefore the throw logic) fires multiple
times in a single tick.
Suggested fix — guard with the existing held flag so it can only fire once
per press:
while (keyState.mapping.consumeClick()) {
if (!keyState.held) {
keyState.held = true;
this.triggerKeyDown(player, keyState);
}
}
Video / Screenshots
If applicable, add screenshots to help explain your problem.
Version
Grappling Hook Mod Reforged v1.2 (v13)
Minecraft 1.20.1, Forge 47.4.10
Output Log
Details
NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.m_20182_()" because "e" is null
at com.yyon.grapplinghook.utils.Vec.positionVec(Vec.java:58)
at com.yyon.grapplinghook.entities.grapplehook.GrapplehookEntity.m_8119_(GrapplehookEntity.java:234)
**To Reproduce**
1. Equip the grappling hook item
2. Hold down the throw key for an extended period without releasing
3. Observe that the hook fires/launches repeatedly instead of once
4. Occasionally, especially under lag or with rapid re-throwing, the game
crashes with the NullPointerException shown above
Additional context
Happy to test a fix if needed. Thanks for maintaining this mod!
Describe the bug
When holding down the throw key (LAUNCHER/THROW), the grappling hook is launched
repeatedly / continuously instead of just once. This also increases the chance of
related instability, including a NullPointerException crash in
GrapplehookEntity.tick() (com.yyon.grapplinghook.utils.Vec.positionVec) when the
hook entity loses its owner reference during rapid re-throwing.
Root cause (found via decompilation): in
ClientEventHandlers.onClientTick(),the key-down handler drains the entire click queue every tick without checking
whether the key is already marked as held:
If more than one click gets queued between ticks (e.g. due to network/frame
timing variance), triggerKeyDown (and therefore the throw logic) fires multiple
times in a single tick.
Suggested fix — guard with the existing
heldflag so it can only fire onceper press:
Video / Screenshots
If applicable, add screenshots to help explain your problem.
Version
Grappling Hook Mod Reforged v1.2 (v13)
Minecraft 1.20.1, Forge 47.4.10
Output Log
Details
NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.m_20182_()" because "e" is null at com.yyon.grapplinghook.utils.Vec.positionVec(Vec.java:58) at com.yyon.grapplinghook.entities.grapplehook.GrapplehookEntity.m_8119_(GrapplehookEntity.java:234)Additional context
Happy to test a fix if needed. Thanks for maintaining this mod!