Skip to content

Commit

Permalink
Added ability to rotate GuiTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon3055 committed Apr 21, 2024
1 parent a5887ec commit fe58ede
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class GuiTexture extends GuiElement<GuiTexture> implements BackgroundRend
private Supplier<Material> getMaterial;
private Supplier<Integer> colour = () -> 0xFFFFFFFF;
private Borders dynamicBorders = null;
private Supplier<Integer> rotation = () -> 0;

/**
* @param parent parent {@link GuiParent}.
Expand Down Expand Up @@ -97,14 +98,32 @@ public GuiTexture setColour(Supplier<Integer> 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<Integer> 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();
if (material == null) return;
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());
}
}
}

0 comments on commit fe58ede

Please sign in to comment.