mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-05 10:29:45 +01:00
Make texture-gallery stronger against corrupting
This commit is contained in:
parent
b9b7aaffc9
commit
0fc1424021
@ -47,6 +47,10 @@ public void writeTexturesFile(ResourcePack resourcePack, OutputStream out) throw
|
||||
ordinalMap.forEach((textureResourcePath, ordinal) -> {
|
||||
Texture texture = textureResourcePath.getResource(resourcePack::getTexture);
|
||||
if (texture != null) textures[ordinal] = texture;
|
||||
|
||||
// make sure the resource-path doesn't get lost
|
||||
if (textures[ordinal].getResourcePath().equals(ResourcePack.MISSING_TEXTURE))
|
||||
textures[ordinal] = Texture.missing(textureResourcePath);
|
||||
});
|
||||
|
||||
try (Writer writer = new OutputStreamWriter(out)) {
|
||||
|
@ -37,6 +37,13 @@ private Texture(ResourcePath<Texture> resourcePath, Color color, boolean halfTra
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
private Texture(ResourcePath<Texture> resourcePath) {
|
||||
this.resourcePath = resourcePath;
|
||||
this.color = MISSING.color;
|
||||
this.halfTransparent = MISSING.halfTransparent;
|
||||
this.texture = MISSING.texture;
|
||||
}
|
||||
|
||||
public ResourcePath<Texture> getResourcePath() {
|
||||
return resourcePath;
|
||||
}
|
||||
@ -131,4 +138,8 @@ private static Color calculateColor(BufferedImage image){
|
||||
return new Color().set(red, green, blue, alpha, false);
|
||||
}
|
||||
|
||||
public static Texture missing(ResourcePath<Texture> resourcePath) {
|
||||
return new Texture(resourcePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user