Pause MCMusic when "Ping" packet is received
This prevents Minecraft's music from playing at the same time as user-provided battle/silly music.
This commit is contained in:
parent
aac81f20bc
commit
7a5c9506c9
4 changed files with 16 additions and 2 deletions
|
@ -180,7 +180,7 @@ public class BattleMusic
|
||||||
if(initialized && next != null)
|
if(initialized && next != null)
|
||||||
{
|
{
|
||||||
logger.debug("play called with file " + next.getName() + " and vol " + volume);
|
logger.debug("play called with file " + next.getName() + " and vol " + volume);
|
||||||
Minecraft.getInstance().getSoundManager().pause();
|
TurnBasedMinecraftMod.proxy.pauseMCMusic();
|
||||||
String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase();
|
String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase();
|
||||||
if(suffix.equals("mid") && sequencer != null)
|
if(suffix.equals("mid") && sequencer != null)
|
||||||
{
|
{
|
||||||
|
@ -362,7 +362,7 @@ public class BattleMusic
|
||||||
}
|
}
|
||||||
if(resumeMCSounds)
|
if(resumeMCSounds)
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().getSoundManager().resume();
|
TurnBasedMinecraftMod.proxy.resumeMCMusic();
|
||||||
}
|
}
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1482,4 +1482,14 @@ public class ClientProxy extends CommonProxy {
|
||||||
public void showClientConfigGui() {
|
public void showClientConfigGui() {
|
||||||
Minecraft.getInstance().setScreen(new ClientConfigGui(null, null));
|
Minecraft.getInstance().setScreen(new ClientConfigGui(null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pauseMCMusic() {
|
||||||
|
Minecraft.getInstance().getSoundManager().pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resumeMCMusic() {
|
||||||
|
Minecraft.getInstance().getSoundManager().resume();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,4 +177,7 @@ public class CommonProxy
|
||||||
public static final StreamCodec<ByteBuf, Collection<Integer>> COLLECTION_INT_CODEC = ByteBufCodecs.INT.apply(ByteBufCodecs.collection(ArrayList::new));
|
public static final StreamCodec<ByteBuf, Collection<Integer>> COLLECTION_INT_CODEC = ByteBufCodecs.INT.apply(ByteBufCodecs.collection(ArrayList::new));
|
||||||
|
|
||||||
public void showClientConfigGui() {}
|
public void showClientConfigGui() {}
|
||||||
|
|
||||||
|
public void pauseMCMusic() {}
|
||||||
|
public void resumeMCMusic() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public record PacketBattlePing(int battleID, int remainingSeconds) implements Cu
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
|
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds);
|
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds);
|
||||||
|
TurnBasedMinecraftMod.proxy.pauseMCMusic();
|
||||||
}).exceptionally(e -> {
|
}).exceptionally(e -> {
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage()));
|
ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage()));
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue