Add ability to loop the same song via command
This commit is contained in:
parent
8de17aacc8
commit
281048f33a
@ -214,7 +214,24 @@ public class DiscjockeyCommand {
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
.then(literal("loop")
|
||||
.executes(context -> {
|
||||
context.getSource().sendFeedback(Text.translatable(Main.MOD_ID + ".loop_status", Main.SONG_PLAYER.loopSong ? "yes" : "no"));
|
||||
return 1;
|
||||
})
|
||||
.then(literal("yes")
|
||||
.executes(context -> {
|
||||
Main.SONG_PLAYER.loopSong = true;
|
||||
context.getSource().sendFeedback(Text.translatable(Main.MOD_ID + ".loop_enabled"));
|
||||
return 1;
|
||||
}))
|
||||
.then(literal("no")
|
||||
.executes(context -> {
|
||||
Main.SONG_PLAYER.loopSong = false;
|
||||
context.getSource().sendFeedback(Text.translatable(Main.MOD_ID + ".loop_disabled"));
|
||||
return 1;
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
||||
private int tuneInitialUntunedBlocks = -1;
|
||||
private HashMap<BlockPos, Pair<Integer, Long>> notePredictions = new HashMap<>();
|
||||
public boolean didSongReachEnd = false;
|
||||
public boolean loopSong = false;
|
||||
|
||||
public SongPlayer() {
|
||||
Main.TICK_LISTENERS.add(this);
|
||||
@ -205,6 +206,9 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
||||
if (index >= song.notes.length) {
|
||||
stop();
|
||||
didSongReachEnd = true;
|
||||
if(loopSong) {
|
||||
start(song);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -31,6 +31,9 @@
|
||||
"disc_jockey.mapped_instruments": "Mapped instruments: %s",
|
||||
"disc_jockey.no_mapped_instruments": "No instruments mapped, yet.",
|
||||
"disc_jockey.instrument_maps_cleared": "Instrument mappings cleared.",
|
||||
"disc_jockey.loop_status": "Loop song: %s",
|
||||
"disc_jockey.loop_enabled": "Enabled looping of current song.",
|
||||
"disc_jockey.loop_disabled": "Disabled looping of current song.",
|
||||
"disc_jockey.warning": "WARNING!!! This mod is very likely to get false flagged as hacks, please contact a server administrator before using this mod! (You can disable this warning in the mod settings)",
|
||||
"key.category.disc_jockey": "Disc Jockey",
|
||||
"disc_jockey.key_bind.open_screen": "Open song selection screen",
|
||||
|
Loading…
x
Reference in New Issue
Block a user