How get block side which one is looking player #2449
-
The image posted is the general idea of what I am trying to say.. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It depends where you are in the code and what kind of raycast/HitResult you find acceptable. If your HitResult is hitting a block you will have a BlockHitResult which has a getSide(). Assuming where you are in the code doesn't have a HitResult parameter: On the client there is You can do the calculation from scratch using something like:
On the client the entity would be MinecraftClient.cameraEntity or on the server you would use the ServerPlayerEntity. |
Beta Was this translation helpful? Give feedback.
-
You can simply use |
Beta Was this translation helpful? Give feedback.
It depends where you are in the code and what kind of raycast/HitResult you find acceptable.
If your HitResult is hitting a block you will have a BlockHitResult which has a getSide().
Assuming where you are in the code doesn't have a HitResult parameter:
On the client there is
MinecraftClient.crosshairTarget
which may or may not be aBlockHitResult
See MinecraftClient.doItemUse() for example.
You can do the calculation from scratch using something like: