Compile error fixes

This commit is contained in:
Anuken 2019-12-14 10:06:09 -05:00
parent 58e3143e2a
commit 1f5a6e1bf8
5 changed files with 28 additions and 11 deletions

View File

@ -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);
}
}

View File

@ -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! */

View File

@ -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 extends MappableContent> 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);

View File

@ -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. */

View File

@ -149,7 +149,7 @@ public class Mods implements Loadable{
//generate new icons
for(Array<Content> 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<Throwable> 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;
}
}
}
}*/
}