From 1167c00c645376481560afd838038251174860ec Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sun, 4 Jun 2023 00:07:28 +0300 Subject: Update to 1.20 RC 1 --- build.gradle | 2 + gradle.properties | 14 +- .../cottonmc/cotton/gui/SyncedGuiDescription.java | 4 +- .../cotton/gui/client/BackgroundPainter.java | 40 ++-- .../cotton/gui/client/CottonClientScreen.java | 26 +-- .../cottonmc/cotton/gui/client/CottonHud.java | 4 +- .../cotton/gui/client/CottonInventoryScreen.java | 32 ++- .../gui/client/NinePatchBackgroundPainter.java | 7 +- .../cottonmc/cotton/gui/client/ScreenDrawing.java | 214 ++++++++++----------- .../cottonmc/cotton/gui/impl/VisualLogger.java | 8 +- .../cotton/gui/impl/client/CottonScreenImpl.java | 4 - .../impl/client/NinePatchTextureRendererImpl.java | 12 +- .../cotton/gui/impl/modmenu/WKirbSprite.java | 6 +- .../io/github/cottonmc/cotton/gui/widget/WBar.java | 24 +-- .../github/cottonmc/cotton/gui/widget/WButton.java | 12 +- .../cottonmc/cotton/gui/widget/WClippedPanel.java | 8 +- .../cottonmc/cotton/gui/widget/WDynamicLabel.java | 6 +- .../github/cottonmc/cotton/gui/widget/WItem.java | 11 +- .../cottonmc/cotton/gui/widget/WItemSlot.java | 8 +- .../github/cottonmc/cotton/gui/widget/WLabel.java | 8 +- .../cottonmc/cotton/gui/widget/WLabeledSlider.java | 19 +- .../cottonmc/cotton/gui/widget/WListPanel.java | 6 +- .../github/cottonmc/cotton/gui/widget/WPanel.java | 8 +- .../cottonmc/cotton/gui/widget/WScrollBar.java | 26 +-- .../cottonmc/cotton/gui/widget/WScrollPanel.java | 6 +- .../github/cottonmc/cotton/gui/widget/WSlider.java | 22 +-- .../github/cottonmc/cotton/gui/widget/WSprite.java | 20 +- .../cottonmc/cotton/gui/widget/WTabPanel.java | 12 +- .../github/cottonmc/cotton/gui/widget/WText.java | 8 +- .../cottonmc/cotton/gui/widget/WTextField.java | 44 ++--- .../cottonmc/cotton/gui/widget/WTiledSprite.java | 6 +- .../cottonmc/cotton/gui/widget/WToggleButton.java | 10 +- .../github/cottonmc/cotton/gui/widget/WWidget.java | 33 ++-- .../cottonmc/cotton/gui/widget/icon/Icon.java | 12 +- .../cottonmc/cotton/gui/widget/icon/ItemIcon.java | 11 +- .../cotton/gui/widget/icon/TextureIcon.java | 6 +- src/main/resources/fabric.mod.json | 6 +- .../github/cottonmc/test/TestItemDescription.java | 6 +- .../github/cottonmc/test/client/TestClientGui.java | 6 +- .../io/github/cottonmc/test/client/WHudTest.java | 6 +- 40 files changed, 353 insertions(+), 370 deletions(-) diff --git a/build.gradle b/build.gradle index e116a82..0234a4d 100644 --- a/build.gradle +++ b/build.gradle @@ -94,6 +94,7 @@ dependencies { modCompileOnly("com.terraformersmc:modmenu:$project.modmenu_version") { exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc', module: 'fabric-loader' } // Test mod dependencies @@ -101,6 +102,7 @@ dependencies { modTestModImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modTestModRuntimeOnly("com.terraformersmc:modmenu:$project.modmenu_version") { exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc', module: 'fabric-loader' } } diff --git a/gradle.properties b/gradle.properties index 7fe141f..e100a5c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,18 +2,18 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties - # check these on https://fabricmc.net/use - minecraft_version=1.19.4 - yarn_mappings=1.19.4+build.1 - loader_version=0.14.17 + # check these on https://fabricmc.net/develop + minecraft_version=1.20-rc1 + yarn_mappings=1.20-rc1+build.2 + loader_version=0.14.21 # Mod Properties - mod_version = 7.1.0 + mod_version = 8.0.0-beta.1 maven_group = io.github.cottonmc archives_base_name = LibGui # Dependencies - fabric_version=0.76.0+1.19.4 + fabric_version=0.83.0+1.20 jankson_version=5.0.1+j1.2.2 - modmenu_version=6.1.0-rc.4 + modmenu_version=7.0.0-beta.2 libninepatch_version=1.2.0 diff --git a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java index 2abc643..64d905e 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java @@ -71,7 +71,7 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio super(type, syncId); this.blockInventory = null; this.playerInventory = playerInventory; - this.world = playerInventory.player.world; + this.world = playerInventory.player.getWorld(); this.propertyDelegate = null;//new ArrayPropertyDelegate(1); } @@ -88,7 +88,7 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio super(type, syncId); this.blockInventory = blockInventory; this.playerInventory = playerInventory; - this.world = playerInventory.player.world; + this.world = playerInventory.player.getWorld(); this.propertyDelegate = propertyDelegate; if (propertyDelegate!=null && propertyDelegate.size()>0) this.addProperties(propertyDelegate); if (blockInventory != null) blockInventory.onOpen(playerInventory.player); 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 77b7268..f3df523 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 @@ -1,6 +1,6 @@ package io.github.cottonmc.cotton.gui.client; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.util.Identifier; import io.github.cottonmc.cotton.gui.impl.LibGuiCommon; @@ -20,11 +20,13 @@ import java.util.function.Consumer; public interface BackgroundPainter { /** * Paint the specified panel to the screen. - * @param left The absolute position of the left of the panel, in gui-screen coordinates - * @param top The absolute position of the top of the panel, in gui-screen coordinates - * @param panel The panel being painted + * + * @param context The draw context + * @param left The absolute position of the left of the panel, in gui-screen coordinates + * @param top The absolute position of the top of the panel, in gui-screen coordinates + * @param panel The panel being painted */ - public void paintBackground(MatrixStack matrices, int left, int top, WWidget panel); + public void paintBackground(DrawContext context, int left, int top, WWidget panel); /** * The {@code VANILLA} background painter draws a vanilla-like GUI panel using nine-patch textures. @@ -47,9 +49,9 @@ public interface BackgroundPainter { * *
For {@linkplain WItemSlot item slots}, this painter uses {@link WItemSlot#SLOT_TEXTURE libgui:textures/widget/item_slot.png}.
*/
- public static BackgroundPainter SLOT = (matrices, left, top, panel) -> {
+ public static BackgroundPainter SLOT = (context, left, top, panel) -> {
if (!(panel instanceof WItemSlot)) {
- ScreenDrawing.drawBeveledPanel(matrices, left-1, top-1, panel.getWidth()+2, panel.getHeight()+2, 0xB8000000, 0x4C000000, 0xB8FFFFFF);
+ ScreenDrawing.drawBeveledPanel(context, left-1, top-1, panel.getWidth()+2, panel.getHeight()+2, 0xB8000000, 0x4C000000, 0xB8FFFFFF);
} else {
WItemSlot slot = (WItemSlot)panel;
for(int x = 0; x < slot.getWidth()/18; ++x) {
@@ -59,19 +61,19 @@ public interface BackgroundPainter {
if (slot.isBigSlot()) {
int sx = (x * 18) + left - 4;
int sy = (y * 18) + top - 4;
- ScreenDrawing.texturedRect(matrices, sx, sy, 26, 26, WItemSlot.SLOT_TEXTURE,
+ ScreenDrawing.texturedRect(context, sx, sy, 26, 26, WItemSlot.SLOT_TEXTURE,
18 * px, 0, 44 * px, 26 * px, 0xFF_FFFFFF);
if (slot.getFocusedSlot() == index) {
- ScreenDrawing.texturedRect(matrices, sx, sy, 26, 26, WItemSlot.SLOT_TEXTURE,
+ ScreenDrawing.texturedRect(context, sx, sy, 26, 26, WItemSlot.SLOT_TEXTURE,
18 * px, 26 * px, 44 * px, 52 * px, 0xFF_FFFFFF);
}
} else {
int sx = (x * 18) + left;
int sy = (y * 18) + top;
- ScreenDrawing.texturedRect(matrices, sx, sy, 18, 18, WItemSlot.SLOT_TEXTURE,
+ ScreenDrawing.texturedRect(context, sx, sy, 18, 18, WItemSlot.SLOT_TEXTURE,
0, 0, 18 * px, 18 * px, 0xFF_FFFFFF);
if (slot.getFocusedSlot() == index) {
- ScreenDrawing.texturedRect(matrices, sx, sy, 18, 18, WItemSlot.SLOT_TEXTURE,
+ ScreenDrawing.texturedRect(context, sx, sy, 18, 18, WItemSlot.SLOT_TEXTURE,
0, 26 * px, 18 * px, 44 * px, 0xFF_FFFFFF);
}
}
@@ -85,11 +87,11 @@ public interface BackgroundPainter {
*
* @param panelColor the panel background color
* @return a colorful gui panel painter
- * @see ScreenDrawing#drawGuiPanel(MatrixStack, int, int, int, int, int)
+ * @see ScreenDrawing#drawGuiPanel(DrawContext, int, int, int, int, int)
*/
public static BackgroundPainter createColorful(int panelColor) {
- return (matrices, left, top, panel) -> {
- ScreenDrawing.drawGuiPanel(matrices, left, top, panel.getWidth(), panel.getHeight(), panelColor);
+ return (context, left, top, panel) -> {
+ ScreenDrawing.drawGuiPanel(context, left, top, panel.getWidth(), panel.getHeight(), panelColor);
};
}
@@ -101,11 +103,11 @@ public interface BackgroundPainter {
* @return a colorful gui panel painter
*/
public static BackgroundPainter createColorful(int panelColor, float contrast) {
- return (matrices, left, top, panel) -> {
+ return (context, left, top, panel) -> {
int shadowColor = ScreenDrawing.multiplyColor(panelColor, 1.0f - contrast);
int hilightColor = ScreenDrawing.multiplyColor(panelColor, 1.0f + contrast);
- ScreenDrawing.drawGuiPanel(matrices, left, top, panel.getWidth(), panel.getHeight(), shadowColor, panelColor, hilightColor, 0xFF000000);
+ ScreenDrawing.drawGuiPanel(context, left, top, panel.getWidth(), panel.getHeight(), shadowColor, panelColor, hilightColor, 0xFF000000);
};
}
@@ -151,9 +153,9 @@ public interface BackgroundPainter {
* @since 1.5.0
*/
public static BackgroundPainter createLightDarkVariants(BackgroundPainter light, BackgroundPainter dark) {
- return (matrices, left, top, panel) -> {
- if (panel.shouldRenderInDarkMode()) dark.paintBackground(matrices, left, top, panel);
- else light.paintBackground(matrices, left, top, panel);
+ return (context, left, top, panel) -> {
+ if (panel.shouldRenderInDarkMode()) dark.paintBackground(context, left, top, panel);
+ else light.paintBackground(context, left, top, panel);
};
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
index 81d7646..310b9aa 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
@@ -1,11 +1,10 @@
package io.github.cottonmc.cotton.gui.client;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
-import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
-import net.minecraft.text.Style;
import net.minecraft.text.Text;
import io.github.cottonmc.cotton.gui.GuiDescription;
@@ -124,41 +123,41 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
}
}
- private void paint(MatrixStack matrices, int mouseX, int mouseY) {
- renderBackground(matrices);
+ private void paint(DrawContext context, int mouseX, int mouseY) {
+ renderBackground(context);
if (description!=null) {
WPanel root = description.getRootPanel();
if (root!=null) {
GL11.glEnable(GL11.GL_SCISSOR_TEST);
Scissors.refreshScissors();
- root.paint(matrices, left, top, mouseX-left, mouseY-top);
+ root.paint(context, left, top, mouseX-left, mouseY-top);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
Scissors.checkStackIsEmpty();
}
if (getTitle() != null && description.isTitleVisible()) {
int width = description.getRootPanel().getWidth();
- ScreenDrawing.drawString(matrices, getTitle().asOrderedText(), description.getTitleAlignment(), left + titleX, top + titleY, width - titleX, description.getTitleColor());
+ ScreenDrawing.drawString(context, getTitle().asOrderedText(), description.getTitleAlignment(), left + titleX, top + titleY, width - titleX, description.getTitleColor());
}
}
}
@Override
- public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
- paint(matrices, mouseX, mouseY);
+ public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
+ paint(context, mouseX, mouseY);
- super.render(matrices, mouseX, mouseY, partialTicks);
+ super.render(context, mouseX, mouseY, partialTicks);
if (description!=null) {
WPanel root = description.getRootPanel();
if (root!=null) {
WWidget hitChild = root.hit(mouseX-left, mouseY-top);
- if (hitChild!=null) hitChild.renderTooltip(matrices, left, top, mouseX-left, mouseY-top);
+ if (hitChild!=null) hitChild.renderTooltip(context, left, top, mouseX-left, mouseY-top);
}
}
- VisualLogger.render(matrices);
+ VisualLogger.render(context);
}
@Override
@@ -257,11 +256,6 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
return super.keyReleased(ch, keyCode, modifiers);
}
- @Override
- public void renderTextHover(MatrixStack matrices, @Nullable Style textStyle, int x, int y) {
- renderTextHoverEffect(matrices, textStyle, x, y);
- }
-
@Override
protected void addElementNarrations(NarrationMessageBuilder builder) {
if (description != null) NarrationHelper.addNarrations(description.getRootPanel(), builder);
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java
index 05141a7..5dde548 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java
@@ -23,7 +23,7 @@ public final class CottonHud {
private static final Map If the texture is 256x256, this draws the texture at one pixel per texel.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param x the x coordinate of the box on-screen
* @param y the y coordinate of the box on-screen
* @param width the width of the box on-screen
@@ -165,9 +163,9 @@ public class ScreenDrawing {
* @param textureY the y offset into the texture
* @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
*/
- public static void texturedGuiRect(MatrixStack matrices, int x, int y, int width, int height, Identifier texture, int textureX, int textureY, int color) {
+ public static void texturedGuiRect(DrawContext context, int x, int y, int width, int height, Identifier texture, int textureX, int textureY, int color) {
float px = 1/256f;
- texturedRect(matrices, x, y, width, height, texture, textureX*px, textureY*px, (textureX+width)*px, (textureY+height)*px, color);
+ texturedRect(context, x, y, width, height, texture, textureX*px, textureY*px, (textureX+width)*px, (textureY+height)*px, color);
}
/**
@@ -175,7 +173,7 @@ public class ScreenDrawing {
*
* If the texture is 256x256, this draws the texture at one pixel per texel.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param left the x coordinate of the box on-screen
* @param top the y coordinate of the box on-screen
* @param width the width of the box on-screen
@@ -183,55 +181,55 @@ public class ScreenDrawing {
* @param texture the Identifier for the texture
* @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
*/
- public static void texturedGuiRect(MatrixStack matrices, int left, int top, int width, int height, Identifier texture, int color) {
- texturedGuiRect(matrices, left, top, width, height, texture, 0, 0, color);
+ public static void texturedGuiRect(DrawContext context, int left, int top, int width, int height, Identifier texture, int color) {
+ texturedGuiRect(context, left, top, width, height, texture, 0, 0, color);
}
/**
* Draws an untextured rectangle of the specified RGB color.
*/
- public static void coloredRect(MatrixStack matrices, int left, int top, int width, int height, int color) {
+ public static void coloredRect(DrawContext context, int left, int top, int width, int height, int color) {
if (width <= 0) width = 1;
if (height <= 0) height = 1;
- DrawableHelper.fill(matrices, left, top, left + width, top + height, color);
+ context.fill(left, top, left + width, top + height, color);
}
/**
* Draws a beveled, round rectangle that is substantially similar to default Minecraft UI panels.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param x the X position of the panel
* @param y the Y position of the panel
* @param width the width of the panel
* @param height the height of the panel
*/
- public static void drawGuiPanel(MatrixStack matrices, int x, int y, int width, int height) {
- if (LibGui.isDarkMode()) drawGuiPanel(matrices, x, y, width, height, 0xFF0B0B0B, 0xFF2F2F2F, 0xFF414141, 0xFF000000);
- else drawGuiPanel(matrices, x, y, width, height, 0xFF555555, 0xFFC6C6C6, 0xFFFFFFFF, 0xFF000000);
+ public static void drawGuiPanel(DrawContext context, int x, int y, int width, int height) {
+ if (LibGui.isDarkMode()) drawGuiPanel(context, x, y, width, height, 0xFF0B0B0B, 0xFF2F2F2F, 0xFF414141, 0xFF000000);
+ else drawGuiPanel(context, x, y, width, height, 0xFF555555, 0xFFC6C6C6, 0xFFFFFFFF, 0xFF000000);
}
/**
* Draws a beveled, round, and colored rectangle that is substantially similar to default Minecraft UI panels.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param x the X position of the panel
* @param y the Y position of the panel
* @param width the width of the panel
* @param height the height of the panel
* @param panelColor the panel ARGB color
*/
- public static void drawGuiPanel(MatrixStack matrices, int x, int y, int width, int height, int panelColor) {
+ public static void drawGuiPanel(DrawContext context, int x, int y, int width, int height, int panelColor) {
int shadowColor = multiplyColor(panelColor, 0.50f);
int hilightColor = multiplyColor(panelColor, 1.25f);
- drawGuiPanel(matrices, x, y, width, height, shadowColor, panelColor, hilightColor, 0xFF000000);
+ drawGuiPanel(context, x, y, width, height, shadowColor, panelColor, hilightColor, 0xFF000000);
}
/**
* Draws a beveled, round rectangle with custom edge colors that is substantially similar to default Minecraft UI panels.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param x the X position of the panel
* @param y the Y position of the panel
* @param width the width of the panel
@@ -241,46 +239,46 @@ public class ScreenDrawing {
* @param hilight the top/left hilight ARGB color
* @param outline the outline ARGB color
*/
- public static void drawGuiPanel(MatrixStack matrices, int x, int y, int width, int height, int shadow, int panel, int hilight, int outline) {
- coloredRect(matrices, x + 3, y + 3, width - 6, height - 6, panel); //Main panel area
-
- coloredRect(matrices, x + 2, y + 1, width - 4, 2, hilight); //Top hilight
- coloredRect(matrices, x + 2, y + height - 3, width - 4, 2, shadow); //Bottom shadow
- coloredRect(matrices, x + 1, y + 2, 2, height - 4, hilight); //Left hilight
- coloredRect(matrices, x + width - 3, y + 2, 2, height - 4, shadow); //Right shadow
- coloredRect(matrices, x + width - 3, y + 2, 1, 1, panel); //Topright non-hilight/non-shadow transition pixel
- coloredRect(matrices, x + 2, y + height - 3, 1, 1, panel); //Bottomleft non-hilight/non-shadow transition pixel
- coloredRect(matrices, x + 3, y + 3, 1, 1, hilight); //Topleft round hilight pixel
- coloredRect(matrices, x + width - 4, y + height - 4, 1, 1, shadow); //Bottomright round shadow pixel
-
- coloredRect(matrices, x + 2, y, width - 4, 1, outline); //Top outline
- coloredRect(matrices, x, y + 2, 1, height - 4, outline); //Left outline
- coloredRect(matrices, x + width - 1, y + 2, 1, height - 4, outline); //Right outline
- coloredRect(matrices, x + 2, y + height - 1, width - 4, 1, outline); //Bottom outline
- coloredRect(matrices, x + 1, y + 1, 1, 1, outline); //Topleft round pixel
- coloredRect(matrices, x + 1, y + height - 2, 1, 1, outline); //Bottomleft round pixel
- coloredRect(matrices, x + width - 2, y + 1, 1, 1, outline); //Topright round pixel
- coloredRect(matrices, x + width - 2, y + height - 2, 1, 1, outline); //Bottomright round pixel
+ public static void drawGuiPanel(DrawContext context, int x, int y, int width, int height, int shadow, int panel, int hilight, int outline) {
+ coloredRect(context, x + 3, y + 3, width - 6, height - 6, panel); //Main panel area
+
+ coloredRect(context, x + 2, y + 1, width - 4, 2, hilight); //Top hilight
+ coloredRect(context, x + 2, y + height - 3, width - 4, 2, shadow); //Bottom shadow
+ coloredRect(context, x + 1, y + 2, 2, height - 4, hilight); //Left hilight
+ coloredRect(context, x + width - 3, y + 2, 2, height - 4, shadow); //Right shadow
+ coloredRect(context, x + width - 3, y + 2, 1, 1, panel); //Topright non-hilight/non-shadow transition pixel
+ coloredRect(context, x + 2, y + height - 3, 1, 1, panel); //Bottomleft non-hilight/non-shadow transition pixel
+ coloredRect(context, x + 3, y + 3, 1, 1, hilight); //Topleft round hilight pixel
+ coloredRect(context, x + width - 4, y + height - 4, 1, 1, shadow); //Bottomright round shadow pixel
+
+ coloredRect(context, x + 2, y, width - 4, 1, outline); //Top outline
+ coloredRect(context, x, y + 2, 1, height - 4, outline); //Left outline
+ coloredRect(context, x + width - 1, y + 2, 1, height - 4, outline); //Right outline
+ coloredRect(context, x + 2, y + height - 1, width - 4, 1, outline); //Bottom outline
+ coloredRect(context, x + 1, y + 1, 1, 1, outline); //Topleft round pixel
+ coloredRect(context, x + 1, y + height - 2, 1, 1, outline); //Bottomleft round pixel
+ coloredRect(context, x + width - 2, y + 1, 1, 1, outline); //Topright round pixel
+ coloredRect(context, x + width - 2, y + height - 2, 1, 1, outline); //Bottomright round pixel
}
/**
* Draws a default-sized recessed itemslot panel
*/
- public static void drawBeveledPanel(MatrixStack matrices, int x, int y) {
- drawBeveledPanel(matrices, x, y, 18, 18, 0xFF373737, 0xFF8b8b8b, 0xFFFFFFFF);
+ public static void drawBeveledPanel(DrawContext context, int x, int y) {
+ drawBeveledPanel(context, x, y, 18, 18, 0xFF373737, 0xFF8b8b8b, 0xFFFFFFFF);
}
/**
* Draws a default-color recessed itemslot panel of variable size
*/
- public static void drawBeveledPanel(MatrixStack matrices, int x, int y, int width, int height) {
- drawBeveledPanel(matrices, x, y, width, height, 0xFF373737, 0xFF8b8b8b, 0xFFFFFFFF);
+ public static void drawBeveledPanel(DrawContext context, int x, int y, int width, int height) {
+ drawBeveledPanel(context, x, y, width, height, 0xFF373737, 0xFF8b8b8b, 0xFFFFFFFF);
}
/**
* Draws a generalized-case beveled panel. Can be inset or outset depending on arguments.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param x x coordinate of the topleft corner
* @param y y coordinate of the topleft corner
* @param width width of the panel
@@ -289,18 +287,18 @@ public class ScreenDrawing {
* @param panel color of the panel area
* @param bottomright color of the bottom/right bevel
*/
- public static void drawBeveledPanel(MatrixStack matrices, int x, int y, int width, int height, int topleft, int panel, int bottomright) {
- coloredRect(matrices, x, y, width, height, panel); //Center panel
- coloredRect(matrices, x, y, width - 1, 1, topleft); //Top shadow
- coloredRect(matrices, x, y + 1, 1, height - 2, topleft); //Left shadow
- coloredRect(matrices, x + width - 1, y + 1, 1, height - 1, bottomright); //Right hilight
- coloredRect(matrices, x + 1, y + height - 1, width - 1, 1, bottomright); //Bottom hilight
+ public static void drawBeveledPanel(DrawContext context, int x, int y, int width, int height, int topleft, int panel, int bottomright) {
+ coloredRect(context, x, y, width, height, panel); //Center panel
+ coloredRect(context, x, y, width - 1, 1, topleft); //Top shadow
+ coloredRect(context, x, y + 1, 1, height - 2, topleft); //Left shadow
+ coloredRect(context, x + width - 1, y + 1, 1, height - 1, bottomright); //Right hilight
+ coloredRect(context, x + 1, y + height - 1, width - 1, 1, bottomright); //Bottom hilight
}
/**
* Draws a string with a custom alignment.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param s the string
* @param align the alignment of the string
* @param x the X position
@@ -308,22 +306,23 @@ public class ScreenDrawing {
* @param width the width of the string, used for aligning
* @param color the text color
*/
- public static void drawString(MatrixStack matrices, String s, HorizontalAlignment align, int x, int y, int width, int color) {
+ public static void drawString(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) {
+ var textRenderer = MinecraftClient.getInstance().textRenderer;
switch (align) {
case LEFT -> {
- MinecraftClient.getInstance().textRenderer.draw(matrices, s, x, y, color);
+ context.drawText(textRenderer, s, x, y, color, false);
}
case CENTER -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
+ int wid = textRenderer.getWidth(s);
int l = (width / 2) - (wid / 2);
- MinecraftClient.getInstance().textRenderer.draw(matrices, s, x + l, y, color);
+ context.drawText(textRenderer, s, x + l, y, color, false);
}
case RIGHT -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
+ int wid = textRenderer.getWidth(s);
int l = width - wid;
- MinecraftClient.getInstance().textRenderer.draw(matrices, s, x + l, y, color);
+ context.drawText(textRenderer, s, x + l, y, color, false);
}
}
}
@@ -331,7 +330,7 @@ public class ScreenDrawing {
/**
* Draws a text component with a custom alignment.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param text the text
* @param align the alignment of the string
* @param x the X position
@@ -340,22 +339,23 @@ public class ScreenDrawing {
* @param color the text color
* @since 1.9.0
*/
- public static void drawString(MatrixStack matrices, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) {
+ public static void drawString(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) {
+ var textRenderer = MinecraftClient.getInstance().textRenderer;
switch (align) {
case LEFT -> {
- MinecraftClient.getInstance().textRenderer.draw(matrices, text, x, y, color);
+ context.drawText(textRenderer, text, x, y, color, false);
}
case CENTER -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
+ int wid = textRenderer.getWidth(text);
int l = (width / 2) - (wid / 2);
- MinecraftClient.getInstance().textRenderer.draw(matrices, text, x + l, y, color);
+ context.drawText(textRenderer, text, x + l, y, color, false);
}
case RIGHT -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
+ int wid = textRenderer.getWidth(text);
int l = width - wid;
- MinecraftClient.getInstance().textRenderer.draw(matrices, text, x + l, y, color);
+ context.drawText(textRenderer, text, x + l, y, color, false);
}
}
}
@@ -363,7 +363,7 @@ public class ScreenDrawing {
/**
* Draws a shadowed string.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param s the string
* @param align the alignment of the string
* @param x the X position
@@ -371,22 +371,23 @@ public class ScreenDrawing {
* @param width the width of the string, used for aligning
* @param color the text color
*/
- public static void drawStringWithShadow(MatrixStack matrices, String s, HorizontalAlignment align, int x, int y, int width, int color) {
+ public static void drawStringWithShadow(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) {
+ var textRenderer = MinecraftClient.getInstance().textRenderer;
switch (align) {
case LEFT -> {
- MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, s, x, y, color);
+ context.drawText(textRenderer, s, x, y, color, true);
}
case CENTER -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
+ int wid = textRenderer.getWidth(s);
int l = (width / 2) - (wid / 2);
- MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, s, x + l, y, color);
+ context.drawText(textRenderer, s, x + l, y, color, true);
}
case RIGHT -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
+ int wid = textRenderer.getWidth(s);
int l = width - wid;
- MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, s, x + l, y, color);
+ context.drawText(textRenderer, s, x + l, y, color, true);
}
}
}
@@ -394,7 +395,7 @@ public class ScreenDrawing {
/**
* Draws a shadowed text component.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param text the text component
* @param align the alignment of the string
* @param x the X position
@@ -402,22 +403,23 @@ public class ScreenDrawing {
* @param width the width of the string, used for aligning
* @param color the text color
*/
- public static void drawStringWithShadow(MatrixStack matrices, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) {
+ public static void drawStringWithShadow(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) {
+ var textRenderer = MinecraftClient.getInstance().textRenderer;
switch (align) {
case LEFT -> {
- MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text, x, y, color);
+ context.drawText(textRenderer, text, x, y, color, true);
}
case CENTER -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
+ int wid = textRenderer.getWidth(text);
int l = (width / 2) - (wid / 2);
- MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text, x + l, y, color);
+ context.drawText(textRenderer, text, x + l, y, color, true);
}
case RIGHT -> {
- int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
+ int wid = textRenderer.getWidth(text);
int l = width - wid;
- MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text, x + l, y, color);
+ context.drawText(textRenderer, text, x + l, y, color, true);
}
}
}
@@ -425,27 +427,27 @@ public class ScreenDrawing {
/**
* Draws a left-aligned string.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param s the string
* @param x the X position
* @param y the Y position
* @param color the text color
*/
- public static void drawString(MatrixStack matrices, String s, int x, int y, int color) {
- MinecraftClient.getInstance().textRenderer.draw(matrices, s, x, y, color);
+ public static void drawString(DrawContext context, String s, int x, int y, int color) {
+ context.drawText(MinecraftClient.getInstance().textRenderer, s, x, y, color, false);
}
/**
* Draws a left-aligned text component.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param text the text component
* @param x the X position
* @param y the Y position
* @param color the text color
*/
- public static void drawString(MatrixStack matrices, OrderedText text, int x, int y, int color) {
- MinecraftClient.getInstance().textRenderer.draw(matrices, text, x, y, color);
+ public static void drawString(DrawContext context, OrderedText text, int x, int y, int color) {
+ context.drawText(MinecraftClient.getInstance().textRenderer, text, x, y, color, false);
}
/**
@@ -454,16 +456,14 @@ public class ScreenDrawing {
* This method has no effect when the caller is not in a LibGui screen.
* For example, there will be nothing drawn in HUDs.
*
- * @param matrices the rendering matrix stack
+ * @param context the draw context
* @param textStyle the text style
* @param x the X position
* @param y the Y position
* @since 4.0.0
*/
- public static void drawTextHover(MatrixStack matrices, @Nullable Style textStyle, int x, int y) {
- if (MinecraftClient.getInstance().currentScreen instanceof CottonScreenImpl screen) {
- screen.renderTextHover(matrices, textStyle, x, y);
- }
+ public static void drawTextHover(DrawContext context, @Nullable Style textStyle, int x, int y) {
+ context.drawHoverEvent(MinecraftClient.getInstance().textRenderer, textStyle, x, y);
}
public static int colorAtOpacity(int opaque, float opacity) {
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java
index f54e9fa..490833f 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java
@@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -53,7 +53,7 @@ public final class VisualLogger {
}
@Environment(EnvType.CLIENT)
- public static void render(MatrixStack matrices) {
+ public static void render(DrawContext context) {
var client = MinecraftClient.getInstance();
var textRenderer = client.textRenderer;
int width = client.getWindow().getScaledWidth();
@@ -67,8 +67,8 @@ public final class VisualLogger {
int y = 0;
for (var line : lines) {
- ScreenDrawing.coloredRect(matrices, 2, 2 + y, textRenderer.getWidth(line), fontHeight, 0x88_000000);
- ScreenDrawing.drawString(matrices, line, 2, 2 + y, 0xFF_FFFFFF);
+ ScreenDrawing.coloredRect(context, 2, 2 + y, textRenderer.getWidth(line), fontHeight, 0x88_000000);
+ ScreenDrawing.drawString(context, line, 2, 2 + y, 0xFF_FFFFFF);
y += fontHeight;
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonScreenImpl.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonScreenImpl.java
index cd215b3..4050c64 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonScreenImpl.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonScreenImpl.java
@@ -2,8 +2,6 @@ package io.github.cottonmc.cotton.gui.impl.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Style;
import io.github.cottonmc.cotton.gui.GuiDescription;
import io.github.cottonmc.cotton.gui.widget.WWidget;
@@ -17,6 +15,4 @@ public interface CottonScreenImpl {
WWidget getLastResponder();
void setLastResponder(@Nullable WWidget lastResponder);
-
- void renderTextHover(MatrixStack matrices, @Nullable Style textStyle, int x, int y);
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchTextureRendererImpl.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchTextureRendererImpl.java
index 9227f94..d044dce 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchTextureRendererImpl.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchTextureRendererImpl.java
@@ -3,12 +3,12 @@ package io.github.cottonmc.cotton.gui.impl.client;
import com.mojang.blaze3d.systems.RenderCall;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gl.ShaderProgram;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
@@ -19,20 +19,20 @@ import org.joml.Matrix4f;
/**
* An implementation of LibNinePatch's {@link ContextualTextureRenderer} for identifiers.
*/
-public enum NinePatchTextureRendererImpl implements ContextualTextureRenderer Hovering is used by LibGui itself mostly for narration support.
* For rendering, it might be preferable that you check the mouse coordinates in
- * {@link #paint(MatrixStack, int, int, int, int) paint()} directly.
+ * {@link #paint(DrawContext, int, int, int, int) paint()} directly.
* That lets you react to different parts of the widget being hovered over.
*
* @return the {@code hovered} property
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/Icon.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/Icon.java
index ccf1bcc..3075814 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/Icon.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/Icon.java
@@ -2,7 +2,7 @@ package io.github.cottonmc.cotton.gui.widget.icon;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
/**
* A square icon for a widget such as a button.
@@ -15,11 +15,11 @@ public interface Icon {
/**
* Paints this icon.
*
- * @param matrices the GUI matrix stack
- * @param x the X coordinate
- * @param y the Y coordinate
- * @param size the size of this icon in pixels (size N means a N*N square)
+ * @param context the draw context
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param size the size of this icon in pixels (size N means a N*N square)
*/
@Environment(EnvType.CLIENT)
- void paint(MatrixStack matrices, int x, int y, int size);
+ void paint(DrawContext context, int x, int y, int size);
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java
index f979b44..9da86ee 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java
@@ -2,8 +2,7 @@ package io.github.cottonmc.cotton.gui.widget.icon;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.item.ItemRenderer;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -41,15 +40,13 @@ public class ItemIcon implements Icon {
@Environment(EnvType.CLIENT)
@Override
- public void paint(MatrixStack matrices, int x, int y, int size) {
- MinecraftClient client = MinecraftClient.getInstance();
- ItemRenderer renderer = client.getItemRenderer();
+ public void paint(DrawContext context, int x, int y, int size) {
float scale = size != 16 ? ((float) size / 16f) : 1f;
-
+ MatrixStack matrices = context.getMatrices();
matrices.push();
matrices.translate(x, y, 0);
matrices.scale(scale, scale, 1);
- renderer.renderInGui(matrices, stack, 0, 0);
+ context.drawItemWithoutEntity(stack, 0, 0);
matrices.pop();
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java
index acc3ce5..c822d88 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java
@@ -2,7 +2,7 @@ package io.github.cottonmc.cotton.gui.widget.icon;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.Identifier;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
@@ -79,7 +79,7 @@ public class TextureIcon implements Icon {
@Environment(EnvType.CLIENT)
@Override
- public void paint(MatrixStack matrices, int x, int y, int size) {
- ScreenDrawing.texturedRect(matrices, x, y, size, size, texture, color, opacity);
+ public void paint(DrawContext context, int x, int y, int size) {
+ ScreenDrawing.texturedRect(context, x, y, size, size, texture, color, opacity);
}
}
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index f127656..646abd4 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -25,12 +25,12 @@
"mixins": ["mixins.libgui.json"],
"depends": {
"java": ">=17",
- "fabricloader": ">=0.14.17",
+ "fabricloader": ">=0.14.21",
"fabric-api-base": ">=0.4.4",
"fabric-lifecycle-events-v1": "^2.0.2",
"fabric-networking-api-v1": "^1.0.21",
- "fabric-rendering-v1": "^2.1.0",
- "minecraft": ">=1.19.4",
+ "fabric-rendering-v1": "^3.0.6",
+ "minecraft": ">=1.20-rc.1",
"jankson": "^5.0.1",
"libninepatch": "^1.2.0"
},
diff --git a/src/testMod/java/io/github/cottonmc/test/TestItemDescription.java b/src/testMod/java/io/github/cottonmc/test/TestItemDescription.java
index 4c9c1f0..45be514 100644
--- a/src/testMod/java/io/github/cottonmc/test/TestItemDescription.java
+++ b/src/testMod/java/io/github/cottonmc/test/TestItemDescription.java
@@ -2,7 +2,7 @@ package io.github.cottonmc.test;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.StackReference;
import net.minecraft.text.Text;
@@ -149,8 +149,8 @@ public class TestItemDescription extends ItemSyncedGuiDescription {
}
@Override
- public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
- ScreenDrawing.coloredRect(matrices, x, y, this.getWidth(), this.getHeight(), color);
+ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
+ ScreenDrawing.coloredRect(context, x, y, this.getWidth(), this.getHeight(), color);
}
}
}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java b/src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java
index 839072e..7bc7ffb 100644
--- a/src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java
+++ b/src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java
@@ -2,7 +2,7 @@ package io.github.cottonmc.test.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
@@ -149,8 +149,8 @@ public class TestClientGui extends LightweightGuiDescription {
}
@Override
- public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
- ScreenDrawing.coloredRect(matrices, x, y, this.getWidth(), this.getHeight(), color);
+ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
+ ScreenDrawing.coloredRect(context, x, y, this.getWidth(), this.getHeight(), color);
}
}
}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/WHudTest.java b/src/testMod/java/io/github/cottonmc/test/client/WHudTest.java
index 98f4d0f..2f07c3a 100644
--- a/src/testMod/java/io/github/cottonmc/test/client/WHudTest.java
+++ b/src/testMod/java/io/github/cottonmc/test/client/WHudTest.java
@@ -2,7 +2,7 @@ package io.github.cottonmc.test.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.WWidget;
@@ -14,8 +14,8 @@ public class WHudTest extends WWidget {
private static final Logger LOGGER = LogManager.getLogger();
@Override
- public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
- ScreenDrawing.coloredRect(matrices, x, y, width, height, 0xFF_00FF00);
+ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
+ ScreenDrawing.coloredRect(context, x, y, width, height, 0xFF_00FF00);
}
@Override
--
cgit
From 6b14e2b3afa122744d3ae209703fc44b041b4e80 Mon Sep 17 00:00:00 2001
From: Juuz <6596629+Juuxel@users.noreply.github.com>
Date: Sun, 4 Jun 2023 00:10:07 +0300
Subject: ScreenDrawing: Clean up javadoc
---
.../cottonmc/cotton/gui/client/ScreenDrawing.java | 242 ++++++++++-----------
1 file changed, 121 insertions(+), 121 deletions(-)
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
index 64e9096..4064a04 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
@@ -27,13 +27,13 @@ public class ScreenDrawing {
/**
* Draws a textured rectangle.
*
- * @param context the draw context
- * @param x the x coordinate of the box on-screen
- * @param y the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the Identifier for the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param context the draw context
+ * @param x the x coordinate of the box on-screen
+ * @param y the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the Identifier for the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
*/
public static void texturedRect(DrawContext context, int x, int y, int width, int height, Identifier texture, int color) {
texturedRect(context, x, y, width, height, texture, 0, 0, 1, 1, color, 1.0f);
@@ -42,14 +42,14 @@ public class ScreenDrawing {
/**
* Draws a textured rectangle.
*
- * @param context the draw context
- * @param x the x coordinate of the box on-screen
- * @param y the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the Identifier for the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
- * @param opacity opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)
+ * @param context the draw context
+ * @param x the x coordinate of the box on-screen
+ * @param y the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the Identifier for the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param opacity opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)
* @since 2.0.0
*/
public static void texturedRect(DrawContext context, int x, int y, int width, int height, Identifier texture, int color, float opacity) {
@@ -59,17 +59,17 @@ public class ScreenDrawing {
/**
* Draws a textured rectangle.
*
- * @param context the draw context
- * @param x the x coordinate of the box on-screen
- * @param y the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the Identifier for the texture
- * @param u1 the left edge of the texture
- * @param v1 the top edge of the texture
- * @param u2 the right edge of the texture
- * @param v2 the bottom edge of the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param context the draw context
+ * @param x the x coordinate of the box on-screen
+ * @param y the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the Identifier for the texture
+ * @param u1 the left edge of the texture
+ * @param v1 the top edge of the texture
+ * @param u2 the right edge of the texture
+ * @param v2 the bottom edge of the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
*/
public static void texturedRect(DrawContext context, int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color) {
texturedRect(context, x, y, width, height, texture, u1, v1, u2, v2, color, 1.0f);
@@ -78,13 +78,13 @@ public class ScreenDrawing {
/**
* Draws a textured rectangle.
*
- * @param context the draw context
- * @param x the x coordinate of the box on-screen
- * @param y the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param context the draw context
+ * @param x the x coordinate of the box on-screen
+ * @param y the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
* @since 3.0.0
*/
public static void texturedRect(DrawContext context, int x, int y, int width, int height, Texture texture, int color) {
@@ -94,14 +94,14 @@ public class ScreenDrawing {
/**
* Draws a textured rectangle.
*
- * @param context the draw context
- * @param x the x coordinate of the box on-screen
- * @param y the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
- * @param opacity opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)
+ * @param context the draw context
+ * @param x the x coordinate of the box on-screen
+ * @param y the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param opacity opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)
* @since 3.0.0
*/
public static void texturedRect(DrawContext context, int x, int y, int width, int height, Texture texture, int color, float opacity) {
@@ -111,18 +111,18 @@ public class ScreenDrawing {
/**
* Draws a textured rectangle.
*
- * @param context the draw context
- * @param x the x coordinate of the box on-screen
- * @param y the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the Identifier for the texture
- * @param u1 the left edge of the texture
- * @param v1 the top edge of the texture
- * @param u2 the right edge of the texture
- * @param v2 the bottom edge of the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
- * @param opacity opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)
+ * @param context the draw context
+ * @param x the x coordinate of the box on-screen
+ * @param y the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the Identifier for the texture
+ * @param u1 the left edge of the texture
+ * @param v1 the top edge of the texture
+ * @param u2 the right edge of the texture
+ * @param v2 the bottom edge of the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param opacity opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)
* @since 2.0.0
*/
public static void texturedRect(DrawContext context, int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color, float opacity) {
@@ -154,14 +154,14 @@ public class ScreenDrawing {
* If the texture is 256x256, this draws the texture at one pixel per texel.
*
* @param context the draw context
- * @param x the x coordinate of the box on-screen
- * @param y the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the Identifier for the texture
- * @param textureX the x offset into the texture
- * @param textureY the y offset into the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param x the x coordinate of the box on-screen
+ * @param y the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the Identifier for the texture
+ * @param textureX the x offset into the texture
+ * @param textureY the y offset into the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
*/
public static void texturedGuiRect(DrawContext context, int x, int y, int width, int height, Identifier texture, int textureX, int textureY, int color) {
float px = 1/256f;
@@ -174,12 +174,12 @@ public class ScreenDrawing {
* If the texture is 256x256, this draws the texture at one pixel per texel.
*
* @param context the draw context
- * @param left the x coordinate of the box on-screen
- * @param top the y coordinate of the box on-screen
- * @param width the width of the box on-screen
- * @param height the height of the box on-screen
- * @param texture the Identifier for the texture
- * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
+ * @param left the x coordinate of the box on-screen
+ * @param top the y coordinate of the box on-screen
+ * @param width the width of the box on-screen
+ * @param height the height of the box on-screen
+ * @param texture the Identifier for the texture
+ * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
*/
public static void texturedGuiRect(DrawContext context, int left, int top, int width, int height, Identifier texture, int color) {
texturedGuiRect(context, left, top, width, height, texture, 0, 0, color);
@@ -199,10 +199,10 @@ public class ScreenDrawing {
* Draws a beveled, round rectangle that is substantially similar to default Minecraft UI panels.
*
* @param context the draw context
- * @param x the X position of the panel
- * @param y the Y position of the panel
- * @param width the width of the panel
- * @param height the height of the panel
+ * @param x the X position of the panel
+ * @param y the Y position of the panel
+ * @param width the width of the panel
+ * @param height the height of the panel
*/
public static void drawGuiPanel(DrawContext context, int x, int y, int width, int height) {
if (LibGui.isDarkMode()) drawGuiPanel(context, x, y, width, height, 0xFF0B0B0B, 0xFF2F2F2F, 0xFF414141, 0xFF000000);
@@ -212,7 +212,7 @@ public class ScreenDrawing {
/**
* Draws a beveled, round, and colored rectangle that is substantially similar to default Minecraft UI panels.
*
- * @param context the draw context
+ * @param context the draw context
* @param x the X position of the panel
* @param y the Y position of the panel
* @param width the width of the panel
@@ -230,14 +230,14 @@ public class ScreenDrawing {
* Draws a beveled, round rectangle with custom edge colors that is substantially similar to default Minecraft UI panels.
*
* @param context the draw context
- * @param x the X position of the panel
- * @param y the Y position of the panel
- * @param width the width of the panel
- * @param height the height of the panel
- * @param shadow the bottom/right shadow ARGB color
- * @param panel the center ARGB color
- * @param hilight the top/left hilight ARGB color
- * @param outline the outline ARGB color
+ * @param x the X position of the panel
+ * @param y the Y position of the panel
+ * @param width the width of the panel
+ * @param height the height of the panel
+ * @param shadow the bottom/right shadow ARGB color
+ * @param panel the center ARGB color
+ * @param hilight the top/left hilight ARGB color
+ * @param outline the outline ARGB color
*/
public static void drawGuiPanel(DrawContext context, int x, int y, int width, int height, int shadow, int panel, int hilight, int outline) {
coloredRect(context, x + 3, y + 3, width - 6, height - 6, panel); //Main panel area
@@ -278,14 +278,14 @@ public class ScreenDrawing {
/**
* Draws a generalized-case beveled panel. Can be inset or outset depending on arguments.
*
- * @param context the draw context
- * @param x x coordinate of the topleft corner
- * @param y y coordinate of the topleft corner
- * @param width width of the panel
- * @param height height of the panel
- * @param topleft color of the top/left bevel
- * @param panel color of the panel area
- * @param bottomright color of the bottom/right bevel
+ * @param context the draw context
+ * @param x x coordinate of the topleft corner
+ * @param y y coordinate of the topleft corner
+ * @param width width of the panel
+ * @param height height of the panel
+ * @param topleft color of the top/left bevel
+ * @param panel color of the panel area
+ * @param bottomright color of the bottom/right bevel
*/
public static void drawBeveledPanel(DrawContext context, int x, int y, int width, int height, int topleft, int panel, int bottomright) {
coloredRect(context, x, y, width, height, panel); //Center panel
@@ -299,12 +299,12 @@ public class ScreenDrawing {
* Draws a string with a custom alignment.
*
* @param context the draw context
- * @param s the string
- * @param align the alignment of the string
- * @param x the X position
- * @param y the Y position
- * @param width the width of the string, used for aligning
- * @param color the text color
+ * @param s the string
+ * @param align the alignment of the string
+ * @param x the X position
+ * @param y the Y position
+ * @param width the width of the string, used for aligning
+ * @param color the text color
*/
public static void drawString(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) {
var textRenderer = MinecraftClient.getInstance().textRenderer;
@@ -331,12 +331,12 @@ public class ScreenDrawing {
* Draws a text component with a custom alignment.
*
* @param context the draw context
- * @param text the text
- * @param align the alignment of the string
- * @param x the X position
- * @param y the Y position
- * @param width the width of the string, used for aligning
- * @param color the text color
+ * @param text the text
+ * @param align the alignment of the string
+ * @param x the X position
+ * @param y the Y position
+ * @param width the width of the string, used for aligning
+ * @param color the text color
* @since 1.9.0
*/
public static void drawString(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) {
@@ -364,12 +364,12 @@ public class ScreenDrawing {
* Draws a shadowed string.
*
* @param context the draw context
- * @param s the string
- * @param align the alignment of the string
- * @param x the X position
- * @param y the Y position
- * @param width the width of the string, used for aligning
- * @param color the text color
+ * @param s the string
+ * @param align the alignment of the string
+ * @param x the X position
+ * @param y the Y position
+ * @param width the width of the string, used for aligning
+ * @param color the text color
*/
public static void drawStringWithShadow(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) {
var textRenderer = MinecraftClient.getInstance().textRenderer;
@@ -396,12 +396,12 @@ public class ScreenDrawing {
* Draws a shadowed text component.
*
* @param context the draw context
- * @param text the text component
- * @param align the alignment of the string
- * @param x the X position
- * @param y the Y position
- * @param width the width of the string, used for aligning
- * @param color the text color
+ * @param text the text component
+ * @param align the alignment of the string
+ * @param x the X position
+ * @param y the Y position
+ * @param width the width of the string, used for aligning
+ * @param color the text color
*/
public static void drawStringWithShadow(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) {
var textRenderer = MinecraftClient.getInstance().textRenderer;
@@ -428,10 +428,10 @@ public class ScreenDrawing {
* Draws a left-aligned string.
*
* @param context the draw context
- * @param s the string
- * @param x the X position
- * @param y the Y position
- * @param color the text color
+ * @param s the string
+ * @param x the X position
+ * @param y the Y position
+ * @param color the text color
*/
public static void drawString(DrawContext context, String s, int x, int y, int color) {
context.drawText(MinecraftClient.getInstance().textRenderer, s, x, y, color, false);
@@ -441,10 +441,10 @@ public class ScreenDrawing {
* Draws a left-aligned text component.
*
* @param context the draw context
- * @param text the text component
- * @param x the X position
- * @param y the Y position
- * @param color the text color
+ * @param text the text component
+ * @param x the X position
+ * @param y the Y position
+ * @param color the text color
*/
public static void drawString(DrawContext context, OrderedText text, int x, int y, int color) {
context.drawText(MinecraftClient.getInstance().textRenderer, text, x, y, color, false);
@@ -456,7 +456,7 @@ public class ScreenDrawing {
* This method has no effect when the caller is not in a LibGui screen.
* For example, there will be nothing drawn in HUDs.
*
- * @param context the draw context
+ * @param context the draw context
* @param textStyle the text style
* @param x the X position
* @param y the Y position
--
cgit