diff options
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java index f3df523..7831f33 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java @@ -10,6 +10,7 @@ import io.github.cottonmc.cotton.gui.widget.data.Texture; import juuxel.libninepatch.NinePatch; import juuxel.libninepatch.TextureRegion; +import java.util.Objects; import java.util.function.Consumer; /** @@ -158,4 +159,19 @@ public interface BackgroundPainter { else light.paintBackground(context, left, top, panel); }; } + + /** + * Creates a background painter that uses a texture from the GUI atlas. + * + * <p>This method can be used to draw tiled or nine-slice GUI sprites from resource packs + * as a simpler and more data-driven alternative to {@link #createNinePatch(Identifier)}. + * + * @param texture the texture ID + * @return a new background painter that uses a GUI sprite + * @since 9.0.0 + */ + static BackgroundPainter createGuiSprite(Identifier texture) { + Objects.requireNonNull(texture, "Texture cannot be null"); + return (context, left, top, panel) -> context.drawGuiTexture(texture, left, top, panel.getWidth(), panel.getHeight()); + } } |