@Nullable private static BufferedImage getBufferedImage(TextureAtlasSprite textureAtlasSprite) { final int iconWidth = textureAtlasSprite.getIconWidth(); final int iconHeight = textureAtlasSprite.getIconHeight(); final int frameCount = textureAtlasSprite.getFrameCount(); if (iconWidth <= 0 || iconHeight <= 0 || frameCount <= 0) { return null; } BufferedImage bufferedImage = new BufferedImage(iconWidth, iconHeight * frameCount, BufferedImage.TYPE_4BYTE_ABGR); for (int i = 0; i < frameCount; i++) { int[][] frameTextureData = textureAtlasSprite.getFrameTextureData(i); int[] largestMipMapTextureData = frameTextureData[0]; bufferedImage.setRGB(0, i * iconHeight, iconWidth, iconHeight, largestMipMapTextureData, 0, iconWidth); } return bufferedImage; }
for (int i = 0; i < bakedQuad.getSprite().getFrameCount(); i++) { int[][] quadData = bakedQuad.getSprite().getFrameTextureData(i); for (int[] aQuadData : quadData) {
crashreportcategory.addDetail("Sprite name", texture::getIconName); crashreportcategory.addDetail("Sprite size", () -> texture.getIconWidth() + " x " + texture.getIconHeight()); crashreportcategory.addDetail("Sprite frames", () -> texture.getFrameCount() + " frames"); crashreportcategory.addCrashSection("Mipmap levels", 0); throw new ReportedException(crashreport);
private boolean hasTransparency(TabulaCubeContainer cube, TextureAtlasSprite sprite) { int textureWidth = this.model.getTextureWidth(); int textureHeight = this.model.getTextureHeight(); int width = sprite.getIconWidth(); int height = sprite.getIconHeight(); int frameCount = sprite.getFrameCount(); if (frameCount > 0) { for (int i = 0; i < frameCount; i++) { int[] pixels = sprite.getFrameTextureData(i)[0]; int[] textureOffset = cube.getTextureOffset(); int[] dimensions = cube.getDimensions(); int textureX = (textureOffset[0] * width) / textureWidth; int textureY = (textureOffset[1] * height) / textureHeight; int dimensionX = (dimensions[0] * width) / textureWidth; int dimensionY = (dimensions[1] * height) / textureHeight; int dimensionZ = (dimensions[2] * width) / textureWidth; boolean hasTransparencyTop = this.hasTransparency(pixels, textureX + dimensionZ, textureY, dimensionX * 2, dimensionZ, width, height); boolean hasTransparencyBottom = this.hasTransparency(pixels, textureX, textureY + dimensionZ, (dimensionX + dimensionZ) * 2, dimensionY, width, height); if (hasTransparencyTop || hasTransparencyBottom) { return true; } } } return false; }
private boolean hasTransparency(TabulaCubeContainer cube, TextureAtlasSprite sprite) { int textureWidth = this.model.getTextureWidth(); int textureHeight = this.model.getTextureHeight(); int width = sprite.getIconWidth(); int height = sprite.getIconHeight(); int frameCount = sprite.getFrameCount(); if (frameCount > 0) { for (int i = 0; i < frameCount; i++) { int[] pixels = sprite.getFrameTextureData(i)[0]; int[] textureOffset = cube.getTextureOffset(); int[] dimensions = cube.getDimensions(); int textureX = (textureOffset[0] * width) / textureWidth; int textureY = (textureOffset[1] * height) / textureHeight; int dimensionX = (dimensions[0] * width) / textureWidth; int dimensionY = (dimensions[1] * height) / textureHeight; int dimensionZ = (dimensions[2] * width) / textureWidth; boolean hasTransparencyTop = this.hasTransparency(pixels, textureX + dimensionZ, textureY, dimensionX * 2, dimensionZ, width, height); boolean hasTransparencyBottom = this.hasTransparency(pixels, textureX, textureY + dimensionZ, (dimensionX + dimensionZ) * 2, dimensionY, width, height); if (hasTransparencyTop || hasTransparencyBottom) { return true; } } } return false; }
crashreportcategory.addDetail("Sprite name", texture::getIconName); crashreportcategory.addDetail("Sprite size", () -> texture.getIconWidth() + " x " + texture.getIconHeight()); crashreportcategory.addDetail("Sprite frames", () -> texture.getFrameCount() + " frames"); crashreportcategory.addCrashSection("Mipmap levels", 0); throw new ReportedException(crashreport);
crashreportcategory.addDetail("Sprite name", texture::getIconName); crashreportcategory.addDetail("Sprite size", () -> texture.getIconWidth() + " x " + texture.getIconHeight()); crashreportcategory.addDetail("Sprite frames", () -> texture.getFrameCount() + " frames"); crashreportcategory.addCrashSection("Mipmap levels", 0); throw new ReportedException(crashreport);