yarn icon indicating copy to clipboard operation
yarn copied to clipboard

*HitResult -> *HitPosition

Open Runemoro opened this issue 5 years ago • 15 comments

It's just the position on the block/entity that was hit. I'm not sure what it's a result of.

Runemoro avatar Mar 29 '19 06:03 Runemoro

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?

Gegy avatar Mar 29 '19 08:03 Gegy

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.

Runemoro avatar Mar 29 '19 08:03 Runemoro

The arrow performs a raytrace check to get that position, iirc. Not sure about the bell.

Gegy avatar Mar 29 '19 08:03 Gegy

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.

Runemoro avatar Mar 29 '19 09:03 Runemoro

  1. is the class only used for the hitting?

  2. Does only the player use this class or other entities as well?

Prospector avatar Mar 29 '19 22:03 Prospector

  1. Yes. In fact, there is a boolean which can be set to true if no block was hit.
  2. It's used in many places (players, mobs with AI, arrows, etc.)

Runemoro avatar Mar 30 '19 02:03 Runemoro

My suggestion would be HitTarget or InteractionTarget

Prospector avatar Mar 30 '19 03:03 Prospector

HitContext?

Runemoro avatar May 06 '19 14:05 Runemoro

There is also the argument that we should stick with *HitResult as that is what Mojang calls it

ChloeDawn avatar May 06 '19 14:05 ChloeDawn

as that is what Mojang calls it

What makes you think that?

Runemoro avatar May 06 '19 14:05 Runemoro

HitContext sounds good. As HitResult is not "wrong" imo, if it's really the current Mojang name, I'd be for keeping it, though.

NeunEinser avatar May 06 '19 18:05 NeunEinser

Position isn't really more accurate than Result imo.

liach avatar Oct 09 '19 03:10 liach

If HitPosition is agreed to be a good change, I would further suggest HitPos

ChloeDawn avatar Oct 09 '19 11:10 ChloeDawn

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.).

Runemoro avatar Oct 28 '19 22:10 Runemoro

I think that HitResult is a fine name as it mirrors ActionResult, and both are used for different scenarios (raycasting and generic actions).

haykam821 avatar Dec 01 '21 02:12 haykam821