Skip to content

Commit b702b5d

Browse files
author
EternalBlueFlame
committed
linking still not fixed, but sorta closer
1 parent 5cfafdf commit b702b5d

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ else if (TCRailTypes.isStraightTrack(lastTrack)) {
270270
} else if (TCRailTypes.isDiagonalTrack(lastTrack) || TCRailTypes.isDiagonalCrossingTrack(lastTrack)){
271271
moveOnTCDiagonal(j);
272272
}
273+
velocity[2]=0;
274+
velocity[3]=0;
273275

274276
}
275277

@@ -516,6 +518,8 @@ public void addLinking(AbstractTrains host, double speed){
516518

517519
velocity[2]+=speed*velocity[4];
518520
velocity[3]+=speed*velocity[5];
521+
velocity[4]=0;
522+
velocity[5]=0;
519523
}
520524

521525
public void drag(AbstractTrains host, double drag){

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,6 @@ public void updatePosition(){
971971
prevPosZ = posZ;
972972

973973
ticksSinceLastVelocityChange=1;
974-
975-
cachedVectors[1]= new Vec3f(rotationPoints()[0], 0, 0).rotatePoint(0, rotationYaw, 0)
976-
.addVector(posX,0,posZ);
977-
bogieFront.setPosition(cachedVectors[1].xCoord, bogieFront.posY,cachedVectors[1].zCoord);
978974
} else {
979975
motionX = (posX - prevPosX)/ticksSinceLastVelocityChange;
980976
motionZ = (posZ - prevPosZ)/ticksSinceLastVelocityChange;
@@ -1010,7 +1006,7 @@ public void addLinkingMove(double velocity){
10101006
bogieBack.addLinking(this, velocity);
10111007
bogieFront.addLinking(this, velocity);
10121008
}
1013-
public void manageLink(AbstractTrains other) {
1009+
public void manageLink(EntityRollingStock other) {
10141010
if(isLocoTurnedOn || other.bogieBack ==null || other.bogieFront ==null || bogieBack ==null || bogieFront ==null) {
10151011
return;
10161012
}
@@ -1021,6 +1017,7 @@ public void manageLink(AbstractTrains other) {
10211017

10221018
double springDist = MathHelper.sqrt_double(vecX * vecX + vecZ * vecZ)
10231019
-(getOptimalDistance(other)+other.getOptimalDistance(this));
1020+
springDist*=0.0625;
10241021

10251022
if(getVelocity()>0.3) {
10261023
springDist *= 0.45;
@@ -1029,14 +1026,13 @@ public void manageLink(AbstractTrains other) {
10291026
} else {
10301027
springDist*=0.3;
10311028
}
1032-
if(backLink!=null && other == backLink) {
1029+
if(backLink!=null && other.getEntityId() == backLink.getEntityId()) {
10331030
springDist *= -1;
10341031
}
10351032

10361033
if(Math.abs(springDist)>0.01) {
10371034
addLinkingMove(springDist);
10381035
}
1039-
10401036
}
10411037

10421038
/**
@@ -1045,11 +1041,11 @@ public void manageLink(AbstractTrains other) {
10451041
public void finalMove(){
10461042

10471043
applyDrag();
1048-
if(frontLink!=null) {
1049-
manageLink(frontLink);
1044+
if(frontLink instanceof EntityRollingStock) {
1045+
manageLink((EntityRollingStock) frontLink);
10501046
}
1051-
if(backLink!=null){
1052-
manageLink(backLink);
1047+
if(backLink instanceof EntityRollingStock){
1048+
manageLink((EntityRollingStock) backLink);
10531049
}
10541050

10551051
applyDrag();

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -930,14 +930,6 @@ else if (getState().equals("broken")) {
930930
}
931931
}
932932

933-
@Override
934-
public void manageLink(AbstractTrains other){
935-
if(forwardPressed || backwardPressed){
936-
return;
937-
}
938-
super.manageLink(other);
939-
}
940-
941933
@Override
942934
public boolean isAccelerating(){return forwardPressed || backwardPressed;}
943935

src/main/java/train/common/entity/EntityHitbox.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ebf.tim.entities.EntitySeat;
44
import ebf.tim.utility.CommonUtil;
5+
import ebf.tim.utility.DebugUtil;
56
import fexcraft.tmt.slim.Vec3d;
67
import fexcraft.tmt.slim.Vec3f;
78
import net.minecraft.entity.Entity;
@@ -192,7 +193,7 @@ public void updateCollidingEntities(EntityRollingStock host){
192193
for (List olist: entities) {
193194
for(Object obj : olist) {
194195
//this shouldn't be possible, but it's forge, sooooo....
195-
if(!(obj instanceof Entity)){
196+
if(!(obj instanceof Entity) || interactionBoxes.contains(obj)){
196197
continue;
197198
}
198199

@@ -201,7 +202,7 @@ public void updateCollidingEntities(EntityRollingStock host){
201202
//If the cart is in a consist containing a locomotive, we do not want to push it.
202203
if (!ConfigHandler.PUSHABLE_ROLLINGSTOCK || host instanceof Locomotive || (host.consistLeadID != null && host.worldObj.getEntityByID(host.consistLeadID) instanceof Locomotive)) {
203204
//still need to push the player back though
204-
if (containsEntity((Entity)obj)) {
205+
if (obj instanceof EntityLiving && containsEntity((Entity)obj)) {
205206
((Entity)obj).applyEntityCollision(host);
206207
}
207208
continue;
@@ -226,7 +227,7 @@ public void updateCollidingEntities(EntityRollingStock host){
226227
}
227228
boolean skip=false;
228229
for(AbstractTrains t: host.consist) {
229-
if(t.getEntityId()==host.getEntityId()){
230+
if(t.getEntityId()==((CollisionBox) obj).host.getEntityId()){
230231
skip=true;
231232
}
232233
}

0 commit comments

Comments
 (0)