Skip to content

Commit

Permalink
Properly calculate distance in subtick-distances for accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Jan 30, 2015
1 parent 49e3e49 commit 11eb112
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/tconstruct/library/entity/ProjectileBase.java
Expand Up @@ -183,8 +183,18 @@ public void onHitEntity(MovingObjectPosition movingobjectposition) {
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
float speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);

float distance = speed * this.ticksInAir;

speed = Math.max(0, speed-2);

// absolute distance travelled minus the current tick
float distance = speed * (this.ticksInAir-1);
// distance travelled in the current tick
float dist2 = 0;
dist2 += MathHelper.abs((float)movingobjectposition.entityHit.lastTickPosX - (float)this.lastTickPosX);
dist2 += MathHelper.abs((float)movingobjectposition.entityHit.lastTickPosY - (float)this.lastTickPosY);
dist2 += MathHelper.abs((float)movingobjectposition.entityHit.lastTickPosZ - (float)this.lastTickPosZ);
dist2 = MathHelper.sqrt_double(dist2);

distance += dist2;

if(!tags.hasKey("BaseAttack"))
{
Expand Down

0 comments on commit 11eb112

Please sign in to comment.