mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Throw exceptions in Pony.getBufferedImage().
If an exception is thrown, don't save the Pony.
This commit is contained in:
parent
3355a7cb8a
commit
b3d849fdc9
2 changed files with 16 additions and 9 deletions
|
@ -50,7 +50,12 @@ public class Pony implements IPony {
|
|||
|
||||
private boolean initialized = false;
|
||||
|
||||
public Pony(Identifier resource) {
|
||||
Pony(Identifier resource, IPonyData data) {
|
||||
texture = resource;
|
||||
metadata = data;
|
||||
}
|
||||
|
||||
Pony(Identifier resource) {
|
||||
texture = resource;
|
||||
metadata = checkSkin(texture);
|
||||
}
|
||||
|
@ -122,8 +127,8 @@ public class Pony implements IPony {
|
|||
int width = getTexLevelParameter(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH);
|
||||
int height = getTexLevelParameter(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT);
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
return null;
|
||||
if (width * height == 0) {
|
||||
throw new IllegalStateException("GL texture not uploaded yet");
|
||||
}
|
||||
|
||||
NativeImage.Format channels = getFormat(format);
|
||||
|
@ -135,11 +140,8 @@ public class Pony implements IPony {
|
|||
try {
|
||||
image.loadFromTextureImage(0, false);
|
||||
} catch (IllegalStateException e) {
|
||||
// Out of memory
|
||||
// or buffer contained no/invalid image
|
||||
MineLittlePony.logger.fatal("Could not load texture from GL memory", e);
|
||||
|
||||
return null;
|
||||
image.close();
|
||||
throw e;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.util.List;
|
|||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -66,7 +67,11 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
|
|||
|
||||
@Override
|
||||
public IPony getPony(Identifier resource) {
|
||||
return poniesCache.getUnchecked(resource);
|
||||
try {
|
||||
return poniesCache.get(resource);
|
||||
} catch (ExecutionException e) {
|
||||
return new Pony(resource, new PonyData());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue