Allow scaling a scalable element up

This commit is contained in:
David Burnett committed 2021-01-14 13:22:09 -05:00
1 parent 9d88ccb624
commit aba8ecdc96
1 file changed
+20
@@ -5,6 +5,7 @@ import net.minecraft.client.gui.screen.Screen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
// TODO: class needs some rewrites
@OnlyIn(Dist.CLIENT)
public class ScalableElementScreen extends ElementScreen {
@@ -42,6 +43,25 @@ public class ScalableElementScreen extends ElementScreen {
return this.w;
}
/**
* Draws this shape scaling upwards instead of downwards
* @param matrixStack Matrix stack instance
* @param xPos X position of top of image
* @param yPos Y position of top of image
* @param height Height to draw
* @return Width for some reason
*/
public int drawScaledYUp(MatrixStack matrixStack, int xPos, int yPos, int height) {
// remainder that doesn't fit total height
int remainder = height % this.h;
int offset = this.h - remainder;
if (remainder > 0) {
Screen.blit(matrixStack, xPos, yPos + offset, this.x, this.y + offset, this.w, remainder, this.texW, this.texH);
}
return this.w;
}
public int drawScaled(MatrixStack matrixStack, int xPos, int yPos, int width, int height) {
// we draw full height row-wise
int full = height / this.h;