Posted August 11, 201411 yr Hello! Ive been messing around with some code, and i was trying to create a method where my item would damage an entity from a distance. For some reason the damage is not being delt. My log messages appear in the console so im sure the method is being called. if you see an obvious error please tell me! Any help is appreciated! @Override public boolean onEntitySwing(EntityLivingBase entity, ItemStack stack) { EntityPlayer player = (EntityPlayer) entity; EntityLivingBase target = getMouseOver(1, 10, player); LogHelper.logInfo("Being called"); if (target != null) { float missing_health = ((EntityLivingBase) target).getMaxHealth() - ((EntityLivingBase) target).getHealth(); target.attackEntityFrom(Pineapple.pineapple, (float) (5 + (missing_health * 0.10))); LogHelper.logInfo("Attacking Entity -- Current Health:" + target.getHealth() + " Name:" + target.getClass()); } return false; } public EntityLivingBase getMouseOver(float tick, float distance, EntityPlayer player) { if (mc.theWorld != null) { MovingObjectPosition pos = player.rayTrace(distance, tick); Vec3 vec3 = mc.renderViewEntity.getPosition(tick); Vec3 vec31 = mc.renderViewEntity.getLook(tick); Vec3 vec32 = vec3.addVector(vec31.xCoord * distance, vec31.yCoord * distance, vec31.zCoord * distance); List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(this.mc.renderViewEntity, this.mc.renderViewEntity.boundingBox.addCoord(vec31.xCoord * distance, vec31.yCoord * distance, vec31.zCoord * distance).expand(1.0, 1.0, 1.0)); for (int i = 0; i < list.size(); ++i) { Entity entity = (Entity) list.get(i); if (entity instanceof EntityLivingBase) { return (EntityLivingBase) entity; } } } return null; } System.out.println("Hi!");
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.