Fixed Carriage Sounds (Again)

This commit is contained in:
Rabbitminers 2023-04-03 19:33:17 +01:00
parent 1e80af3303
commit 4f176979de

View File

@ -31,6 +31,7 @@ public class CarriageSounds {
LoopingSound sharedWheelSoundSeated; LoopingSound sharedWheelSoundSeated;
LoopingSound sharedHonkSound; LoopingSound sharedHonkSound;
Couple<SoundEvent> bogeySounds;
SoundEvent closestBogeySound; SoundEvent closestBogeySound;
boolean arrived; boolean arrived;
@ -40,6 +41,9 @@ public class CarriageSounds {
public CarriageSounds(CarriageContraptionEntity entity) { public CarriageSounds(CarriageContraptionEntity entity) {
this.entity = entity; this.entity = entity;
bogeySounds = entity.getCarriage().bogeys.map(bogey ->
bogey != null ? bogey.getStyle().getSoundType()
: AllSoundEvents.TRAIN2.getMainEvent());
distanceFactor = LerpedFloat.linear(); distanceFactor = LerpedFloat.linear();
speedFactor = LerpedFloat.linear(); speedFactor = LerpedFloat.linear();
approachFactor = LerpedFloat.linear(); approachFactor = LerpedFloat.linear();
@ -83,11 +87,8 @@ public class CarriageSounds {
double distance1 = toBogey1.length(); double distance1 = toBogey1.length();
double distance2 = toBogey2.length(); double distance2 = toBogey2.length();
CarriageContraptionEntity cce = dce.entity.get(); Couple<CarriageBogey> bogeys = entity.getCarriage().bogeys;
if (cce != null) {
Couple<CarriageBogey> bogeys = cce.getCarriage().bogeys;
closestBogeySound = bogeys.get(distance1 > distance2).getStyle().getSoundType(); closestBogeySound = bogeys.get(distance1 > distance2).getStyle().getSoundType();
}
Vec3 toCarriage = distance1 > distance2 ? toBogey2 : toBogey1; Vec3 toCarriage = distance1 > distance2 ? toBogey2 : toBogey1;
double distance = Math.min(distance1, distance2); double distance = Math.min(distance1, distance2);