Fix (rarely) possible null-values in textures.json

This commit is contained in:
Lukas Rieger (Blue) 2022-08-23 19:45:39 +02:00
parent c3dd98ce2d
commit 0e84d4f914
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
1 changed files with 4 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import de.bluecolored.bluemap.core.resources.resourcepack.texture.Texture;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@ -41,10 +42,11 @@ public class TextureGallery {
public void writeTexturesFile(ResourcePack resourcePack, OutputStream out) throws IOException {
Texture[] textures = new Texture[nextId];
Arrays.fill(textures, Texture.MISSING);
ordinalMap.forEach((textureResourcePath, ordinal) -> {
Texture texture = textureResourcePath.getResource(resourcePack::getTexture);
if (texture == null) texture = Texture.MISSING;
textures[ordinal] = texture;
if (texture != null) textures[ordinal] = texture;
});
try (Writer writer = new OutputStreamWriter(out)) {