|
7 | 7 | import net.minecraft.entity.LivingEntity;
|
8 | 8 | import net.minecraft.entity.passive.AbstractHorseEntity;
|
9 | 9 | import net.minecraft.entity.player.PlayerEntity;
|
| 10 | +import net.minecraft.registry.RegistryKey; |
10 | 11 | import net.minecraft.registry.tag.FluidTags;
|
11 | 12 | import net.minecraft.util.math.BlockPos;
|
12 | 13 | import org.jetbrains.annotations.Nullable;
|
|
15 | 16 | import eu.ha3.presencefootsteps.config.Variator;
|
16 | 17 | import eu.ha3.presencefootsteps.mixins.ILivingEntity;
|
17 | 18 | import eu.ha3.presencefootsteps.sound.State;
|
| 19 | +import eu.ha3.presencefootsteps.util.Lerp; |
18 | 20 | import eu.ha3.presencefootsteps.util.PlayerUtil;
|
19 | 21 | import eu.ha3.presencefootsteps.sound.Options;
|
20 | 22 | import eu.ha3.presencefootsteps.sound.SoundEngine;
|
21 | 23 | import eu.ha3.presencefootsteps.world.Association;
|
22 | 24 | import eu.ha3.presencefootsteps.world.AssociationPool;
|
| 25 | +import eu.ha3.presencefootsteps.world.BiomeVarianceLookup; |
23 | 26 | import eu.ha3.presencefootsteps.world.Solver;
|
24 | 27 | import eu.ha3.presencefootsteps.world.SoundsKey;
|
25 | 28 | import eu.ha3.presencefootsteps.world.Substrates;
|
@@ -58,20 +61,40 @@ class TerrestrialStepSoundGenerator implements StepSoundGenerator {
|
58 | 61 | protected final MotionTracker motionTracker = new MotionTracker(this);
|
59 | 62 | protected final AssociationPool associations;
|
60 | 63 |
|
| 64 | + private final Lerp biomePitch = new Lerp(); |
| 65 | + private final Lerp biomeVolume = new Lerp(); |
| 66 | + |
61 | 67 | public TerrestrialStepSoundGenerator(LivingEntity entity, SoundEngine engine, Modifier<TerrestrialStepSoundGenerator> modifier) {
|
62 | 68 | this.entity = entity;
|
63 | 69 | this.engine = engine;
|
64 | 70 | this.modifier = modifier;
|
65 | 71 | this.associations = new AssociationPool(entity, engine);
|
66 | 72 | }
|
67 | 73 |
|
| 74 | + @Override |
| 75 | + public float getLocalPitch(float tickDelta) { |
| 76 | + return biomePitch.get(tickDelta); |
| 77 | + } |
| 78 | + |
| 79 | + @Override |
| 80 | + public float getLocalVolume(float tickDelta) { |
| 81 | + return biomeVolume.get(tickDelta); |
| 82 | + } |
| 83 | + |
68 | 84 | @Override
|
69 | 85 | public MotionTracker getMotionTracker() {
|
70 | 86 | return motionTracker;
|
71 | 87 | }
|
72 | 88 |
|
73 | 89 | @Override
|
74 | 90 | public void generateFootsteps() {
|
| 91 | + BiomeVarianceLookup.BiomeVariance variance = entity.getWorld().getBiome(entity.getBlockPos()).getKey().map(RegistryKey::getValue).map(key -> { |
| 92 | + return engine.getIsolator().biomes().lookup(key); |
| 93 | + }).orElse(BiomeVarianceLookup.BiomeVariance.DEFAULT); |
| 94 | + |
| 95 | + biomePitch.update(variance.pitch(), 0.01F); |
| 96 | + biomeVolume.update(variance.volume(), 0.01F); |
| 97 | + |
75 | 98 | motionTracker.simulateMotionData(entity);
|
76 | 99 | simulateFootsteps();
|
77 | 100 | simulateAirborne();
|
|
0 commit comments