Traincraft Change Max Speed
ilyakorolevv opened this issue · 4 comments
Hello! I'm looking for a way to change max speed to one train model, being NY Subway locomotive, it only goes up to 65 km/h, even slower under the load, so if you know where is the file in the code, I'd appreciate it very much
you'll have to download the source code, change the values, then compile it.
there's a build option in the setup.bat/setup.sh files to automate the build process, be sure to read the instructions they provide, it will tell you where the jar file was placed.
as for what/where to change, you got two options.
Classic/Static option:
the EnumTrains class still holds all the static values for all trains and stock, from weight to speed and MHP.
for this one, the 1327 is the mhp, and the 98 is the max speed.
https://github.com/EternalBlueFlame/Traincraft-5/blob/TC4.5-1.7.10/src/main/java/train/common/library/EnumTrains.java#L216-L217
Modern/Dynamic option:
some recent API changes let you add the following code to an entity class to change the values in more dynamic/less convoluted way. So if you wanna do something fancy like change max speed based on the amount of fuel, or if the riding entity is an instance of EntityPlayer and it's display name is something specific, or if you don't wanna look at the train wreck that is the enum, you can do stuff like that this way.
@Override
public float getMaxSpeed() {return 89;}
@Override
public int getPower(){return 1327;}
the class for this particular train is:
https://github.com/EternalBlueFlame/Traincraft-5/blob/TC4.5-1.7.10/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramNY.java
Jar files are compiled code and can not be edited, textures aren't compiled so those can be changed without issue but code is a different case.
In the case of code you have to download the git branch as a zip, extract that, then edit the code and run either the setup.bat file (windows) or the setup.sh file (Mac/Linux) and select the build option.