Posted June 13, 20205 yr Code: TraceResult = mc.objectMouseOver; if(TraceResult!=null){ if(TraceResult.getType() == RayTraceResult.Type.ENTITY) { EntityRayTraceResult EntityTrace = (EntityRayTraceResult) TraceResult; if (EntityTrace.getEntity() instanceof LivingEntity) { if (EntityTrace.getEntity().attackEntityFrom(DamageSource.causePlayerDamage(mc.player), 3)) { System.out.println("Attack successful"); } else{ System.out.println("Attack failed"); } } } } What am I trying to achieve: Damage entity when player releases left mouse button. Input tracking works well, but the problem is: After I release the left mouse button attackEntityFrom always returns false. Aditional info: These "if's" are located in ClientTickEvent event. Edited June 13, 20205 yr by byalexeykh
June 13, 20205 yr 16 minutes ago, byalexeykh said: EntityTrace.getEntity().attackEntityFrom(DamageSource.causePlayerDamage(mc.player), 3) You cannot do that on the client side. That method should be called on the server side. You should do the ray tracing on the server side (there might be a slight difference in player's facing with the client though). Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
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.