diff --git a/src/main/java/com/minelittlepony/client/pony/Pony.java b/src/main/java/com/minelittlepony/client/pony/Pony.java index 6aa393c4..e63d6807 100644 --- a/src/main/java/com/minelittlepony/client/pony/Pony.java +++ b/src/main/java/com/minelittlepony/client/pony/Pony.java @@ -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; } diff --git a/src/main/java/com/minelittlepony/client/pony/PonyManager.java b/src/main/java/com/minelittlepony/client/pony/PonyManager.java index 0c0ef115..35d19dff 100644 --- a/src/main/java/com/minelittlepony/client/pony/PonyManager.java +++ b/src/main/java/com/minelittlepony/client/pony/PonyManager.java @@ -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