Skip to content

Commit d7b497d

Browse files
author
EternalBlueFlame
committed
movement and seating fixes
- Seat positions are now rotated correctly. many still need fixing. - Train should now use player facing direction to change acceleration direction. - Linking should no longer hinder acceleration.
1 parent 1640ae8 commit d7b497d

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/main/java/train/common/api/AbstractTrains.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ public void setTrainOwner(String trainOwner) {
170170
public static int uniqueIDs = 1;
171171

172172

173+
public boolean isLocoTurnedOn = false;
174+
173175
/**
174176
* The distance this train has traveled
175177
*/

src/main/java/train/common/api/EntityRollingStock.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ private void positionSeats(){
909909
getWorld().spawnEntityInWorld(seats.get(i1));
910910
}
911911
cachedVectors[0] = new Vec3f(getRiderOffsets()[i1][0], getRiderOffsets()[i1][1], getRiderOffsets()[i1][2])
912-
.rotatePoint(rotationPitch, rotationYaw, 0f);
912+
.rotatePoint(rotationPitch, 180+rotationYaw, 0f);
913913
cachedVectors[0].addVector(posX,posY,posZ);
914914
seats.get(i1).setPosition(cachedVectors[0].xCoord, cachedVectors[0].yCoord, cachedVectors[0].zCoord);
915915
}
@@ -1007,7 +1007,7 @@ public void addLinkingMove(double velocity){
10071007
bogieFront.addLinking(this, velocity);
10081008
}
10091009
public void manageLink(AbstractTrains other) {
1010-
if(isAccelerating() || other.bogieBack ==null || other.bogieFront ==null || bogieBack ==null || bogieFront ==null) {
1010+
if(isLocoTurnedOn || other.bogieBack ==null || other.bogieFront ==null || bogieBack ==null || bogieFront ==null) {
10111011
return;
10121012
}
10131013

@@ -1062,6 +1062,10 @@ public void finalMove(){
10621062
bogieBack.posX - bogieFront.posX)),
10631063
CommonUtil.calculatePitch(bogieFront.posY, bogieBack.posY , Math.abs(rotationPoints()[0]) + Math.abs(rotationPoints()[1])));
10641064

1065+
cachedVectors[1]= new Vec3f(rotationPoints()[0], 0, 0).rotatePoint(0, rotationYaw, 0)
1066+
.addVector(posX,0,posZ);
1067+
bogieFront.setPosition(cachedVectors[1].xCoord, bogieFront.posY,cachedVectors[1].zCoord);
1068+
10651069
//reset the vector when we're done so it wont break trains.
10661070
cachedVectors[1]= new Vec3f(0,0,0);
10671071
//update the collision handler's positions
@@ -1075,22 +1079,20 @@ public void finalMove(){
10751079

10761080
@Override
10771081
public void applyDrag() {
1078-
boolean canSlope=ConfigHandler.ENABLE_SLOPE_ACCELERATION;
10791082
float drag = 0.9998f, brakeBuff = 0;
10801083
//check if lope things can be done at all
10811084
for(AbstractTrains stock : consist) {
1082-
if(stock!=this && stock.isAccelerating()){
1083-
canSlope=false;
1084-
break;
1085-
} else if(stock==this){
1086-
break;
1085+
if(stock!=this && stock.isLocoTurnedOn){
1086+
return;
1087+
} else if(stock ==this && isAccelerating()){
1088+
return;
10871089
}
10881090
}
10891091
if (isBraking) {
10901092
//realistically would be more like 2.4, but 5 makes gameplay more dramatic
10911093
brakeBuff += weightKg() * 3.0f;
10921094
}
1093-
if(canSlope) {
1095+
if(ConfigHandler.ENABLE_SLOPE_ACCELERATION) {
10941096
if (Math.abs(rotationPitch) - 1 > 0) { //cap the pitch that we actually consider to be on a slope
10951097
//vanilla uses 0.0078125 per tick for slope speed.
10961098
//0.00017361 would be that divided by 45 since vanilla slopes are 45 degree angles.

src/main/java/train/common/api/Locomotive.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public abstract class Locomotive extends Freight implements WirelessTransmitter,
4848
private Entity lastEntityRider;
4949
private boolean hasDrowned = false;
5050
protected boolean canCheckInvent = true;
51-
public boolean isLocoTurnedOn = false;
5251
public boolean forwardPressed = false;
5352
public boolean backwardPressed = false;
5453
public boolean brakePressed = false;
@@ -1227,7 +1226,7 @@ public void accel(Integer desiredSpeed) {
12271226
if (this.worldObj != null) {
12281227
if (this.getSpeed() != desiredSpeed) {
12291228
if ((int) this.getSpeed() <= this.speedLimit) {
1230-
double rotation = this.riddenByEntity == null?rotationYaw:riddenByEntity.rotationYaw;
1229+
double rotation = this.seats.get(0).getPassenger() == null?rotationYaw:seats.get(0).getPassenger().rotationYaw;
12311230
double[] motion = CommonUtil.rotatePoint(0.002,0,rotation==0?0:CommonUtil.floorDouble(rotation/90d)*90);
12321231
addVelocity(motion[0],0,motion[2]);
12331232
}

0 commit comments

Comments
 (0)