Fixed a startup crash with certain mods

This commit is contained in:
Anuken
2024-03-19 09:27:55 -04:00
parent 0efa8be09d
commit fc036c2f06
2 changed files with 22 additions and 3 deletions

View File

@@ -361,7 +361,24 @@ public class Mods implements Loadable{
Log.debug("Time to generate icons: @", Time.elapsed());
//dispose old atlas data
Core.atlas = packer.flush(filter, new TextureAtlas());
Core.atlas = packer.flush(filter, new TextureAtlas(){
PixmapRegion fake = new PixmapRegion(new Pixmap(1, 1));
boolean didWarn = false;
@Override
public PixmapRegion getPixmap(AtlasRegion region){
var other = super.getPixmap(region);
if(other.pixmap.isDisposed()){
if(!didWarn){
Log.err(new RuntimeException("Calling getPixmap outside of createIcons is not supported! This will be a crash in the future."));
didWarn = true;
}
return fake;
}
return other;
}
});
textureResize.each(e -> Core.atlas.find(e.key).scale = e.value);

View File

@@ -39,8 +39,10 @@ public class SectorPreset extends UnlockableContent{
/** Internal use only! */
public SectorPreset(String name, LoadedMod mod){
super(name);
this.minfo.mod = mod;
this.generator = new FileMapGenerator(name, this);
if(mod != null){
this.minfo.mod = mod;
}
this.generator = new FileMapGenerator(this.name, this);
}
/** Internal use only! */