Jump to content

Not Dealing Damage with extended reach


Masterzach32

Recommended Posts

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!");

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.