diff --git a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java index 5bca990c81..38923955e9 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java @@ -137,7 +137,7 @@ public abstract class BulletType extends Content{ } for(int i = 0; i < lightining; i++){ - Lightning.create(b.getTeam(), Pal.surge, damage, b.x, b.y, Mathf.random(360f), lightningLength); + Lightning.createLighting(Lightning.nextSeed(), b.getTeam(), Pal.surge, damage, b.x, b.y, Mathf.random(360f), lightningLength); } } diff --git a/core/src/io/anuke/mindustry/entities/effect/Lightning.java b/core/src/io/anuke/mindustry/entities/effect/Lightning.java index 44bc54d1cb..8d28f33d65 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Lightning.java +++ b/core/src/io/anuke/mindustry/entities/effect/Lightning.java @@ -44,7 +44,11 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{ /** Create a lighting branch at a location. Use Team.none to damage everyone. */ public static void create(Team team, Color color, float damage, float x, float y, float targetAngle, int length){ - Call.createLighting(lastSeed++, team, color, damage, x, y, targetAngle, length); + Call.createLighting(nextSeed(), team, color, damage, x, y, targetAngle, length); + } + + public static int nextSeed(){ + return lastSeed++; } /** Do not invoke! */ diff --git a/core/src/io/anuke/mindustry/mod/ContentParser.java b/core/src/io/anuke/mindustry/mod/ContentParser.java index 4280dd3f24..99def211c7 100644 --- a/core/src/io/anuke/mindustry/mod/ContentParser.java +++ b/core/src/io/anuke/mindustry/mod/ContentParser.java @@ -308,7 +308,7 @@ public class ContentParser{ if(value.has(key)){ return value.getString(key); }else{ - throw new IllegalArgumentException((currentContent == null ? "" : currentContent.sourceFile + ": ") + "You are missing a \"" + key + "\". It must be added before the file can be parsed."); + throw new IllegalArgumentException("You are missing a \"" + key + "\". It must be added before the file can be parsed."); } } @@ -433,14 +433,26 @@ public class ContentParser{ currentMod = mod; boolean located = locate(type, name) != null; Content c = parsers.get(type).parse(mod.name, name, value); + c.minfo = new ModContentInfo(); + c.minfo.sourceFile = file; toBeParsed.add(c); + if(!located){ - c.sourceFile = file; - c.mod = mod; + c.minfo.mod = mod; } return c; } + public void markError(Content content, LoadedMod mod, FileHandle file, Throwable error){ + if(content.minfo == null){ + content.minfo = new ModContentInfo(); + } + + content.minfo.mod = mod; + content.minfo.sourceFile = file; + content.minfo.error = Strings.parseException(error, true); + } + private T locate(ContentType type, String name){ T first = Vars.content.getByName(type, name); //try vanilla replacement return first != null ? first : Vars.content.getByName(type, currentMod.name + "-" + name); diff --git a/core/src/io/anuke/mindustry/mod/ModContentInfo.java b/core/src/io/anuke/mindustry/mod/ModContentInfo.java index 5e0ce32904..7d1fd105ca 100644 --- a/core/src/io/anuke/mindustry/mod/ModContentInfo.java +++ b/core/src/io/anuke/mindustry/mod/ModContentInfo.java @@ -6,7 +6,7 @@ import io.anuke.mindustry.mod.Mods.*; public class ModContentInfo{ /** The mod that loaded this piece of content. */ - public LoadedMod mod; + public @Nullable LoadedMod mod; /** File that this content was loaded from. */ public FileHandle sourceFile; /** The error that occurred during loading, if applicable. Null if no error occurred. */ diff --git a/core/src/io/anuke/mindustry/mod/Mods.java b/core/src/io/anuke/mindustry/mod/Mods.java index 98ceba586c..7aa5fa21ea 100644 --- a/core/src/io/anuke/mindustry/mod/Mods.java +++ b/core/src/io/anuke/mindustry/mod/Mods.java @@ -149,7 +149,7 @@ public class Mods implements Loadable{ //generate new icons for(Array arr : content.getContentMap()){ arr.each(c -> { - if(c instanceof UnlockableContent && c.mod != null){ + if(c instanceof UnlockableContent && c.minfo != null && c.minfo.mod != null){ UnlockableContent u = (UnlockableContent)c; u.createIcons(packer); } @@ -534,6 +534,7 @@ public class Mods implements Loadable{ loaded.each(p -> p.mod != null, p -> contextRun(p, () -> cons.get(p.mod))); } + /* public void handleError(Throwable t, LoadedMod mod){ Array causes = Strings.getCauses(t); Content content = null; @@ -559,13 +560,13 @@ public class Mods implements Loadable{ }else{ throw new ModLoadException("Error loading mod " + mod.meta.name, t); } - } + }*/ public void contextRun(LoadedMod mod, Runnable run){ try{ run.run(); }catch(Throwable t){ - handleError(t, mod); + throw new RuntimeException("Error loading mod " + mod.meta.name, t); } } @@ -751,7 +752,7 @@ public class Mods implements Loadable{ } } - /** Thrown when an error occurs while loading a mod.*/ + /** Thrown when an error occurs while loading a mod. public static class ModLoadException extends RuntimeException{ public Content content; public LoadedMod mod; @@ -783,5 +784,5 @@ public class Mods implements Loadable{ this.mod = content.mod; } } - } + }*/ }