Disable midi playback
Controlling midi volume with only Java library stuff doesn't appear to work, so it has been disabled for now.
This commit is contained in:
parent
ac1b77d58a
commit
c4811e2271
5 changed files with 27 additions and 20 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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/";
|
||||
|
|
|
@ -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 <here>
|
||||
|
|
|
@ -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"],
|
||||
|
|
Loading…
Reference in a new issue