diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2023-05-11 01:54:39 -0400 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2023-06-17 01:32:14 -0400 |
commit | b28a20421348c3385022deeb3cb1ea0ea74928af (patch) | |
tree | 71194fe5dc1ad6c92cb7e044216d241738704e8d /src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget | |
parent | 826a6d8fd9a38c794eb70b7a71aa969dfddd685c (diff) | |
download | Skyblocker-b28a20421348c3385022deeb3cb1ea0ea74928af.tar.gz Skyblocker-b28a20421348c3385022deeb3cb1ea0ea74928af.tar.bz2 Skyblocker-b28a20421348c3385022deeb3cb1ea0ea74928af.zip |
1.20 Port
The game launches successfully without any crashes!
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget')
8 files changed, 48 insertions, 53 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java index 6b96c151..33f77933 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java @@ -10,7 +10,7 @@ import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.Component; import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.text.MutableText; @@ -103,14 +103,15 @@ public abstract class Widget { /** * Draw this widget with a background */ - public final void render(MatrixStack ms) { - this.render(ms, true); + public final void render(DrawContext context) { + this.render(context, true); } /** * Draw this widget, possibly with a background */ - public final void render(MatrixStack ms, boolean hasBG) { + public final void render(DrawContext context, boolean hasBG) { + MatrixStack ms = context.getMatrices(); // not sure if this is the way to go, but it fixes Z-layer issues // like blocks being rendered behind the BG and the hotbar clipping into things @@ -123,9 +124,9 @@ public abstract class Widget { // move above other UI elements ms.translate(0, 0, 200); if (hasBG) { - DrawableHelper.fill(ms, x + 1, y, x + w - 1, y + h, COL_BG_BOX); - DrawableHelper.fill(ms, x, y + 1, x + 1, y + h - 1, COL_BG_BOX); - DrawableHelper.fill(ms, x + w - 1, y + 1, x + w, y + h - 1, COL_BG_BOX); + context.fill(x + 1, y, x + w - 1, y + h, COL_BG_BOX); + context.fill(x, y + 1, x + 1, y + h - 1, COL_BG_BOX); + context.fill(x + w - 1, y + 1, x + w, y + h - 1, COL_BG_BOX); } // move above background (if exists) ms.translate(0, 0, 100); @@ -133,19 +134,19 @@ public abstract class Widget { int strHeightHalf = Widget.txtRend.fontHeight / 2; int strAreaWidth = Widget.txtRend.getWidth(title) + 4; - txtRend.draw(ms, title, x + 8, y + 2, this.color); + context.drawText(txtRend, title, x + 8, y + 2, this.color, false); - this.drawHLine(ms, x + 2, y + 1 + strHeightHalf, 4); - this.drawHLine(ms, x + 2 + strAreaWidth + 4, y + 1 + strHeightHalf, w - 4 - 4 - strAreaWidth); - this.drawHLine(ms, x + 2, y + h - 2, w - 4); + this.drawHLine(context, x + 2, y + 1 + strHeightHalf, 4); + this.drawHLine(context, x + 2 + strAreaWidth + 4, y + 1 + strHeightHalf, w - 4 - 4 - strAreaWidth); + this.drawHLine(context, x + 2, y + h - 2, w - 4); - this.drawVLine(ms, x + 1, y + 2 + strHeightHalf, h - 4 - strHeightHalf); - this.drawVLine(ms, x + w - 2, y + 2 + strHeightHalf, h - 4 - strHeightHalf); + this.drawVLine(context, x + 1, y + 2 + strHeightHalf, h - 4 - strHeightHalf); + this.drawVLine(context, x + w - 2, y + 2 + strHeightHalf, h - 4 - strHeightHalf); int yOffs = y + BORDER_SZE_N; for (Component c : components) { - c.render(ms, x + BORDER_SZE_W, yOffs); + c.render(context, x + BORDER_SZE_W, yOffs); yOffs += c.getHeight() + Component.PAD_L; } // pop manipulations above @@ -153,12 +154,12 @@ public abstract class Widget { RenderSystem.disableDepthTest(); } - private void drawHLine(MatrixStack ms, int xpos, int ypos, int width) { - DrawableHelper.fill(ms, xpos, ypos, xpos + width, ypos + 1, this.color); + private void drawHLine(DrawContext context, int xpos, int ypos, int width) { + context.fill(xpos, ypos, xpos + width, ypos + 1, this.color); } - private void drawVLine(MatrixStack ms, int xpos, int ypos, int height) { - DrawableHelper.fill(ms, xpos, ypos, xpos + 1, ypos + height, this.color); + private void drawVLine(DrawContext context, int xpos, int ypos, int height) { + context.fill(xpos, ypos, xpos + 1, ypos + height, this.color); } /** diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java index 671b1f41..850cb3d2 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java @@ -2,8 +2,8 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.util.math.MatrixStack; /** * Abstract base class for a component that may be added to a Widget. @@ -15,12 +15,11 @@ public abstract class Component { public static final int PAD_L = 4; static TextRenderer txtRend = MinecraftClient.getInstance().textRenderer; - static ItemRenderer itmRend = MinecraftClient.getInstance().getItemRenderer(); // these should always be the content dimensions without any padding. int width, height; - public abstract void render(MatrixStack ms, int x, int y); + public abstract void render(DrawContext context, int x, int y); public int getWidth() { return this.width; diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java index f845eba5..afd05c26 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java @@ -1,7 +1,7 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component; import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -36,10 +36,10 @@ public class IcoFatTextComponent extends Component { } @Override - public void render(MatrixStack ms, int x, int y) { - itmRend.renderGuiItemIcon(ms, ico, x, y + ICO_OFFS); - txtRend.draw(ms, line1, x + ICO_DIM + PAD_L, y, 0xffffffff); - txtRend.draw(ms, line2, x + ICO_DIM + PAD_L, y + txtRend.fontHeight + PAD_S, 0xffffffff); + public void render(DrawContext context, int x, int y) { + context.drawItem(ico, x, y + ICO_OFFS); + context.drawText(txtRend, line1, x + ICO_DIM + PAD_L, y, 0xffffffff, false); + context.drawText(txtRend, line2, x + ICO_DIM + PAD_L, y + txtRend.fontHeight + PAD_S, 0xffffffff, false); } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java index 7a495a13..7ab92dd5 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java @@ -1,7 +1,7 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component; import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -32,9 +32,9 @@ public class IcoTextComponent extends Component { } @Override - public void render(MatrixStack ms, int x, int y) { - itmRend.renderGuiItemIcon(ms, ico, x, y); - txtRend.draw(ms, text, x + ICO_DIM + PAD_L, y + 5, 0xffffffff); + public void render(DrawContext context, int x, int y) { + context.drawItem(ico, x, y); + context.drawText(txtRend, text, x + ICO_DIM + PAD_L, y + 5, 0xffffffff, false); } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java index 265d11f1..34e0268b 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java @@ -1,6 +1,6 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -23,8 +23,8 @@ public class PlainTextComponent extends Component { } @Override - public void render(MatrixStack ms, int x, int y) { - txtRend.draw(ms, text, x + PAD_S, y, 0xffffffff); + public void render(DrawContext context, int x, int y) { + context.drawText(txtRend, text, x + PAD_S, y, 0xffffffff, false); } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlayerComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlayerComponent.java index 18859080..fd66ec73 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlayerComponent.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlayerComponent.java @@ -1,10 +1,8 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component; -import com.mojang.blaze3d.systems.RenderSystem; - +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.PlayerSkinDrawer; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; /** @@ -27,10 +25,9 @@ public class PlayerComponent extends Component { } @Override - public void render(MatrixStack ms, int x, int y) { - RenderSystem.setShaderTexture(0, tex); - PlayerSkinDrawer.draw(ms, x, y, SKIN_ICO_DIM); - txtRend.draw(ms, name, x + SKIN_ICO_DIM + PAD_S, y, 0xffffffff); + public void render(DrawContext context, int x, int y) { + PlayerSkinDrawer.draw(context, tex, x, y, SKIN_ICO_DIM); + context.drawText(txtRend, name, x + SKIN_ICO_DIM + PAD_S, y, 0xffffffff, false); } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java index b9ebc0e9..a7cc8d12 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java @@ -1,8 +1,7 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component; import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -55,16 +54,16 @@ public class ProgressComponent extends Component { } @Override - public void render(MatrixStack ms, int x, int y) { - itmRend.renderGuiItemIcon(ms, ico, x, y + ICO_OFFS); - txtRend.draw(ms, desc, x + ICO_DIM + PAD_L, y, 0xffffffff); + public void render(DrawContext context, int x, int y) { + context.drawItem(ico, x, y + ICO_OFFS); + context.drawText(txtRend, desc, x + ICO_DIM + PAD_L, y, 0xffffffff, false); int barX = x + ICO_DIM + PAD_L; int barY = y + txtRend.fontHeight + PAD_S; int endOffsX = ((int) (this.barW * (this.pcnt / 100f))); - DrawableHelper.fill(ms, barX + endOffsX, barY, barX + this.barW, barY + BAR_HEIGHT, COL_BG_BAR); - DrawableHelper.fill(ms, barX, barY, barX + endOffsX, barY + BAR_HEIGHT, + context.fill(barX + endOffsX, barY, barX + this.barW, barY + BAR_HEIGHT, COL_BG_BAR); + context.fill(barX, barY, barX + endOffsX, barY + BAR_HEIGHT, this.color); - txtRend.drawWithShadow(ms, bar, barX + 3, barY + 2, 0xffffffff); + context.drawTextWithShadow(txtRend, bar, barX + 3, barY + 2, 0xffffffff); } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/TableComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/TableComponent.java index 5d49be2c..30287dc0 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/TableComponent.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/TableComponent.java @@ -1,7 +1,6 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; /** * Meta-Component that consists of a grid of other components @@ -38,11 +37,11 @@ public class TableComponent extends Component { } @Override - public void render(MatrixStack ms, int xpos, int ypos) { + public void render(DrawContext context, int xpos, int ypos) { for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { if (comps[x][y] != null) { - comps[x][y].render(ms, xpos + (x * cellW), ypos + y * cellH); + comps[x][y].render(context, xpos + (x * cellW), ypos + y * cellH); } } // add a line before the col if we're not drawing the first one @@ -51,7 +50,7 @@ public class TableComponent extends Component { int lineX2 = xpos + (x * cellW) - PAD_S; int lineY1 = ypos + 1; int lineY2 = ypos + this.height - PAD_S - 1; // not sure why but it looks correct - DrawableHelper.fill(ms, lineX1, lineY1, lineX2, lineY2, this.color); + context.fill(lineX1, lineY1, lineX2, lineY2, this.color); } } } |