From aba8ecdc96dc4f6b9e935c8cd37a47b99fe8ad37 Mon Sep 17 00:00:00 2001 From: David Burnett Date: Thu, 14 Jan 2021 13:22:09 -0500 Subject: [PATCH] Allow scaling a scalable element up --- .../client/screen/ScalableElementScreen.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java b/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java index 7ec3b51..f50372d 100644 --- a/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java +++ b/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java @@ -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;