Skip to content

Commit fe58ede

Browse files
committed
Added ability to rotate GuiTexture
1 parent a5887ec commit fe58ede

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Diff for: src/main/java/codechicken/lib/gui/modular/elements/GuiTexture.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class GuiTexture extends GuiElement<GuiTexture> implements BackgroundRend
1717
private Supplier<Material> getMaterial;
1818
private Supplier<Integer> colour = () -> 0xFFFFFFFF;
1919
private Borders dynamicBorders = null;
20+
private Supplier<Integer> rotation = () -> 0;
2021

2122
/**
2223
* @param parent parent {@link GuiParent}.
@@ -97,14 +98,32 @@ public GuiTexture setColour(Supplier<Integer> colour) {
9798
return this;
9899
}
99100

101+
/**
102+
* Sets the texture rotation, each integer increment will rotate the texture by 90 degrees.
103+
* (Not compatible with dynamic textures)
104+
*/
105+
public GuiTexture setRotation(Supplier<Integer> rotation) {
106+
this.rotation = rotation;
107+
return this;
108+
}
109+
110+
/**
111+
* Sets the texture rotation, each integer increment will rotate the texture by 90 degrees.
112+
* (Not compatible with dynamic textures)
113+
*/
114+
public GuiTexture setRotation(int rotation) {
115+
this.rotation = () -> rotation;
116+
return this;
117+
}
118+
100119
@Override
101120
public void renderBackground(GuiRender render, double mouseX, double mouseY, float partialTicks) {
102121
Material material = getMaterial();
103122
if (material == null) return;
104123
if (dynamicBorders != null) {
105124
render.dynamicTex(material, getRectangle(), dynamicBorders, colour.get());
106125
} else {
107-
render.texRect(material, getRectangle(), colour.get());
126+
render.texRect(material, rotation.get(), getRectangle(), colour.get());
108127
}
109128
}
110129
}

0 commit comments

Comments
 (0)