Permalink
Browse files

APC improvements, removed debug messages.

  • Loading branch information...
Ri5ux committed Dec 18, 2017
1 parent c09ce39 commit 2b4492f1298c4e5996f6f9a97441d3eccab20a02
Showing with 46 additions and 17 deletions.
  1. +46 −17 src/main/java/org/avp/entities/EntityAPC.java
@@ -229,7 +229,7 @@ private void handleKeybindAction()
public void onUpdate()
{
super.onUpdate();
if (this.world.isRemote)
{
this.handleKeybindAction();
@@ -259,12 +259,11 @@ public void onUpdate()
double addedRotation;
double prevPosX;
double prevPosZ;
this.tireRotation += curVelocity * -100;
if (curVelocity > 0.26249999999999996D)
{
// velocity1 = Math.cos((double) this.rotationYaw * Math.PI / 180.0D);
// addedRotation = Math.sin((double) this.rotationYaw * Math.PI / 180.0D);
// velocity1 = Math.cos((double) this.rotationYaw * Math.PI / 180.0D);
// addedRotation = Math.sin((double) this.rotationYaw * Math.PI / 180.0D);
}
// if (this.world.isRemote && this.isVehicleEmpty)
@@ -326,6 +325,11 @@ public void onUpdate()
double decelerationRate = 0.003D;
double accelerationRate = 0.003D;
this.tireRotation += curVelocity * -100 * driver.moveForward;
this.tireRotation = tireRotation % 360;
// System.out.println(tireRotation);
if (accellerating)
{
if (this.speedMultiplier < maxAcceleration)
@@ -343,35 +347,35 @@ else if (reverse)
else if (speedMultiplier > 0)
{
speedMultiplier -= 0.003D;
System.out.println("deccelleration");
// System.out.println("deccelleration");
}
else if (speedMultiplier < 0)
{
speedMultiplier = 0F;
}
//Entities.getEntityRiddenBy(this).rotationYaw +
float mov = this.rotationYaw + 90;
// Entities.getEntityRiddenBy(this).rotationYaw +
float mov = this.rotationYaw + 90;
this.motionX += -Math.sin((double) (mov * (float) Math.PI / 180.0F)) * this.speedMultiplier;
this.motionZ += Math.cos((double) (mov * (float) Math.PI / 180.0F)) * this.speedMultiplier;
float baseTurnAcc = 6F;
float turnAcceleration = curVelocity < 0.25 ? baseTurnAcc : baseTurnAcc / 1.5F;
float turnSpeed = (float) (curVelocity * turnAcceleration);
// System.out.println(curVelocity);
// System.out.println(curVelocity);
if (driver.moveStrafing > 0)
{
//left rotation
System.out.println("left");
// left rotation
// System.out.println("left");
this.rotationYaw = this.rotationYaw + (reverse ? +turnSpeed : -turnSpeed);
}
else if (driver.moveStrafing < 0)
{
//right rotation
System.out.println("right");
// right rotation
// System.out.println("right");
this.rotationYaw = this.rotationYaw + (reverse ? -turnSpeed : +turnSpeed);
}
@@ -468,7 +472,7 @@ else if (driver.moveStrafing < 0)
rotation = -rotIncr;
}
// this.rotationYaw = (float) ((double) this.rotationYaw + rotation);
// this.rotationYaw = (float) ((double) this.rotationYaw + rotation);
this.setRotation(this.rotationYaw, this.rotationPitch);
if (!this.world.isRemote)
@@ -634,4 +638,29 @@ public float getTireRotation()
{
return this.tireRotation;
}
public EntityLivingBase getDriver()
{
return (EntityLivingBase) Entities.getEntityRiddenBy(this);
}
public boolean isAccelerating()
{
if (this.getDriver() != null)
{
return this.getDriver().moveForward > 0.1;
}
return false;
}
public boolean isReversing()
{
if (this.getDriver() != null)
{
return this.getDriver().moveForward < -0.1;
}
return false;
}
}

0 comments on commit 2b4492f

Please sign in to comment.