Sort textures based on transparency (Fixes: #492)

This commit is contained in:
Lukas Rieger (Blue) 2024-06-13 23:04:32 +02:00
parent 7ac9698b96
commit ba936b69fd
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6

View File

@ -24,11 +24,7 @@
*/
package de.bluecolored.bluemap.core.map;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException;
import com.google.gson.JsonParseException;
import com.google.gson.*;
import de.bluecolored.bluemap.core.resources.ResourcePath;
import de.bluecolored.bluemap.core.resources.adapter.ResourcesGson;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
@ -82,7 +78,12 @@ public synchronized void put(ResourcePack resourcePack) {
this.put(ResourcePack.MISSING_TEXTURE); // put this first
resourcePack.getTextures().keySet()
.stream()
.sorted(Comparator.comparing(Key::getFormatted))
.sorted(Comparator
.comparing((ResourcePath<Texture> r) -> {
Texture texture = r.getResource(resourcePack::getTexture);
return texture != null && texture.getColorPremultiplied().a < 1f;
})
.thenComparing(Key::getFormatted))
.forEach(this::put);
}