Many fixes
Switch back to using shadowjar for dependencies. Fix saving new entity entries in config. Fix possible BattleMusic failures. Fix getEntity method not being side-aware.
This commit is contained in:
parent
202f918f79
commit
cb328f3dbb
10 changed files with 107 additions and 37 deletions
29
build.gradle
29
build.gradle
|
@ -6,11 +6,13 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||||
|
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
//apply plugin: 'maven-publish'
|
//apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
|
|
||||||
version = "1.9"
|
version = "1.9"
|
||||||
group = "com.burnedkirby.TurnBasedMinecraft"
|
group = "com.burnedkirby.TurnBasedMinecraft"
|
||||||
|
@ -108,7 +110,20 @@ dependencies {
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||||
|
|
||||||
compile files('src/main/resources/META-INF/libraries/javamp3-1.0.3.jar')
|
compile files('libs/javamp3-1.0.3.jar')
|
||||||
|
|
||||||
|
shadow files('libs/javamp3-1.0.3.jar')
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
project.configurations.shadow.setTransitive(true);
|
||||||
|
configurations = [project.configurations.shadow]
|
||||||
|
relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas'
|
||||||
|
classifier '' // replace the default jar
|
||||||
|
}
|
||||||
|
|
||||||
|
reobf {
|
||||||
|
shadowJar {} // reobfuscate the shadowed jar
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example for how to get properties into the manifest for reading by the runtime..
|
// Example for how to get properties into the manifest for reading by the runtime..
|
||||||
|
@ -122,7 +137,7 @@ jar {
|
||||||
"Implementation-Version": "${version}",
|
"Implementation-Version": "${version}",
|
||||||
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
|
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
"ContainedDeps": "javamp3-1.0.3.jar"
|
// "ContainedDeps": "javamp3-1.0.3.jar"
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,11 +146,11 @@ jar {
|
||||||
// we define a custom artifact that is sourced from the reobfJar output task
|
// we define a custom artifact that is sourced from the reobfJar output task
|
||||||
// and then declare that to be published
|
// and then declare that to be published
|
||||||
// Note you'll need to add a repository here
|
// Note you'll need to add a repository here
|
||||||
def reobfFile = file("$buildDir/reobfJar/output.jar")
|
//def reobfFile = file("$buildDir/reobfJar/output.jar")
|
||||||
def reobfArtifact = artifacts.add('default', reobfFile) {
|
//def reobfArtifact = artifacts.add('default', reobfFile) {
|
||||||
type 'jar'
|
// type 'jar'
|
||||||
builtBy 'reobfJar'
|
// builtBy 'reobfJar'
|
||||||
}
|
//}
|
||||||
//publishing {
|
//publishing {
|
||||||
// publications {
|
// publications {
|
||||||
// mavenJava(MavenPublication) {
|
// mavenJava(MavenPublication) {
|
||||||
|
|
|
@ -43,19 +43,16 @@ public class BattleMusic
|
||||||
try {
|
try {
|
||||||
sequencer = MidiSystem.getSequencer();
|
sequencer = MidiSystem.getSequencer();
|
||||||
sequencer.open();
|
sequencer.open();
|
||||||
} catch (Throwable t)
|
} catch (Throwable t) {
|
||||||
{
|
|
||||||
logger.error("Failed to load midi sequencer");
|
logger.error("Failed to load midi sequencer");
|
||||||
return;
|
sequencer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
clip = AudioSystem.getClip();
|
clip = AudioSystem.getClip();
|
||||||
} catch(LineUnavailableException e)
|
} catch(Throwable t) {
|
||||||
{
|
|
||||||
logger.error("Failed to load clip (for wav)");
|
logger.error("Failed to load clip (for wav)");
|
||||||
return;
|
clip = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
File battleMusicFolder = new File(TurnBasedMinecraftMod.MUSIC_BATTLE);
|
File battleMusicFolder = new File(TurnBasedMinecraftMod.MUSIC_BATTLE);
|
||||||
|
@ -114,7 +111,7 @@ public class BattleMusic
|
||||||
{
|
{
|
||||||
sillyMusic.add(f);
|
sillyMusic.add(f);
|
||||||
}
|
}
|
||||||
logger.info("Got " + sillyMusic.size() + " battle music files");
|
logger.info("Got " + sillyMusic.size() + " silly music files");
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
|
@ -185,13 +182,13 @@ public class BattleMusic
|
||||||
logger.debug("play called with file " + next.getName() + " and vol " + volume);
|
logger.debug("play called with file " + next.getName() + " and vol " + volume);
|
||||||
Minecraft.getInstance().getSoundHandler().pause();
|
Minecraft.getInstance().getSoundHandler().pause();
|
||||||
String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase();
|
String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase();
|
||||||
if(suffix.equals("mid"))
|
if(suffix.equals("mid") && sequencer != null)
|
||||||
{
|
{
|
||||||
if(sequencer.isRunning())
|
if(sequencer.isRunning())
|
||||||
{
|
{
|
||||||
sequencer.stop();
|
sequencer.stop();
|
||||||
}
|
}
|
||||||
if(clip.isActive())
|
if(clip != null && clip.isActive())
|
||||||
{
|
{
|
||||||
clip.stop();
|
clip.stop();
|
||||||
clip.close();
|
clip.close();
|
||||||
|
@ -213,9 +210,9 @@ public class BattleMusic
|
||||||
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
|
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
|
||||||
sequencer.start();
|
sequencer.start();
|
||||||
}
|
}
|
||||||
else if(suffix.equals("wav"))
|
else if(suffix.equals("wav") && clip != null)
|
||||||
{
|
{
|
||||||
if(sequencer.isRunning())
|
if(sequencer != null && sequencer.isRunning())
|
||||||
{
|
{
|
||||||
sequencer.stop();
|
sequencer.stop();
|
||||||
}
|
}
|
||||||
|
@ -248,11 +245,11 @@ public class BattleMusic
|
||||||
}
|
}
|
||||||
else if(suffix.equals("mp3"))
|
else if(suffix.equals("mp3"))
|
||||||
{
|
{
|
||||||
if(sequencer.isRunning())
|
if(sequencer != null && sequencer.isRunning())
|
||||||
{
|
{
|
||||||
sequencer.stop();
|
sequencer.stop();
|
||||||
}
|
}
|
||||||
if(clip.isActive())
|
if(clip != null && clip.isActive())
|
||||||
{
|
{
|
||||||
clip.stop();
|
clip.stop();
|
||||||
clip.close();
|
clip.close();
|
||||||
|
@ -290,9 +287,13 @@ public class BattleMusic
|
||||||
|
|
||||||
public void stopMusic(boolean resumeMCSounds)
|
public void stopMusic(boolean resumeMCSounds)
|
||||||
{
|
{
|
||||||
sequencer.stop();
|
if(sequencer != null) {
|
||||||
clip.stop();
|
sequencer.stop();
|
||||||
clip.close();
|
}
|
||||||
|
if(clip != null) {
|
||||||
|
clip.stop();
|
||||||
|
clip.close();
|
||||||
|
}
|
||||||
if(mp3StreamThread != null && mp3StreamThread.isAlive())
|
if(mp3StreamThread != null && mp3StreamThread.isAlive())
|
||||||
{
|
{
|
||||||
mp3StreamRunnable.setKeepPlaying(false);
|
mp3StreamRunnable.setKeepPlaying(false);
|
||||||
|
@ -312,7 +313,7 @@ public class BattleMusic
|
||||||
|
|
||||||
public boolean isPlaying()
|
public boolean isPlaying()
|
||||||
{
|
{
|
||||||
return isPlaying || sequencer.isRunning() || clip.isActive();
|
return isPlaying || (sequencer != null && sequencer.isRunning()) || (clip != null && clip.isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBattleMusic()
|
public boolean hasBattleMusic()
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy
|
public class ClientProxy extends CommonProxy
|
||||||
{
|
{
|
||||||
|
@ -27,6 +28,7 @@ public class ClientProxy extends CommonProxy
|
||||||
battleMusicCount = 0;
|
battleMusicCount = 0;
|
||||||
sillyMusicCount = 0;
|
sillyMusicCount = 0;
|
||||||
localBattle = null;
|
localBattle = null;
|
||||||
|
logger.debug("Init client");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -228,4 +230,9 @@ public class ClientProxy extends CommonProxy
|
||||||
{
|
{
|
||||||
localBattle = new Battle(null, id, null, null, false, Minecraft.getInstance().world.dimension.getType());
|
localBattle = new Battle(null, id, null, null, false, Minecraft.getInstance().world.dimension.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entity getEntity(int id, DimensionType dim) {
|
||||||
|
return Minecraft.getInstance().world.getEntityByID(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class CommonProxy
|
||||||
private Entity attackingEntity = null;
|
private Entity attackingEntity = null;
|
||||||
private int attackingDamage = 0;
|
private int attackingDamage = 0;
|
||||||
private Config config = null;
|
private Config config = null;
|
||||||
private Logger logger = null;
|
protected Logger logger = null;
|
||||||
private Map<Integer, EditingInfo> editingPlayers;
|
private Map<Integer, EditingInfo> editingPlayers;
|
||||||
|
|
||||||
public final void initialize()
|
public final void initialize()
|
||||||
|
@ -159,4 +159,8 @@ public class CommonProxy
|
||||||
{
|
{
|
||||||
return editingPlayers.remove(id);
|
return editingPlayers.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Entity getEntity(int id, DimensionType dim) {
|
||||||
|
return ServerLifecycleHooks.getCurrentServer().getWorld(dim).getEntityByID(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -790,8 +790,8 @@ public class Config
|
||||||
try {
|
try {
|
||||||
if (eInfo.classType != null || !eInfo.customName.isEmpty()) {
|
if (eInfo.classType != null || !eInfo.customName.isEmpty()) {
|
||||||
for (com.electronwill.nightconfig.core.Config entity : entities) {
|
for (com.electronwill.nightconfig.core.Config entity : entities) {
|
||||||
if ((eInfo.classType != null && entity.get("name").equals(eInfo.classType.getName()))
|
String entityName = entity.get("name");
|
||||||
|| (!eInfo.customName.isEmpty() && entity.get("custom_name").equals(eInfo.customName))) {
|
if ((eInfo.classType != null && entityName != null && entityName.equals(eInfo.classType.getName()))) {
|
||||||
entity.set("attack_power", eInfo.attackPower);
|
entity.set("attack_power", eInfo.attackPower);
|
||||||
entity.set("attack_probability", eInfo.attackProbability);
|
entity.set("attack_probability", eInfo.attackProbability);
|
||||||
entity.set("attack_variance", eInfo.attackVariance);
|
entity.set("attack_variance", eInfo.attackVariance);
|
||||||
|
@ -808,8 +808,56 @@ public class Config
|
||||||
entity.set("decision_flee_probability", eInfo.decisionFlee);
|
entity.set("decision_flee_probability", eInfo.decisionFlee);
|
||||||
saved = true;
|
saved = true;
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
String customName = entity.get("custom_name");
|
||||||
|
if(!eInfo.customName.isEmpty() && customName != null && customName.equals(eInfo.customName)) {
|
||||||
|
entity.set("attack_power", eInfo.attackPower);
|
||||||
|
entity.set("attack_probability", eInfo.attackProbability);
|
||||||
|
entity.set("attack_variance", eInfo.attackVariance);
|
||||||
|
entity.set("attack_effect", eInfo.attackEffect.toString());
|
||||||
|
entity.set("attack_effect_probability", eInfo.attackEffectProbability);
|
||||||
|
entity.set("defense_damage", eInfo.defenseDamage);
|
||||||
|
entity.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||||
|
entity.set("evasion", eInfo.evasion);
|
||||||
|
entity.set("speed", eInfo.speed);
|
||||||
|
entity.set("ignore_battle", eInfo.ignoreBattle);
|
||||||
|
entity.set("category", eInfo.category);
|
||||||
|
entity.set("decision_attack_probability", eInfo.decisionAttack);
|
||||||
|
entity.set("decision_defend_probability", eInfo.decisionDefend);
|
||||||
|
entity.set("decision_flee_probability", eInfo.decisionFlee);
|
||||||
|
saved = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!saved) {
|
||||||
|
com.electronwill.nightconfig.core.Config newEntry = conf.createSubConfig();
|
||||||
|
if(eInfo.classType != null) {
|
||||||
|
newEntry.set("name", eInfo.classType.getName());
|
||||||
|
} else if(!eInfo.customName.isEmpty()) {
|
||||||
|
newEntry.set("custom_name", eInfo.customName);
|
||||||
|
} else {
|
||||||
|
logger.error("Failed to save new entity entry into config, no name or custom_name");
|
||||||
|
conf.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
newEntry.set("attack_power", eInfo.attackPower);
|
||||||
|
newEntry.set("attack_probability", eInfo.attackProbability);
|
||||||
|
newEntry.set("attack_variance", eInfo.attackVariance);
|
||||||
|
newEntry.set("attack_effect", eInfo.attackEffect.toString());
|
||||||
|
newEntry.set("attack_effect_probability", eInfo.attackEffectProbability);
|
||||||
|
newEntry.set("defense_damage", eInfo.defenseDamage);
|
||||||
|
newEntry.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||||
|
newEntry.set("evasion", eInfo.evasion);
|
||||||
|
newEntry.set("speed", eInfo.speed);
|
||||||
|
newEntry.set("ignore_battle", eInfo.ignoreBattle);
|
||||||
|
newEntry.set("category", eInfo.category);
|
||||||
|
newEntry.set("decision_attack_probability", eInfo.decisionAttack);
|
||||||
|
newEntry.set("decision_defend_probability", eInfo.decisionDefend);
|
||||||
|
newEntry.set("decision_flee_probability", eInfo.decisionFlee);
|
||||||
|
entities.add(newEntry);
|
||||||
|
saved = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class EntityIDDimPair {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity getEntity() {
|
public Entity getEntity() {
|
||||||
return Utility.getEntity(id, dim);
|
return TurnBasedMinecraftMod.proxy.getEntity(id, dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,8 +51,4 @@ public class Utility
|
||||||
{
|
{
|
||||||
return Math.sqrt(Math.pow(a.posX - b.posX, 2.0) + Math.pow(a.posY - b.posY, 2.0) + Math.pow(a.posZ - b.posZ, 2.0));
|
return Math.sqrt(Math.pow(a.posX - b.posX, 2.0) + Math.pow(a.posY - b.posY, 2.0) + Math.pow(a.posZ - b.posZ, 2.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity getEntity(int id, DimensionType dimension) {
|
|
||||||
return ServerLifecycleHooks.getCurrentServer().getWorld(dimension).getEntityByID(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class PacketBattleMessage
|
||||||
public static class Handler {
|
public static class Handler {
|
||||||
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
Entity fromEntity = Utility.getEntity(pkt.entityIDFrom, pkt.dimension);
|
Entity fromEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.entityIDFrom, pkt.dimension);
|
||||||
String from = "Unknown";
|
String from = "Unknown";
|
||||||
if(fromEntity != null)
|
if(fromEntity != null)
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,7 @@ public class PacketBattleMessage
|
||||||
from = fromEntity.getDisplayName().getFormattedText();
|
from = fromEntity.getDisplayName().getFormattedText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Entity toEntity = Utility.getEntity(pkt.entityIDTo, pkt.dimension);
|
Entity toEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.entityIDTo, pkt.dimension);
|
||||||
String to = "Unknown";
|
String to = "Unknown";
|
||||||
if(toEntity != null)
|
if(toEntity != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Maven-Artifact: fr.delthas:javamp3:1.0.3
|
|
Loading…
Reference in a new issue