forked from Hurricaaane/Presence-Footsteps
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # src/main/java/eu/ha3/presencefootsteps/sound/generator/TerrestrialStepSoundGenerator.java
- Loading branch information
Showing
19 changed files
with
555 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package eu.ha3.presencefootsteps.util; | ||
|
||
import net.minecraft.util.math.MathHelper; | ||
|
||
public class Lerp { | ||
public float previous; | ||
public float current; | ||
|
||
public void update(float newTarget, float rate) { | ||
previous = current; | ||
if (current < newTarget) { | ||
current = Math.min(current + rate, newTarget); | ||
} | ||
if (current > newTarget) { | ||
current = Math.max(current - rate, newTarget); | ||
} | ||
} | ||
|
||
public float get(float tickDelta) { | ||
return MathHelper.lerp(tickDelta, previous, current); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/eu/ha3/presencefootsteps/world/BiomeVarianceLookup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package eu.ha3.presencefootsteps.world; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.mojang.datafixers.util.Pair; | ||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.JsonOps; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
|
||
import eu.ha3.presencefootsteps.util.JsonObjectWriter; | ||
import net.minecraft.sound.BlockSoundGroup; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class BiomeVarianceLookup implements Index<Identifier, BiomeVarianceLookup.BiomeVariance> { | ||
private final Map<Identifier, BiomeVariance> entries = new HashMap<>(); | ||
|
||
@Override | ||
public BiomeVariance lookup(Identifier key) { | ||
return entries.getOrDefault(key, BiomeVariance.DEFAULT); | ||
} | ||
|
||
@Override | ||
public boolean contains(Identifier key) { | ||
return entries.containsKey(key); | ||
} | ||
|
||
@Override | ||
public void add(String key, JsonElement value) { | ||
BiomeVariance.CODEC.decode(JsonOps.INSTANCE, value).result().map(Pair::getFirst).ifPresent(i -> { | ||
entries.put(Identifier.of(key), i); | ||
}); | ||
} | ||
|
||
@Override | ||
public void writeToReport(boolean full, JsonObjectWriter writer, Map<String, BlockSoundGroup> groups) throws IOException { | ||
} | ||
|
||
public record BiomeVariance(float volume, float pitch) { | ||
public static final BiomeVariance DEFAULT = new BiomeVariance(1, 1); | ||
static final Codec<BiomeVariance> CODEC = RecordCodecBuilder.create(i -> i.group( | ||
Codec.FLOAT.fieldOf("volume").forGetter(BiomeVariance::volume), | ||
Codec.FLOAT.fieldOf("pitch").forGetter(BiomeVariance::pitch) | ||
).apply(i, BiomeVariance::new)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.