From 5791a021eff042a6ba875b5f337c2829dfc2a312 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Sun, 30 Jun 2019 00:05:56 -0400 Subject: [PATCH] Fix GL loading Works for resources and other player skins, broken for own skin --- .../com/minelittlepony/client/pony/Pony.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/pony/Pony.java b/src/main/java/com/minelittlepony/client/pony/Pony.java index 7765d9e2..84a451cb 100644 --- a/src/main/java/com/minelittlepony/client/pony/Pony.java +++ b/src/main/java/com/minelittlepony/client/pony/Pony.java @@ -27,13 +27,11 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import org.lwjgl.BufferUtils; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; import java.io.FileNotFoundException; import java.io.IOException; -import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicInteger; import static com.mojang.blaze3d.platform.GlStateManager.getTexLevelParameter; @@ -109,19 +107,15 @@ 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); - int channels = 4; + NativeImage.Format channels = NativeImage.Format.RGBA; if (format == GL_RGB) { - channels = 3; + channels = NativeImage.Format.RGB; } - ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * channels); - glGetTexImage(GL_TEXTURE_2D, 0, format, GL_UNSIGNED_BYTE, buffer); + NativeImage image = new NativeImage(channels, width, height, false); + image.loadFromTextureImage(0, false); + return image; - try { - return NativeImage.fromByteBuffer(buffer); - } catch (IOException e) { - return MissingSprite.getMissingSpriteTexture().getImage(); - } } private IPonyData checkSkin(NativeImage bufferedimage) {