Skip to content

Commit 7741752

Browse files
drag, collision, and linking fixes
1 parent e40ae66 commit 7741752

File tree

4 files changed

+25
-30
lines changed

4 files changed

+25
-30
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ public void onUpdate() {
107107
@Override
108108
protected void updateFuelTrain(int amount) {
109109
//reduceExplosionChance = 1000;
110-
if (fuelTrain < 0) {
110+
if (fuelTrain < 1 || !this.isLocoTurnedOn()) {
111111
//hasUranium = false;
112-
motionX *= 0.8;
113-
motionZ *= 0.8;
112+
motionX *= 0.55;
113+
motionZ *= 0.55;
114114
}
115115
else {
116116
if(this.isLocoTurnedOn()) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,8 +2391,8 @@ public void moveMinecartOnRail(int i, int j, int k, double d) {
23912391
motionX *= 0.99D;
23922392
motionZ *= 0.99D;
23932393
} else {
2394-
motionX *= 1D;
2395-
motionZ *= 1D;
2394+
motionX *= 0.9D;
2395+
motionZ *= 0.9D;
23962396
}
23972397
if (motionX < -maxSpeed) {
23982398
motionX = -maxSpeed;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,22 +801,22 @@ public void onUpdate()
801801
motionZ *= 0.98;
802802
}
803803
}
804-
if (getState().equals("warm")) {
804+
else if (getState().equals("warm")) {
805805
this.extinguish();
806806
if (getCurrentMaxSpeed() >= (getMaxSpeed() * 0.7)) {
807807
motionX *= 0.94;
808808
motionZ *= 0.94;
809809
}
810810
}
811-
if (getState().equals("hot")) {
811+
else if (getState().equals("hot")) {
812812
this.extinguish();
813813
}
814-
if (getState().equals("too hot")) {
814+
else if (getState().equals("too hot")) {
815815
motionX *= 0.95;
816816
motionZ *= 0.95;
817817
worldObj.spawnParticle("largesmoke", posX, posY + 0.3, posZ, 0.0D, 0.0D, 0.0D);
818818
}
819-
if (getState().equals("broken")) {
819+
else if (getState().equals("broken")) {
820820
setFire(8);
821821
this.setCustomSpeed(0);// set speed to normal
822822
this.setAccel(0.000001);// simulate a break down

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

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,34 +94,29 @@ public void manageCollision(){
9494
} else {
9595
if (e instanceof CollisionBox) {
9696
if(((CollisionBox) e).host==null){
97-
return;
97+
continue;
9898
}
9999
EntityRollingStock entityOne = (((CollisionBox) e).host);
100100
if (entityOne.isAttaching && host.isAttaching) {
101-
if(entityOne instanceof Locomotive && host instanceof Locomotive){
102-
if(entityOne.canBeAdjusted(null) || host.canBeAdjusted(null)){
103-
LinkHandler.addStake(host, entityOne, true);
104-
LinkHandler.addStake(entityOne, host, true);
105-
} else {
106-
EntityPlayer p = host.getWorld().getClosestPlayerToEntity(host,32);
107-
if(p!=null){
108-
p.addChatComponentMessage(new ChatComponentText("One or more trains is not in towing mode."));
109-
p.addChatComponentMessage(new ChatComponentText("Use a Stake while sneaking to toggle towing mode."));
110-
}
111-
}
112-
} else {
101+
if(entityOne.canBeAdjusted(host) || host.canBeAdjusted(entityOne)){
113102
LinkHandler.addStake(host, entityOne, true);
114103
LinkHandler.addStake(entityOne, host, true);
104+
} else {
105+
EntityPlayer p = host.getWorld().getClosestPlayerToEntity(host,32);
106+
if(p!=null){
107+
p.addChatComponentMessage(new ChatComponentText("One or more trains is not in towing mode."));
108+
p.addChatComponentMessage(new ChatComponentText("Use a Stake while sneaking to toggle towing mode."));
109+
}
115110
}
116-
return;
117-
}
118-
double[] motion = CommonUtil.rotatePoint(0.005, 0,
119-
CommonUtil.atan2degreesf(e.posZ - host.posZ, e.posX - host.posX));
120-
host.addVelocity(-motion[0], 0, -motion[2]);
121-
if(entityOne instanceof Locomotive) {
122-
entityOne.addVelocity(motion[0]*0.2, 0, motion[2]*0.2);
123111
} else {
124-
entityOne.addVelocity(motion[0], 0, motion[2]);
112+
double[] motion = CommonUtil.rotatePoint(0.005, 0,
113+
CommonUtil.atan2degreesf(e.posZ - host.posZ, e.posX - host.posX));
114+
host.addVelocity(-motion[0], 0, -motion[2]);
115+
if (entityOne instanceof Locomotive) {
116+
entityOne.addVelocity(motion[0] * 0.2, 0, motion[2] * 0.2);
117+
} else {
118+
entityOne.addVelocity(motion[0], 0, motion[2]);
119+
}
125120
}
126121

127122
} else if (e instanceof EntityPlayer || e instanceof EntityLiving) {

0 commit comments

Comments
 (0)