diff --git a/core/src/mindustry/maps/generators/FileMapGenerator.java b/core/src/mindustry/maps/generators/FileMapGenerator.java index 5a53cb643e..da5f39fc8a 100644 --- a/core/src/mindustry/maps/generators/FileMapGenerator.java +++ b/core/src/mindustry/maps/generators/FileMapGenerator.java @@ -1,6 +1,7 @@ package mindustry.maps.generators; import arc.math.geom.*; +import mindustry.*; import mindustry.content.*; import mindustry.game.*; import mindustry.io.*; @@ -16,7 +17,13 @@ public class FileMapGenerator implements WorldGenerator{ public final SectorPreset preset; public FileMapGenerator(String mapName, SectorPreset preset){ - this.map = maps != null ? maps.loadInternalMap(mapName) : null; + //try to look for the prefixed map first, then the mod-specific one + this.map = maps != null ? maps.loadInternalMap( + preset.minfo.mod == null || Vars.tree.get("maps/" + mapName + "." + mapExtension).exists() ? + mapName : + mapName.substring(1 + preset.minfo.mod.name.length()) + ) : null; + this.preset = preset; } diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index ef3511c674..d39825f455 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -575,7 +575,7 @@ public class ContentParser{ if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number."); - SectorPreset out = new SectorPreset(mod + "-" + name); + SectorPreset out = new SectorPreset(mod + "-" + name, currentMod); currentContent = out; read(() -> { diff --git a/core/src/mindustry/type/SectorPreset.java b/core/src/mindustry/type/SectorPreset.java index 174d9fac6a..3c6b885d8d 100644 --- a/core/src/mindustry/type/SectorPreset.java +++ b/core/src/mindustry/type/SectorPreset.java @@ -5,6 +5,7 @@ import mindustry.ctype.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.maps.generators.*; +import mindustry.mod.Mods.*; public class SectorPreset extends UnlockableContent{ public FileMapGenerator generator; @@ -36,11 +37,17 @@ public class SectorPreset extends UnlockableContent{ } /** Internal use only! */ - public SectorPreset(String name){ + public SectorPreset(String name, LoadedMod mod){ super(name); + this.minfo.mod = mod; this.generator = new FileMapGenerator(name, this); } + /** Internal use only! */ + public SectorPreset(String name){ + this(name, null); + } + public void initialize(Planet planet, int sector){ this.planet = planet; sector %= planet.sectors.size;