Skip to content

Commit 6cccd99

Browse files
authored
Merge pull request #681 from fixrtm/fix-slow-train
fix: vehicle stops at low speed
2 parents 69b2686 + 269b34d commit 6cccd99

File tree

3 files changed

+44
-11
lines changed

3 files changed

+44
-11
lines changed

CHANGELOG-SNAPSHOTS.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The changelog for 2.0.23 and earlier is generated by [anatawa12's fork of `auto-
2626
- Directory based ModelPacks not working `#677`
2727
- Getting onto bogie of moving train may drive train opposite direction `#680`
2828
- This also reverts `#633` because it's broken for long train
29+
- Slow trains will get too slow `#681`
2930

3031
### Security
3132

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Thanks to prepare-changelog.sh, we have some macros.
4949
- we don't need to remove original signature of `RenderElectricalWiring.renderAllWire`
5050
- Directory based ModelPacks not working `#677`
5151
- Getting onto bogie of moving train may drive train opposite direction `#680`
52+
- Slow trains will get too slow `#681`
5253

5354
### Security
5455

src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityBogie.java.patch

+42-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
--- a/jp/ngt/rtm/entity/train/EntityBogie.java
22
+++ b/jp/ngt/rtm/entity/train/EntityBogie.java
3-
@@ -126,11 +126,11 @@
3+
@@ -44,10 +44,11 @@
4+
private TileEntityLargeRailCore currentRailObj;
5+
private RailMap currentRailMap;
6+
private final double[] posBuf = new double[3];
7+
private final float[] rotationBuf = new float[4];
8+
private int split = -1;
9+
+ private static final int SPLITS_PER_METER = 360; //(Minimum Speed[km/h] / 3.6 / 20[tick])^-1 e.g. (0.2/3.6/20)^-1 = 360
10+
private int prevPosIndex;
11+
private float jointDelay;
12+
private boolean reverbSound;
13+
private int jointIndex;
14+
private int existCount;
15+
@@ -126,11 +127,11 @@
416
return BogieController.MotionState.FLY;
517
} else {
618
RailMap railmap = this.currentRailMap;
719
int i = 0;
820
if (frontBogie != null && this.prevPosIndex != -1) {
921
- int j = (int)((speed + 0.25F) * 32.0F);
10-
+ int j = (int)((Math.abs(speed) + 0.25F) * 32.0F);
22+
+ int j = (int)((Math.abs(speed) + 0.25F) * SPLITS_PER_METER);
1123
int k = this.prevPosIndex - j;
1224
int l = this.prevPosIndex + j;
1325
int i1 = k < 0 ? 0 : k;
1426
int j1 = l > this.split ? this.split : l;
1527
double[] adouble = frontBogie.getPosBuf();
16-
@@ -171,11 +171,11 @@
28+
@@ -171,11 +172,11 @@
1729
this.rotationBuf[0] = f2;
1830
this.rotationBuf[1] = f3;
1931
this.rotationBuf[2] = f1;
@@ -26,7 +38,7 @@
2638
}
2739
}
2840

29-
@@ -196,18 +196,20 @@
41+
@@ -196,19 +197,21 @@
3042
TileEntityLargeRailCore tileentitylargerailcore = this.getRail(px, py, pz);
3143
if (tileentitylargerailcore == null) {
3244
return false;
@@ -43,14 +55,16 @@
4355
+ railMap = tileentitylargerailcore.getRailMap(this);
4456
}
4557

58+
- this.split = (int)(this.currentRailMap.getLength() * 32.0D);
4659
+ this.currentRailObj = tileentitylargerailcore;
4760
+ this.currentRailMap = railMap;
48-
this.split = (int)(this.currentRailMap.getLength() * 32.0D);
61+
+ this.split = (int)(this.currentRailMap.getLength() * SPLITS_PER_METER);
4962
this.prevPosIndex = -1;
5063
this.onChangeRail(tileentitylargerailcore);
5164
}
5265

53-
@@ -227,14 +229,17 @@
66+
return true;
67+
@@ -227,14 +230,17 @@
5468
return null;
5569
}
5670

@@ -72,7 +86,7 @@
7286
}
7387

7488
protected boolean reverseJointArray() {
75-
@@ -245,13 +250,13 @@
89+
@@ -245,13 +251,13 @@
7690

7791
protected void playJointSound() {
7892
EntityTrainBase entitytrainbase = this.getTrain();
@@ -88,7 +102,7 @@
88102
int j = this.reverseJointArray() ? i - this.jointIndex - 1 : this.jointIndex;
89103
++this.jointIndex;
90104
int k = this.reverseJointArray() ? i - this.jointIndex - 1 : this.jointIndex;
91-
@@ -287,14 +292,23 @@
105+
@@ -287,14 +293,23 @@
92106

93107
public final void onUpdate() {
94108
if (!this.world.isRemote && !this.tracked) {
@@ -112,7 +126,7 @@
112126
}
113127

114128
public void onBogieUpdate() {
115-
@@ -309,11 +323,11 @@
129+
@@ -309,11 +324,11 @@
116130

117131
}
118132

@@ -125,7 +139,24 @@
125139

126140
}
127141

128-
@@ -491,10 +505,14 @@
142+
@@ -349,13 +364,14 @@
143+
144+
public boolean attackEntityFrom(DamageSource par1, float par2) {
145+
if (this.getTrain() != null && !this.getTrain().isDead) {
146+
return this.getTrain().attackEntityFrom(par1, par2);
147+
} else {
148+
- if (!this.world.isRemote) {
149+
+ /*if (!this.world.isRemote) {
150+
this.setDead();
151+
- }
152+
+ }*/
153+
+ this.setDead();
154+
155+
return true;
156+
}
157+
}
158+
159+
@@ -491,10 +507,14 @@
129160
public void addVelocity(double par1, double par3, double par5) {
130161
}
131162

@@ -140,7 +171,7 @@
140171
}
141172
} else if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() == RTMItem.paddle) {
142173
return true;
143-
@@ -578,6 +596,18 @@
174+
@@ -578,6 +598,18 @@
144175
}
145176

146177
public int getProhibitedAction() {

0 commit comments

Comments
 (0)