forked from ChomeNS/chipmunkmod
add pitch to music
chipmunk sex bot chipmunk sex mod real
This commit is contained in:
parent
2d60606de3
commit
b3dcef2232
3 changed files with 39 additions and 1 deletions
|
@ -24,6 +24,8 @@ import java.util.List;
|
|||
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
|
||||
import static com.mojang.brigadier.arguments.FloatArgumentType.floatArg;
|
||||
import static com.mojang.brigadier.arguments.FloatArgumentType.getFloat;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||
import static com.mojang.brigadier.arguments.LongArgumentType.getLong;
|
||||
|
@ -81,6 +83,7 @@ public class MusicCommand {
|
|||
.executes(instance::gotoCommand)
|
||||
)
|
||||
)
|
||||
|
||||
.then(
|
||||
literal("useCore")
|
||||
.then(
|
||||
|
@ -88,6 +91,14 @@ public class MusicCommand {
|
|||
.executes(instance::useCore)
|
||||
)
|
||||
)
|
||||
|
||||
.then(
|
||||
literal("pitch")
|
||||
.then(
|
||||
argument("pitch", floatArg())
|
||||
.executes(instance::pitch)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -279,4 +290,21 @@ public class MusicCommand {
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int pitch (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
final float pitch = getFloat(context, "pitch");
|
||||
|
||||
SongPlayer.INSTANCE.pitch(pitch);
|
||||
|
||||
source.sendFeedback(
|
||||
Text.translatable(
|
||||
"Set the pitch to: %s",
|
||||
Text.literal(String.valueOf(pitch))
|
||||
).formatted(Formatting.GREEN)
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import land.chipmunk.chipmunkmod.song.Note;
|
|||
import land.chipmunk.chipmunkmod.song.Song;
|
||||
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
||||
import land.chipmunk.chipmunkmod.song.SongLoaderThread;
|
||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -43,6 +44,8 @@ public class SongPlayer {
|
|||
|
||||
@Getter @Setter private boolean useCore = true;
|
||||
|
||||
@Getter @Setter private float pitch = 0;
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
public SongPlayer (MinecraftClient client) {
|
||||
|
@ -204,7 +207,7 @@ public class SongPlayer {
|
|||
while (currentSong.reachedNextNote()) {
|
||||
final Note note = currentSong.getNextNote();
|
||||
|
||||
final float floatingPitch = (float) Math.pow(2, (note.pitch - 12) / 12.0);
|
||||
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);
|
||||
|
||||
try {
|
||||
if (!useCore) {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package land.chipmunk.chipmunkmod.util;
|
||||
|
||||
public class MathUtilities {
|
||||
public static float clamp (float value, float min, float max) {
|
||||
return Math.max(Math.min(value, max), min);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue