Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940package net.codexarchonic.infinity.options;
import net.codexarchonic.infinity.util.core.NbtUtils;import net.minecraft.nbt.CompoundTag;import java.util.function.Function;
import static net.codexarchonic.infinity.util.core.NbtUtils.getFloat;
public interface PitchShifter { Function<Float, Float> applier();
enum Empty implements PitchShifter { INSTANCE; @Override public Function<Float, Float> applier() { return Function.identity(); } } record Constant(float value) implements PitchShifter { @Override public Function<Float, Float> applier() { return f -> value; } } record Add(float value) implements PitchShifter { @Override public Function<Float, Float> applier() { return f -> f + value; } }
static PitchShifter decode(CompoundTag comp) { return switch(NbtUtils.getString(comp, "type")) { case "constant" -> new Constant(getFloat(comp, "value", 1)); case "add" -> new Add(getFloat(comp, "value", 1)); default -> Empty.INSTANCE; }; }}