Make texture-gallery stronger against corrupting
This commit is contained in:
parent
b9b7aaffc9
commit
0fc1424021
|
@ -47,6 +47,10 @@ public class TextureGallery {
|
|||
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 @@ public class Texture {
|
|||
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 @@ public class Texture {
|
|||
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