yarn
yarn copied to clipboard
*HitResult -> *HitPosition
It's just the position on the block/entity that was hit. I'm not sure what it's a result of.
I imagine the reason behind this name is it being a result from a ray-trace query. Since I'm here, what about something like RayIntercept
?
a result from a ray-trace query
The object is created in a few places other than raytraces. For example, when an arrow hits a block, or when a villager hits the bell.
The arrow performs a raytrace check to get that position, iirc. Not sure about the bell.
Looking at the code in ProjectileUtil
, it seems like it only does a raytrace in certain cases, and uses the position of the arrow entity otherwise.
For the bell, it's just created at the center of the face of the side that was hit.
-
is the class only used for the hitting?
-
Does only the player use this class or other entities as well?
- Yes. In fact, there is a boolean which can be set to true if no block was hit.
- It's used in many places (players, mobs with AI, arrows, etc.)
My suggestion would be HitTarget or InteractionTarget
HitContext?
There is also the argument that we should stick with *HitResult as that is what Mojang calls it
as that is what Mojang calls it
What makes you think that?
HitContext
sounds good. As HitResult
is not "wrong" imo, if it's really the current Mojang name, I'd be for keeping it, though.
Position isn't really more accurate than Result imo.
If HitPosition
is agreed to be a good change, I would further suggest HitPos
Another option would be Target
/HitTarget
, since it's used as the target of some action (a block or interaction, the crosshair's target (currently named MinecraftClient.crosshairHitResult
), etc.).
I think that HitResult
is a fine name as it mirrors ActionResult
, and both are used for different scenarios (raycasting and generic actions).