Skip to content

Commit

Permalink
Re-add wheel slip
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Sep 15, 2017
1 parent 3b2b6e9 commit fb9ee69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void onUpdate() {
this.motionY = this.posY - this.prevPosY;
this.motionZ = this.posZ - this.prevPosZ;

distanceTraveled += this.currentSpeed.minecraft();
distanceTraveled += (this.isReverse ? -1 : 1) * this.currentSpeed.minecraft();

List<Entity> entitiesWithin = world.getEntitiesWithinAABB(Entity.class, this.getCollisionBoundingBox());
for (Entity entity : entitiesWithin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public void onUpdate() {
// runSound.setVolume(getSpeed().minecraft() > 0 ? 1 : 0);
// idleSound.setVolume(getSpeed().minecraft() > 0 ? 0 : 1);

simulateWheelSlip();

if (world.isRemote) {
return;
}
Expand Down Expand Up @@ -165,6 +167,11 @@ public void onUpdate() {

protected abstract int getAvailableHP();

private void simulateWheelSlip() {
if (Math.abs(getTractiveEffortNewtons(this.getCurrentSpeed())) == this.getDefinition().getStartingTractionNewtons()) {
this.distanceTraveled += Math.copySign(0.05, getThrottle()); //Wheel Slip
}
}

private double getTractiveEffortNewtons(Speed speed) {
double locoEfficiency = 0.7f; //TODO config
Expand All @@ -174,7 +181,6 @@ private double getTractiveEffortNewtons(Speed speed) {

if (tractiveEffortNewtons > this.getDefinition().getStartingTractionNewtons()) {
tractiveEffortNewtons = this.getDefinition().getStartingTractionNewtons();
this.distanceTraveled += Math.copySign(0.05, getThrottle()); //Whell Slip
}

return Math.copySign(tractiveEffortNewtons, getThrottle());
Expand Down

0 comments on commit fb9ee69

Please sign in to comment.