From b143b05ad728c36609218164aa18437a9f51e725 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 29 Dec 2025 19:55:58 -0500 Subject: [PATCH] Possible texture packing hang fix --- core/src/mindustry/mod/Mods.java | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index d5966b65ba..ece6c67203 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -182,10 +182,9 @@ public class Mods implements Loadable{ } } - Log.debug("Total sprites: @", totalSprites[0]); + Log.debug("Total sprites: @", totalSprites[0]); TextureFilter filter = Core.settings.getBool("linear", true) ? TextureFilter.linear : TextureFilter.nearest; - Texture[] whiteToDispose = {null}; class RegionEntry{ String name; @@ -232,15 +231,20 @@ public class Mods implements Loadable{ } } + Pixmap[] whitePixmap = {null}; + Texture[] whiteTex = {null}; + waitForMain(() -> { + whitePixmap[0] = Pixmaps.blankPixmap(); + whiteTex[0] = new Texture(whitePixmap[0]); + var whiteRegion = new AtlasRegion(whiteTex[0], 0, 0, 1, 1); + Core.atlas.dispose(); //dead shadow-atlas for getting regions, but not pixmaps var shadow = Core.atlas; //dummy texture atlas that returns the 'shadow' regions; used for mod loading Core.atlas = new TextureAtlas(){ - boolean foundWhite; - AtlasRegion whiteRegion; { //needed for the correct operation of the found() method in the TextureRegion @@ -249,13 +253,7 @@ public class Mods implements Loadable{ @Override public AtlasRegion white(){ - if(Core.app.isOnMainThread() && !foundWhite){ - Pixmap pixmap = Pixmaps.blankPixmap(); - Texture tex = new Texture(pixmap); - whiteToDispose[0] = tex; - return whiteRegion = new AtlasRegion(tex, 0, 0, 1, 1); - } - return super.white(); + return whiteRegion; } @Override @@ -312,9 +310,8 @@ public class Mods implements Loadable{ } waitForMain(() -> { - if(whiteToDispose[0] != null){ - whiteToDispose[0].dispose(); - } + whitePixmap[0].dispose(); + whiteTex[0].dispose(); //replace old atlas data Core.atlas = packer.flush(filter, new TextureAtlas(){