Skip to content

Commit 0e84d4f

Browse files
committed
Fix (rarely) possible null-values in textures.json
1 parent c3dd98c commit 0e84d4f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.jetbrains.annotations.Nullable;
1010

1111
import java.io.*;
12+
import java.util.Arrays;
1213
import java.util.HashMap;
1314
import java.util.Map;
1415

@@ -41,10 +42,11 @@ public synchronized void put(ResourcePack resourcePack) {
4142

4243
public void writeTexturesFile(ResourcePack resourcePack, OutputStream out) throws IOException {
4344
Texture[] textures = new Texture[nextId];
45+
Arrays.fill(textures, Texture.MISSING);
46+
4447
ordinalMap.forEach((textureResourcePath, ordinal) -> {
4548
Texture texture = textureResourcePath.getResource(resourcePack::getTexture);
46-
if (texture == null) texture = Texture.MISSING;
47-
textures[ordinal] = texture;
49+
if (texture != null) textures[ordinal] = texture;
4850
});
4951

5052
try (Writer writer = new OutputStreamWriter(out)) {

0 commit comments

Comments
 (0)