From ba936b69fd2e2c52cbee766a60b6723ba65ce1f2 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" <github@bluecolored.de> Date: Thu, 13 Jun 2024 23:04:32 +0200 Subject: [PATCH] Sort textures based on transparency (Fixes: #492) --- .../bluemap/core/map/TextureGallery.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java index 47d33bb4..3fdc9969 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java @@ -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); }