Posted September 29, 20214 yr Hello! I'm trying to figure out if and what entity is the player looking at. here is my current code. if (Minecraft.getInstance().objectMouseOver.getType() == RayTraceResult.Type.ENTITY) { } All I need to know is how to get the entity!
September 29, 20214 yr which version did you use? also please create the next thread in the correct sub forum
September 29, 20214 yr Author 19 hours ago, Luis_ST said: which version did you use? also please create the next thread in the correct sub forum forge 1.16.5
September 30, 20214 yr Author 2 hours ago, poopoodice said: Case it to EntityRayTraceResult and get entity from it Thanks just making sure this is correct. here's my code if (Minecraft.getInstance().objectMouseOver.getType() == RayTraceResult.Type.ENTITY) { EntityRayTraceResult result = (EntityRayTraceResult) Minecraft.getInstance().objectMouseOver; if (result.getEntity().getType() == EntityType.PLAYER) { entity = (ServerPlayerEntity) result.getEntity(); } } Edited September 30, 20214 yr by 8iggy info
September 30, 20214 yr Yes, but it will crash at Quote entity = (ServerPlayerEntity) result.getEntity(); Since it is always a client player, not server.
October 2, 20214 yr Author On 9/30/2021 at 12:40 AM, poopoodice said: Yes, but it will crash at Since it is always a client player, not server. Thanks!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.