From c4811e22717821089af5221cf32e81ef50c41bd0 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sat, 14 Nov 2020 15:10:14 +0900 Subject: [PATCH] Disable midi playback Controlling midi volume with only Java library stuff doesn't appear to work, so it has been disabled for now. --- build.gradle | 2 +- .../client/BattleMusic.java | 37 +++++++++++-------- .../common/TurnBasedMinecraftMod.java | 2 +- src/main/resources/META-INF/mods.toml | 2 +- src/main/resources/mcmod.info | 4 +- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index 112e2b0..5d0e45c 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ apply plugin: 'eclipse' //apply plugin: 'maven-publish' apply plugin: 'com.github.johnrengelman.shadow' -version = "1.12" +version = "1.13" group = "com.burnedkirby.TurnBasedMinecraft" archivesBaseName = "TurnBasedMinecraft" diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleMusic.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleMusic.java index 13da248..f1588a0 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleMusic.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleMusic.java @@ -4,7 +4,9 @@ import java.io.*; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicBoolean; +import javax.sound.midi.MidiChannel; import javax.sound.midi.MidiSystem; +import javax.sound.midi.MidiUnavailableException; import javax.sound.midi.Sequencer; import javax.sound.sampled.*; @@ -41,22 +43,15 @@ public class BattleMusic mp3StreamThread = null; mp3StreamRunnable = null; - try { - sequencer = MidiSystem.getSequencer(); - sequencer.open(); - } catch (Throwable t) { - logger.error("Failed to load midi sequencer"); - t.printStackTrace(); - sequencer = null; - } - // try { -// clip = AudioSystem.getClip(); -// } catch(Throwable t) { -// logger.error("Failed to load clip (for wav)"); +// sequencer = MidiSystem.getSequencer(); +// sequencer.open(); +// } catch (Throwable t) { +// logger.error("Failed to load midi sequencer"); // t.printStackTrace(); -// clip = null; +// sequencer = null; // } + sequencer = null; // midi disabled File battleMusicFolder = new File(TurnBasedMinecraftMod.MUSIC_BATTLE); File sillyMusicFolder = new File(TurnBasedMinecraftMod.MUSIC_SILLY); @@ -88,7 +83,8 @@ public class BattleMusic return false; } String ext = name.substring(extIndex + 1).toLowerCase(); - return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3"); +// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3"); + return ext.equals("wav") || ext.equals("mp3"); // midi disabled } }); for(File f : battleFiles) @@ -107,7 +103,8 @@ public class BattleMusic return false; } String ext = name.substring(extIndex + 1).toLowerCase(); - return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3"); +// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3"); + return ext.equals("wav") || ext.equals("mp3"); // midi disabled } }); for(File f : sillyFiles) @@ -211,6 +208,16 @@ public class BattleMusic return; } + try { + for (MidiChannel channel : MidiSystem.getSynthesizer().getChannels()) { + channel.controlChange(7, (int)(volume * 127)); + } + } catch (MidiUnavailableException e) { + logger.error("Failed to set Midi volume"); + e.printStackTrace(); + return; + } + sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY); sequencer.start(); diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java index b2d25ed..6ebd561 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java @@ -35,7 +35,7 @@ public class TurnBasedMinecraftMod { public static final String MODID = "com_burnedkirby_turnbasedminecraft"; public static final String NAME = "Turn Based Minecraft Mod"; - public static final String VERSION = "1.12"; + public static final String VERSION = "1.13"; public static final String CONFIG_FILENAME = "TBM_Config.toml"; public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml"; public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/"; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a2f0475..6b0af67 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -15,7 +15,7 @@ license="MIT" # The modid of the mod modId="com_burnedkirby_turnbasedminecraft" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -version="1.12" #mandatory +version="1.13" #mandatory # A display name for the mod displayName="TurnBasedMinecraftMod" #mandatory # A URL to query for updates for this mod. See the JSON update specification diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index af95c02..6e8c08f 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,8 +3,8 @@ "modid": "com_burnedkirby_turnbasedminecraft", "name": "Turn Based Minecraft", "description": "Changes battles to be turn-based.", - "version": "${version}", - "mcversion": "${mcversion}", + "version": "1.13", + "mcversion": "1.16.3", "url": "", "updateUrl": "", "authorList": ["Stephen Seo"],