diff --git a/core/src/io/anuke/mindustry/mod/Mods.java b/core/src/io/anuke/mindustry/mod/Mods.java index c191323eff..e26a3df983 100644 --- a/core/src/io/anuke/mindustry/mod/Mods.java +++ b/core/src/io/anuke/mindustry/mod/Mods.java @@ -321,31 +321,56 @@ public class Mods implements Loadable{ /** Creates all the content found in mod files. */ public void loadContent(){ + class LoadRun implements Comparable{ + final ContentType type; + final FileHandle file; + final LoadedMod mod; + + public LoadRun(ContentType type, FileHandle file, LoadedMod mod){ + this.type = type; + this.file = file; + this.mod = mod; + } + + @Override + public int compareTo(LoadRun l){ + int mod = this.mod.name.compareTo(l.mod.name); + if(mod != 0) return mod; + return this.file.name().compareTo(l.file.name()); + } + } + + Array runs = new Array<>(); + for(LoadedMod mod : orderedMods()){ - safeRun(mod, () -> { - if(mod.root.child("content").exists()){ - FileHandle contentRoot = mod.root.child("content"); - for(ContentType type : ContentType.all){ - FileHandle folder = contentRoot.child(type.name().toLowerCase() + "s"); - if(folder.exists()){ - for(FileHandle file : folder.list()){ - if(file.extension().equals("json")){ - try{ - //this binds the content but does not load it entirely - Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString("UTF-8"), file, type); - Log.debug("[{0}] Loaded '{1}'.", mod.meta.name, - (loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded)); - }catch(Exception e){ - throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e); - } - } + if(mod.root.child("content").exists()){ + FileHandle contentRoot = mod.root.child("content"); + for(ContentType type : ContentType.all){ + FileHandle folder = contentRoot.child(type.name().toLowerCase() + "s"); + if(folder.exists()){ + for(FileHandle file : folder.list()){ + if(file.extension().equals("json")){ + runs.add(new LoadRun(type, file, mod)); } } } } - }); + } } + //make sure mod content is in proper order + runs.sort(); + runs.each(l -> safeRun(l.mod, () -> { + try{ + //this binds the content but does not load it entirely + Content loaded = parser.parse(l.mod, l.file.nameWithoutExtension(), l.file.readString("UTF-8"), l.file, l.type); + Log.debug("[{0}] Loaded '{1}'.", l.mod.meta.name, + (loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded)); + }catch(Exception e){ + throw new RuntimeException("Failed to parse content file '" + l.file + "' for mod '" + l.mod.meta.name + "'.", e); + } + })); + //this finishes parsing content fields parser.finishParsing(); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java index b8b0055096..a4a3fea2cb 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java @@ -1,12 +1,13 @@ package io.anuke.mindustry.world.blocks.defense.turrets; +import io.anuke.arc.util.ArcAnnotate.*; import io.anuke.mindustry.entities.bullet.BulletType; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; public abstract class PowerTurret extends CooledTurret{ - protected BulletType shootType; + protected @NonNull BulletType shootType; protected float powerUse = 1f; public PowerTurret(String name){