Add time-varying pitch modulation and built-in procedural glitch effects

This commit is contained in:
rardog
2026-09-24 13:29:51 +03:00
parent 2b9c376bbc
commit cd3672a274
6 changed files with 460 additions and 2 deletions
@@ -33,6 +33,9 @@ public class SoundSettings {
public boolean crossfade;
public ActivationMode activationMode = ActivationMode.CLICK;
public RedstoneMode redstoneMode = RedstoneMode.EDGE;
public PitchModulationMode pitchMode = PitchModulationMode.STATIC;
public float pitchModSpeed = 1.0f;
public float pitchModDepth = 0.25f;
public CompoundNBT toNbt() {
CompoundNBT tag = new CompoundNBT();
@@ -57,6 +60,9 @@ public class SoundSettings {
tag.putBoolean("crossfade", this.crossfade);
tag.putString("activationMode", this.activationMode.name());
tag.putString("redstoneMode", this.redstoneMode.name());
tag.putString("pitchMode", this.pitchMode.name());
tag.putFloat("pitchModSpeed", this.pitchModSpeed);
tag.putFloat("pitchModDepth", this.pitchModDepth);
return tag;
}
@@ -125,6 +131,15 @@ public class SoundSettings {
if (tag.contains("redstoneMode")) {
s.redstoneMode = SoundSettings.parse(tag.getString("redstoneMode"), RedstoneMode.EDGE);
}
if (tag.contains("pitchMode")) {
s.pitchMode = SoundSettings.parse(tag.getString("pitchMode"), PitchModulationMode.STATIC);
}
if (tag.contains("pitchModSpeed")) {
s.pitchModSpeed = tag.getFloat("pitchModSpeed");
}
if (tag.contains("pitchModDepth")) {
s.pitchModDepth = tag.getFloat("pitchModDepth");
}
SoundSettings.sanitizeInPlace(s);
return s;
}
@@ -175,6 +190,15 @@ public class SoundSettings {
if (s.redstoneMode == null) {
s.redstoneMode = RedstoneMode.EDGE;
}
if (s.pitchMode == null) {
s.pitchMode = PitchModulationMode.STATIC;
}
if (!Float.isFinite(s.pitchModSpeed) || s.pitchModSpeed < 0.05f || s.pitchModSpeed > 20.0f) {
s.pitchModSpeed = 1.0f;
}
if (!Float.isFinite(s.pitchModDepth) || s.pitchModDepth < 0.0f || s.pitchModDepth > 2.0f) {
s.pitchModDepth = 0.25f;
}
}
private static <E extends Enum<E>> E parse(String raw, E fallback) {