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:
Stephen Seo 2024-10-23 15:01:31 +09:00
parent 2b4909e1f4
commit 14581183e7
4 changed files with 19 additions and 5 deletions

View file

@ -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;
} }

View file

@ -1483,4 +1483,14 @@ public class ClientProxy extends CommonProxy {
public void showClientConfigGui() { public void showClientConfigGui() {
Minecraft.getInstance().setScreen(new ClientConfigGui()); Minecraft.getInstance().setScreen(new ClientConfigGui());
} }
@Override
public void pauseMCMusic() {
Minecraft.getInstance().getSoundManager().pause();
}
@Override
public void resumeMCMusic() {
Minecraft.getInstance().getSoundManager().resume();
}
} }

View file

@ -175,4 +175,7 @@ public class CommonProxy
public <MSG> void handlePacket(MSG msg,CustomPayloadEvent.Context ctx) {} public <MSG> void handlePacket(MSG msg,CustomPayloadEvent.Context ctx) {}
public void showClientConfigGui() {} public void showClientConfigGui() {}
public void pauseMCMusic() {}
public void resumeMCMusic() {}
} }

View file

@ -52,6 +52,7 @@ public class PacketBattlePing {
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui(); TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged(); TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.decisionSeconds); TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.decisionSeconds);
TurnBasedMinecraftMod.proxy.pauseMCMusic();
}); });
ctx.setPacketHandled(true); ctx.setPacketHandled(true);
} }