CustomFX:

-Added compatibility for images with uneven widths & heights.
This commit is contained in:
c0508383 committed 2022-07-22 03:56:04 -05:00
1 parent 1b5b6cac6d
commit bad6c3e9e4
1 file changed
+14 -4
@@ -314,12 +314,22 @@ public class CustomFX extends EntityFX {
} else {
tessellator.setBrightness(240);
}
float textureXScale = 1.0F, textureYScale = 1.0F;
if (totalWidth > totalHeight) {
textureYScale = (float) totalHeight/totalWidth;
GL11.glScalef(1/textureYScale/2,1/textureYScale/2,1/textureYScale/2);
} else if(totalHeight > totalWidth) {
textureXScale = (float) totalWidth/totalHeight;
GL11.glScalef(1/textureXScale/2,1/textureXScale/2,1/textureXScale/2);
}
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
tessellator.addVertexWithUV( (u2-u1)/2, 0, (v2-v1)/2, u2, v2);
tessellator.addVertexWithUV( (u2-u1)/2, 0, -(v2-v1)/2, u2, v1);
tessellator.addVertexWithUV( -(u2-u1)/2, 0, -(v2-v1)/2, u1, v1);
tessellator.addVertexWithUV( -(u2-u1)/2, 0, (v2-v1)/2, u1, v2);
tessellator.addVertexWithUV( textureXScale * (u2-u1)/2, 0, textureYScale * (v2-v1)/2, u2, v2);
tessellator.addVertexWithUV( textureXScale * (u2-u1)/2, 0, textureYScale * -(v2-v1)/2, u2, v1);
tessellator.addVertexWithUV( textureXScale * -(u2-u1)/2, 0, textureYScale * -(v2-v1)/2, u1, v1);
tessellator.addVertexWithUV( textureXScale * -(u2-u1)/2, 0, textureYScale * (v2-v1)/2, u1, v2);
tessellator.draw();
GL11.glPopMatrix();
}