Repository navigation
fix(entity): default an unsized actor's hitbox to 0.6 x 1.8, scaled - #69
Merged
Merged
Conversation
An actor without server-sent BOUNDINGBOX_WIDTH/HEIGHT and without a known collision box fell back to an unscaled 0.6 x 1.0 box. Large scaled NPCs could then only be hit low on their body: aiming at the head sent no attack at all. The game's minecraft:collision_box description defaults to 0.6 x 1.8 (0x142EBA9A0); the box now uses that, times the actor's scale like the other cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On The Hive hub, the game NPCs ("Punch to play") can only be hit around the middle of their body. Punching the head does nothing.
A packet capture shows that those head hits never leave the client. There are ten
animate(swingSource: attack) with noinventory_transactionattack after them: Perlin's raycast misses the NPC. Body hits on the same NPC (runtime id 1008) do sendItemUseOnEntityattacks.Cause
The NPC is
hivehub:game_sky_solo, withSCALE1.75. The server sends noBOUNDINGBOX_WIDTH/BOUNDINGBOX_HEIGHT(metadata keys 53 / 54) for it. Other hub NPCs do (npc_store0.6 × 2.6,npc_region0.6 × 2.2, …) and were fine.With no server box and no known collision box,
EntityRenderer::HitBoxfell back to{0.6, 1.0}, without applying the scale. The 1.75×-scaled model therefore had a 1-block-tall hit box.What the vanilla client uses
The behaviour below comes from IDA on the Windows client 1.26.60.5:
0x142EBA9A0builds the defaultminecraft:collision_boxdescription and writes0x3FE666663F19999Ainto it, i.e. width 0.6, height 1.8.Player::stopSleep(0x1402BE690) resets the player to the same pair (with eye height 1.62).Change
EntityRenderer::HitBox: the last fallback is now0.6 × 1.8, times the actor's scale, like the other branches of the function. For this NPC, that is 1.05 × 3.15.Testing
SCALE. This follows the existing scaled branches.