Compare commits
8 commits
f687dfdaf3
...
3a6d800745
Author | SHA1 | Date | |
---|---|---|---|
3a6d800745 | |||
56a9db15ad | |||
18076715e0 | |||
8551aae80b | |||
cc7ef71384 | |||
6d8384ce04 | |||
0d0c0ca08c | |||
74291dde8f |
9 changed files with 191 additions and 41 deletions
|
@ -1,4 +1,4 @@
|
|||
name: Build TurnBasedMC and store Artifact
|
||||
name: Build TurnBasedMC and create Release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
|||
steps:
|
||||
- run: git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod.git TurnBasedMinecraftMod
|
||||
- run: cd TurnBasedMinecraftMod && git checkout ${GITHUB_REF_NAME}
|
||||
- run: cd TurnBasedMinecraftMod && sed -i '/org.gradle.jvmargs/s/Xmx[0-9]\+m/Xmx700m/' gradle.properties
|
||||
- run: cd TurnBasedMinecraftMod && sed -i '/org.gradle.jvmargs/s/Xmx[0-9]\+m/Xmx1024m/' gradle.properties
|
||||
- run: cd TurnBasedMinecraftMod && ./gradlew --console=plain build
|
||||
- run: cd TurnBasedMinecraftMod/build/libs && find . -type f -exec sha256sum '{}' ';' -exec bash -c 'sha256sum {} >> sha256sums.txt' ';' && java --version >> javaVersion.txt && javac --version >> javaVersion.txt
|
||||
- name: Create release and attach jar
|
||||
|
@ -24,6 +24,7 @@ jobs:
|
|||
\"name\": \"TurnBasedMinecraftMod version ${GITHUB_REF_NAME}\",
|
||||
\"body\": \"See the [Changelog](https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod/src/branch/master/Changelog.md)
|
||||
|
||||
(Using OpenJDK Java.)
|
||||
$(javac --version)
|
||||
$(find TurnBasedMinecraftMod/build/libs -regex '.*[0-9].jar$' -exec sha256sum '{}' ';')\",
|
||||
\"tag_name\": \"${GITHUB_REF_NAME}\"
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
# Upcoming changes
|
||||
|
||||
# Version Forge-1.25.0
|
||||
|
||||
Remove usage of "shadow jar" in build.gradle, and use jarJar instead.
|
||||
|
||||
Add new dependency `j-ogg-vorbis`.
|
||||
|
||||
Implement playing Vorbis encoded .ogg files for battle/silly music.
|
||||
|
||||
# Version NeoForge-1.24.0
|
||||
|
||||
Update to NeoForge 1.20.2-20.2.88.
|
||||
|
|
28
README.md
28
README.md
|
@ -45,14 +45,18 @@ When playing multiplayer, some configuration of the config on the server may be
|
|||
between them
|
||||
- Supports use of the vanilla Minecraft bow and arrows (have bow selected when
|
||||
in battle)
|
||||
- Supports custom battle music to be played when fighting enemies. (They must be
|
||||
placed in `.minecraft/config/TurnBasedMinecraft/Music/battle` or
|
||||
`.minecraft/config/TurnBasedMinecraft/Music/silly`. Client-side config determines
|
||||
which song plays in battle for the client. only `.wav`, ~~`.mid`~~, and `.mp3` files
|
||||
supported. ~~Only `.mid` files are not affected by volume options (master and
|
||||
music sliders))~~ Midi file playback has been disabled for now due to lack of volume
|
||||
control issues. MP3 file playback sometimes fails, but seems to work better when the
|
||||
file is as "barebones" as possible (no album art metadata in the file).
|
||||
- Supports custom battle music to be played when fighting enemies. (They must
|
||||
be placed in `.minecraft/config/TurnBasedMinecraft/Music/battle` or
|
||||
`.minecraft/config/TurnBasedMinecraft/Music/silly`. Client-side config
|
||||
determines which song plays in battle for the client. only `.wav`,
|
||||
~~`.mid`~~, `.mp3`, and `.ogg` files supported. ~~Only `.mid` files are not
|
||||
affected by volume options (master and music sliders))~~ Midi file playback
|
||||
has been disabled for now due to lack of volume control issues. MP3 file
|
||||
playback sometimes fails, but seems to work better when the file is as
|
||||
"barebones" as possible (no album art metadata in the file). It is recommended
|
||||
to use `.ogg` files for music. Note that ogg Vorbis is supported, and NOT ogg
|
||||
Opus. One can convert to ogg Vorbis with ffmpeg like this: `ffmpeg -i
|
||||
<my_music_file_to_convert> -map a:0 -c:a libvorbis output.ogg`.
|
||||
- Config allows limiting number of combatants in turn-based battle.
|
||||
- Config can be modified (server-side) to add entries of mobs from other mods.
|
||||
(by default an unknown mob cannot enter turn-based battle, so the config must be
|
||||
|
@ -65,7 +69,8 @@ configured for them.)
|
|||
# Building
|
||||
|
||||
Simply invoke `./gradlew build` in the mod directory and after some time the
|
||||
finished jar will be saved at "build/libs/TurnBasedMinecraft-Forge-1.24.0.jar"
|
||||
finished jar will be saved at
|
||||
`build/libs/TurnBasedMinecraft-Forge-1.25.0-all.jar`
|
||||
|
||||
# Reproducibility
|
||||
|
||||
|
@ -74,8 +79,9 @@ more details.
|
|||
|
||||
# Other notes
|
||||
|
||||
This mod uses [shadow](https://github.com/johnrengelman/shadow) which is
|
||||
licenced under the [Apache License 2.0](https://github.com/johnrengelman/shadow/blob/master/LICENSE).
|
||||
This mod uses [j-ogg-vorbis](https://github.com/stephengold/j-ogg-all) available
|
||||
from [http://www.j-ogg.de](http://www.j-ogg.de) and copyrighted by Tor-Einar
|
||||
Jarnbjo.
|
||||
|
||||
This mod also uses [JavaMP3](https://github.com/kevinstadler/JavaMP3)
|
||||
which is licensed under the [MIT License](https://github.com/kevinstadler/JavaMP3/blob/master/LICENSE).
|
||||
|
|
|
@ -4,6 +4,19 @@ Starting with version 1.24.0 of this mod, this file will list what version of
|
|||
Java was used to compile the jars. In theory, using the same version of Java
|
||||
should result in an identical jar due to reproducible builds.
|
||||
|
||||
## Forge 1.25.0
|
||||
|
||||
$ java --version
|
||||
openjdk 17.0.9 2023-10-17
|
||||
OpenJDK Runtime Environment (build 17.0.9+8)
|
||||
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
|
||||
|
||||
$ javac --version
|
||||
javac 17.0.9
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.25.0-all.jar
|
||||
51ef854552b180df68969f4cec6fdc8716ef519b947948b9e5f4ce9953d00162 build/libs/TurnBasedMinecraft-Forge-1.25.0-all.jar
|
||||
|
||||
## NeoForge 1.24.0
|
||||
|
||||
$ java --version
|
||||
|
|
39
build.gradle
39
build.gradle
|
@ -3,16 +3,17 @@ plugins {
|
|||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
}
|
||||
|
||||
version = "1.24.0"
|
||||
version = "1.25.0"
|
||||
group = "com.burnedkirby.TurnBasedMinecraft"
|
||||
archivesBaseName = "TurnBasedMinecraft-Forge"
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
jarJar.enable()
|
||||
|
||||
minecraft {
|
||||
// The mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
||||
|
@ -137,11 +138,10 @@ sourceSets.main.resources { srcDir 'src/generated/resources' }
|
|||
// }
|
||||
//}
|
||||
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
configurations {
|
||||
shade
|
||||
impelmentation.extendsFrom shade
|
||||
repositories {
|
||||
flatDir {
|
||||
dir 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -161,9 +161,16 @@ dependencies {
|
|||
// For more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
implementation files('libs/javamp3-1.0.3.jar')
|
||||
//implementation files('libs/javamp3-1.0.3.jar')
|
||||
implementation 'fr.delthas:javamp3:1.0.3'
|
||||
|
||||
shade files('libs/javamp3-1.0.3.jar')
|
||||
implementation 'com.github.stephengold:j-ogg-vorbis:1.0.4'
|
||||
|
||||
jarJar(group: 'fr.delthas', name: 'javamp3', version: '[1.0.0,2.0.0)') {
|
||||
jarJar.pin(it, '1.0.3')
|
||||
}
|
||||
|
||||
jarJar(group: 'com.github.stephengold', name: 'j-ogg-vorbis', version: '[1.0.4, 2.0.0)')
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
|
@ -203,20 +210,6 @@ jar {
|
|||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveClassifier = ''
|
||||
//project.configurations.shadow.setTransitive(true);
|
||||
configurations = [project.configurations.shade]
|
||||
relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas'
|
||||
finalizedBy 'reobfShadowJar'
|
||||
}
|
||||
|
||||
assemble.dependsOn shadowJar
|
||||
|
||||
reobf {
|
||||
shadowJar {} // reobfuscate the shadowed jar
|
||||
}
|
||||
|
||||
// Reproducible Builds
|
||||
tasks.withType(AbstractArchiveTask).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
|
|
|
@ -44,7 +44,7 @@ mod_name=TurnBasedMinecraftMod
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=MIT
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.24.0
|
||||
mod_version=1.25.0
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import de.jarnbjo.vorbis.VorbisAudioFileReader;
|
||||
import fr.delthas.javamp3.Sound;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -28,7 +29,9 @@ public class BattleMusic
|
|||
private boolean playingIsSilly;
|
||||
private boolean isPlaying;
|
||||
private Thread mp3StreamThread;
|
||||
private Thread oggVorbisStreamThread;
|
||||
private MP3Streamer mp3StreamRunnable;
|
||||
private OGGVorbisStreamer oggVorbisStreamRunnable;
|
||||
|
||||
public BattleMusic(Logger logger)
|
||||
{
|
||||
|
@ -81,7 +84,7 @@ public class BattleMusic
|
|||
}
|
||||
String ext = name.substring(extIndex + 1).toLowerCase();
|
||||
// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3");
|
||||
return ext.equals("wav") || ext.equals("mp3"); // midi disabled
|
||||
return ext.equals("wav") || ext.equals("mp3") || ext.equals("ogg"); // midi disabled
|
||||
}
|
||||
});
|
||||
for(File f : battleFiles)
|
||||
|
@ -101,7 +104,7 @@ public class BattleMusic
|
|||
}
|
||||
String ext = name.substring(extIndex + 1).toLowerCase();
|
||||
// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3");
|
||||
return ext.equals("wav") || ext.equals("mp3"); // midi disabled
|
||||
return ext.equals("wav") || ext.equals("mp3") || ext.equals("ogg"); // midi disabled
|
||||
}
|
||||
});
|
||||
for(File f : sillyFiles)
|
||||
|
@ -303,6 +306,39 @@ public class BattleMusic
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (suffix.equals("ogg")) {
|
||||
if(sequencer != null && sequencer.isRunning())
|
||||
{
|
||||
sequencer.stop();
|
||||
}
|
||||
if(clip != null && clip.isActive())
|
||||
{
|
||||
clip.stop();
|
||||
clip.close();
|
||||
}
|
||||
if(mp3StreamThread != null && mp3StreamThread.isAlive())
|
||||
{
|
||||
mp3StreamRunnable.setKeepPlaying(false);
|
||||
try { mp3StreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||
}
|
||||
|
||||
try {
|
||||
if (oggVorbisStreamRunnable == null) {
|
||||
oggVorbisStreamRunnable = new OGGVorbisStreamer(next, logger, volume);
|
||||
} else {
|
||||
oggVorbisStreamRunnable.setOggVorbisFile(next);
|
||||
oggVorbisStreamRunnable.setVolume(volume);
|
||||
}
|
||||
|
||||
oggVorbisStreamThread = new Thread(oggVorbisStreamRunnable);
|
||||
oggVorbisStreamThread.start();
|
||||
logger.info("Started playing OggVorbis " + next.getName());
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed to play battle music (ogg)");
|
||||
t.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,6 +356,10 @@ public class BattleMusic
|
|||
mp3StreamRunnable.setKeepPlaying(false);
|
||||
try { mp3StreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||
}
|
||||
if (oggVorbisStreamThread != null && oggVorbisStreamThread.isAlive()) {
|
||||
oggVorbisStreamRunnable.setKeepPlaying(false);
|
||||
try { oggVorbisStreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||
}
|
||||
if(resumeMCSounds)
|
||||
{
|
||||
Minecraft.getInstance().getSoundManager().resume();
|
||||
|
@ -454,4 +494,93 @@ public class BattleMusic
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class OGGVorbisStreamer implements Runnable {
|
||||
private AtomicBoolean keepPlaying;
|
||||
private File oggVorbisFile;
|
||||
private Logger logger;
|
||||
private float volume;
|
||||
|
||||
public OGGVorbisStreamer(File oggVorbisFile, Logger logger, float volume) {
|
||||
keepPlaying = new AtomicBoolean(true);
|
||||
this.oggVorbisFile = oggVorbisFile;
|
||||
this.logger = logger;
|
||||
this.volume = volume;
|
||||
if (this.volume > 1.0F) {
|
||||
this.volume = 1.0F;
|
||||
} else if (this.volume < 0.0F) {
|
||||
this.volume = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public void setKeepPlaying(boolean playing) {
|
||||
keepPlaying.set(playing);
|
||||
}
|
||||
|
||||
public void setOggVorbisFile(File oggVorbisFile) {
|
||||
this.oggVorbisFile = oggVorbisFile;
|
||||
}
|
||||
|
||||
public void setVolume(float volume) {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
keepPlaying.set(true);
|
||||
SourceDataLine sdl = null;
|
||||
try {
|
||||
VorbisAudioFileReader reader = new VorbisAudioFileReader();
|
||||
AudioFormat audioFormat = reader.getAudioFileFormat(oggVorbisFile).getFormat();
|
||||
sdl = AudioSystem.getSourceDataLine(audioFormat);
|
||||
sdl.open(audioFormat);
|
||||
{
|
||||
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
|
||||
}
|
||||
|
||||
AudioInputStream ais = reader.getAudioInputStream(oggVorbisFile);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] cached = null;
|
||||
int cachedOffset = 0;
|
||||
int cachedSize = 0;
|
||||
byte[] buf = new byte[4096];
|
||||
sdl.start();
|
||||
int read = ais.read(buf);
|
||||
while (keepPlaying.get()) {
|
||||
if (baos != null) {
|
||||
if (read != -1) {
|
||||
sdl.write(buf, 0, read);
|
||||
baos.write(buf, 0, read);
|
||||
read = ais.read(buf);
|
||||
} else {
|
||||
ais.close();
|
||||
ais = null;
|
||||
cached = baos.toByteArray();
|
||||
baos = null;
|
||||
}
|
||||
} else {
|
||||
cachedSize = cached.length - cachedOffset;
|
||||
if (cachedSize > 4096) {
|
||||
cachedSize = 4096;
|
||||
}
|
||||
sdl.write(cached, cachedOffset, cachedSize);
|
||||
cachedOffset += cachedSize;
|
||||
if (cachedOffset >= cached.length) {
|
||||
cachedOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error("Stream play oggVorbis", t);
|
||||
}
|
||||
|
||||
if (sdl != null) {
|
||||
sdl.stop();
|
||||
sdl.flush();
|
||||
sdl.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.logging.log4j.Logger;
|
|||
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.24.0";
|
||||
public static final String VERSION = "1.25.0";
|
||||
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/";
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"modid": "com_burnedkirby_turnbasedminecraft",
|
||||
"name": "Turn Based Minecraft",
|
||||
"description": "Changes battles to be turn-based.",
|
||||
"version": "1.24.0",
|
||||
"version": "1.25.0",
|
||||
"mcversion": "1.20.2",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
|
|
Loading…
Reference in a new issue