Fixed crash caused by missing sounds

This commit is contained in:
Anuken
2019-12-01 17:35:47 -05:00
parent f784e893dd
commit 42687fb47e
2 changed files with 5 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.mod;
import io.anuke.arc.*;
import io.anuke.arc.assets.*;
import io.anuke.arc.audio.*;
import io.anuke.arc.audio.mock.*;
import io.anuke.arc.collection.Array;
@@ -69,9 +70,9 @@ public class ContentParser{
String name = "sounds/" + data.asString();
String path = Vars.tree.get(name + ".ogg").exists() && !Vars.ios ? name + ".ogg" : name + ".mp3";
ModLoadingSound sound = new ModLoadingSound();
Core.assets.load(path, Sound.class).loaded = result -> {
sound.sound = (Sound)result;
};
AssetDescriptor<?> desc = Core.assets.load(path, Sound.class);
desc.loaded = result -> sound.sound = (Sound)result;
desc.errored = Throwable::printStackTrace;
return sound;
});
put(Objective.class, (type, data) -> {

View File

@@ -52,7 +52,7 @@ public class Mods implements Loadable{
/** @return the loaded mod found by class, or null if not found. */
public @Nullable LoadedMod getMod(Class<? extends Mod> type){
return loaded.find(l -> l.mod.getClass() == type);
return loaded.find(l -> l.mod != null && l.mod.getClass() == type);
}
/** Imports an external mod file.*/