Skip to content

Commit

Permalink
feat: make CpFin/Joint/JointReverb changeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai-Z-JP committed Jan 5, 2024
1 parent 57a1aec commit 0c86127
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/main/java/jp/ngt/rtm/entity/train/EntityBogie.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,14 @@ protected void playJointSound() {
TrainConfig cfg = train.getModelSet().getConfig();
if (!cfg.muteJointSound) {
float pitch = (Math.abs(train.getSpeed()) / cfg.maxSpeed[cfg.maxSpeed.length - 1]) * 0.5F + 1.0F;
ResourceLocation sound = this.reverbSound ? JOINT_SOUND_REVERB : JOINT_SOUND;
String customSoundJoint = cfg.sound_Joint;
String customSoundJointReverb = cfg.sound_JointReverb;
ResourceLocation sound;
if (customSoundJoint != null && customSoundJointReverb != null) {
sound = this.reverbSound ? new ResourceLocation(customSoundJointReverb) : new ResourceLocation(customSoundJoint);
} else {
sound = this.reverbSound ? JOINT_SOUND_REVERB : JOINT_SOUND;
}
RTMCore.proxy.playSound(this, sound, 1.0F, pitch, RTMConfig.trainJointSoundRange);

int size = cfg.jointDelay[this.getBogieId()].length;
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/jp/ngt/rtm/entity/train/EntityTrainBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public abstract class EntityTrainBase extends EntityVehicleBase<TrainConfig> imp
public static final float TRAIN_WIDTH = 2.75F;
public static final float TRAIN_HEIGHT = 1.25F - 0.0625F;//レールに合わせ高さ修正

private static final ResourceLocation SOUND_CP_FIN = new ResourceLocation("rtm", "train.cp_fin");

public BogieController bogieController = new BogieController();
private Formation formation;

Expand Down Expand Up @@ -348,7 +350,16 @@ protected void updateAnimation() {
if (this.brakeAirCount >= MAX_AIR_COUNT) {
this.complessorActive = false;
//this.playBrakeReleaseSound(false);
RTMCore.proxy.playSound(this, new ResourceLocation("rtm", "train.cp_fin"), 1.0F, 1.0F);
String soundCpFin = this.getModelSet().getConfig().sound_CpFin;
ResourceLocation sound;

if (soundCpFin != null) {
String[] sa = soundCpFin.split(":");
sound = new ResourceLocation(sa[0], sa[1]);
} else {
sound = SOUND_CP_FIN;
}
RTMCore.proxy.playSound(this, sound, 1.0F, 1.0F);
}
} else {
if (this.brakeAirCount < MIN_AIR_COUNT) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/jp/ngt/rtm/modelpack/cfg/TrainConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public class TrainConfig extends VehicleBaseConfig implements IConfigWithType {
public boolean useVariableAcceleration;
public boolean useVariableDeceleration;

public String sound_CpFin;
public String sound_Joint;
public String sound_JointReverb;

@Override
public void init() {
super.init();
Expand All @@ -127,6 +131,10 @@ public void init() {
this.sound_BrakeRelease = this.fixSoundPath(this.sound_BrakeRelease);
this.sound_BrakeRelease2 = this.fixSoundPath(this.sound_BrakeRelease2);

this.sound_CpFin = this.fixSoundPath(this.sound_CpFin);
this.sound_Joint = this.fixSoundPath(this.sound_Joint);
this.sound_JointReverb = this.fixSoundPath(this.sound_JointReverb);

if (this.bogiePos == null) {
this.bogiePos = new float[][]{{0.0F, 0.0F, 7.125F}, {0.0F, 0.0F, -7.125F}};
}
Expand Down

0 comments on commit 0c86127

Please sign in to comment.