From fe58ede1a560fc8f694bb1194ef28c3029ea7ec5 Mon Sep 17 00:00:00 2001 From: brandon3055 Date: Sun, 21 Apr 2024 17:11:19 +1000 Subject: [PATCH] Added ability to rotate GuiTexture --- .../lib/gui/modular/elements/GuiTexture.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/codechicken/lib/gui/modular/elements/GuiTexture.java b/src/main/java/codechicken/lib/gui/modular/elements/GuiTexture.java index da5c0577..542b6ee2 100644 --- a/src/main/java/codechicken/lib/gui/modular/elements/GuiTexture.java +++ b/src/main/java/codechicken/lib/gui/modular/elements/GuiTexture.java @@ -17,6 +17,7 @@ public class GuiTexture extends GuiElement implements BackgroundRend private Supplier getMaterial; private Supplier colour = () -> 0xFFFFFFFF; private Borders dynamicBorders = null; + private Supplier rotation = () -> 0; /** * @param parent parent {@link GuiParent}. @@ -97,6 +98,24 @@ public GuiTexture setColour(Supplier colour) { return this; } + /** + * Sets the texture rotation, each integer increment will rotate the texture by 90 degrees. + * (Not compatible with dynamic textures) + */ + public GuiTexture setRotation(Supplier rotation) { + this.rotation = rotation; + return this; + } + + /** + * Sets the texture rotation, each integer increment will rotate the texture by 90 degrees. + * (Not compatible with dynamic textures) + */ + public GuiTexture setRotation(int rotation) { + this.rotation = () -> rotation; + return this; + } + @Override public void renderBackground(GuiRender render, double mouseX, double mouseY, float partialTicks) { Material material = getMaterial(); @@ -104,7 +123,7 @@ public void renderBackground(GuiRender render, double mouseX, double mouseY, flo if (dynamicBorders != null) { render.dynamicTex(material, getRectangle(), dynamicBorders, colour.get()); } else { - render.texRect(material, getRectangle(), colour.get()); + render.texRect(material, rotation.get(), getRectangle(), colour.get()); } } }