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.
}\r
dependencies {\r
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true\r
+ classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'\r
}\r
}\r
apply plugin: 'net.minecraftforge.gradle'\r
apply plugin: 'eclipse'\r
//apply plugin: 'maven-publish'\r
+apply plugin: 'com.github.johnrengelman.shadow'\r
\r
version = "1.9"\r
group = "com.burnedkirby.TurnBasedMinecraft"\r
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html\r
// http://www.gradle.org/docs/current/userguide/dependency_management.html\r
\r
- compile files('src/main/resources/META-INF/libraries/javamp3-1.0.3.jar')\r
+ compile files('libs/javamp3-1.0.3.jar')\r
+\r
+ shadow files('libs/javamp3-1.0.3.jar')\r
+}\r
+\r
+shadowJar {\r
+ project.configurations.shadow.setTransitive(true);\r
+ configurations = [project.configurations.shadow]\r
+ relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas'\r
+ classifier '' // replace the default jar\r
+}\r
+\r
+reobf {\r
+ shadowJar {} // reobfuscate the shadowed jar\r
}\r
\r
// Example for how to get properties into the manifest for reading by the runtime..\r
"Implementation-Version": "${version}",\r
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",\r
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),\r
- "ContainedDeps": "javamp3-1.0.3.jar"\r
+// "ContainedDeps": "javamp3-1.0.3.jar"\r
])\r
}\r
}\r
// we define a custom artifact that is sourced from the reobfJar output task\r
// and then declare that to be published\r
// Note you'll need to add a repository here\r
-def reobfFile = file("$buildDir/reobfJar/output.jar")\r
-def reobfArtifact = artifacts.add('default', reobfFile) {\r
- type 'jar'\r
- builtBy 'reobfJar'\r
-}\r
+//def reobfFile = file("$buildDir/reobfJar/output.jar")\r
+//def reobfArtifact = artifacts.add('default', reobfFile) {\r
+// type 'jar'\r
+// builtBy 'reobfJar'\r
+//}\r
//publishing {\r
// publications {\r
// mavenJava(MavenPublication) {\r
try {
sequencer = MidiSystem.getSequencer();
sequencer.open();
- } catch (Throwable t)
- {
+ } catch (Throwable t) {
logger.error("Failed to load midi sequencer");
- return;
+ sequencer = null;
}
- try
- {
+ try {
clip = AudioSystem.getClip();
- } catch(LineUnavailableException e)
- {
+ } catch(Throwable t) {
logger.error("Failed to load clip (for wav)");
- return;
+ clip = null;
}
File battleMusicFolder = new File(TurnBasedMinecraftMod.MUSIC_BATTLE);
{
sillyMusic.add(f);
}
- logger.info("Got " + sillyMusic.size() + " battle music files");
+ logger.info("Got " + sillyMusic.size() + " silly music files");
initialized = true;
logger.debug("play called with file " + next.getName() + " and vol " + volume);
Minecraft.getInstance().getSoundHandler().pause();
String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase();
- if(suffix.equals("mid"))
+ if(suffix.equals("mid") && sequencer != null)
{
if(sequencer.isRunning())
{
sequencer.stop();
}
- if(clip.isActive())
+ if(clip != null && clip.isActive())
{
clip.stop();
clip.close();
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
sequencer.start();
}
- else if(suffix.equals("wav"))
+ else if(suffix.equals("wav") && clip != null)
{
- if(sequencer.isRunning())
+ if(sequencer != null && sequencer.isRunning())
{
sequencer.stop();
}
}
else if(suffix.equals("mp3"))
{
- if(sequencer.isRunning())
+ if(sequencer != null && sequencer.isRunning())
{
sequencer.stop();
}
- if(clip.isActive())
+ if(clip != null && clip.isActive())
{
clip.stop();
clip.close();
public void stopMusic(boolean resumeMCSounds)
{
- sequencer.stop();
- clip.stop();
- clip.close();
+ if(sequencer != null) {
+ sequencer.stop();
+ }
+ if(clip != null) {
+ clip.stop();
+ clip.close();
+ }
if(mp3StreamThread != null && mp3StreamThread.isAlive())
{
mp3StreamRunnable.setKeepPlaying(false);
public boolean isPlaying()
{
- return isPlaying || sequencer.isRunning() || clip.isActive();
+ return isPlaying || (sequencer != null && sequencer.isRunning()) || (clip != null && clip.isActive());
}
public boolean hasBattleMusic()
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
+import net.minecraft.world.dimension.DimensionType;
public class ClientProxy extends CommonProxy
{
battleMusicCount = 0;
sillyMusicCount = 0;
localBattle = null;
+ logger.debug("Init client");
}
@Override
{
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);
+ }
}
private Entity attackingEntity = null;
private int attackingDamage = 0;
private Config config = null;
- private Logger logger = null;
+ protected Logger logger = null;
private Map<Integer, EditingInfo> editingPlayers;
public final void initialize()
{
return editingPlayers.remove(id);
}
+
+ public Entity getEntity(int id, DimensionType dim) {
+ return ServerLifecycleHooks.getCurrentServer().getWorld(dim).getEntityByID(id);
+ }
}
try {
if (eInfo.classType != null || !eInfo.customName.isEmpty()) {
for (com.electronwill.nightconfig.core.Config entity : entities) {
- if ((eInfo.classType != null && entity.get("name").equals(eInfo.classType.getName()))
- || (!eInfo.customName.isEmpty() && entity.get("custom_name").equals(eInfo.customName))) {
+ String entityName = entity.get("name");
+ if ((eInfo.classType != null && entityName != null && entityName.equals(eInfo.classType.getName()))) {
entity.set("attack_power", eInfo.attackPower);
entity.set("attack_probability", eInfo.attackProbability);
entity.set("attack_variance", eInfo.attackVariance);
entity.set("decision_flee_probability", eInfo.decisionFlee);
saved = true;
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 {
return false;
}
public Entity getEntity() {
- return Utility.getEntity(id, dim);
+ return TurnBasedMinecraftMod.proxy.getEntity(id, dim);
}
@Override
{
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);
- }
}
public static class Handler {
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> {
- Entity fromEntity = Utility.getEntity(pkt.entityIDFrom, pkt.dimension);
+ Entity fromEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.entityIDFrom, pkt.dimension);
String from = "Unknown";
if(fromEntity != null)
{
from = fromEntity.getDisplayName().getFormattedText();
}
}
- Entity toEntity = Utility.getEntity(pkt.entityIDTo, pkt.dimension);
+ Entity toEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.entityIDTo, pkt.dimension);
String to = "Unknown";
if(toEntity != null)
{
+++ /dev/null
-Maven-Artifact: fr.delthas:javamp3:1.0.3