Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
Updated to 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jun 7, 2023
1 parent 80b4399 commit 965e9a8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.0-SNAPSHOT"
id "fabric-loom" version "1.2-SNAPSHOT"
id "maven-publish"
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
org.gradle.jvmargs=-Xmx1G

minecraft_version=1.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.14.19
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21

mod_version=1.2.0
mod_version=1.2.1
maven_group=de.florianmichael
archives_base_name=ui-utils-reborn

fabric_version=0.81.1+1.19.4
fabric_version=0.83.0+1.20
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.florianmichael.uiutilsreborn.widget.ExploitButtonWidget;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
Expand Down Expand Up @@ -193,28 +194,30 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
final var matrices = drawContext.getMatrices();

matrices.push();
matrices.translate(0, 0, -100);
this.parent.render(matrices, -1, -1, delta);
this.parent.render(drawContext, -1, -1, delta);
matrices.pop();

matrices.push();
matrices.translate(0, 0, 900);
this.renderBackground(matrices);
this.renderBackground(drawContext);

matrices.push();
matrices.scale(2F, 2F, 2F);
drawCenteredTextWithShadow(matrices, textRenderer, Text.literal(this.currentPacket.getDisplay()).asOrderedText(), this.width / 4, 2, -1);
drawContext.drawCenteredTextWithShadow(textRenderer, Text.literal(this.currentPacket.getDisplay()).asOrderedText(), this.width / 4, 2, -1);
matrices.pop();

if (this.action != null)
this.action.render(matrices);
this.action.render(drawContext);

if (this.status != null)
this.textRenderer.drawWithShadow(matrices, this.status, 0, 0, -1);
drawContext.drawTextWithShadow(textRenderer, this.status, 0, 0, -1);

super.render(matrices, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);
matrices.pop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import de.florianmichael.uiutilsreborn.util.ITextFieldAdapter;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
Expand All @@ -44,9 +45,9 @@ public MixinTextFieldWidget(int x, int y, int width, int height, Text message) {
}

@Inject(method = "renderButton", at = @At("RETURN"))
public void hookCustomSideInformation(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
public void hookCustomSideInformation(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (this.sideInformation != null)
this.textRenderer.drawWithShadow(matrices, this.sideInformation, this.getX() - textRenderer.getWidth(this.sideInformation.getString()) - 10, this.getY() + this.getHeight() / 4F, -1);
context.drawTextWithShadow(textRenderer, this.sideInformation, this.getX() - textRenderer.getWidth(this.sideInformation.getString()) - 10, this.getY() + this.getHeight() / 4, -1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
package de.florianmichael.uiutilsreborn.widget;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;

import java.awt.*;
import java.util.List;

public class DropboxWidget extends DrawableHelper {
public class DropboxWidget {

public final int x;
public final int y;
Expand Down Expand Up @@ -74,30 +73,31 @@ public void mouseClicked(final double mouseX, final double mouseY) {
}

// Thank you Lucy
private void drawRectBorder(MatrixStack matrices, int left, int top, int right, int bottom) {
DrawableHelper.fill(matrices, left - 1, top - 1, left, bottom + 1, -1);
DrawableHelper.fill(matrices, right, top - 1, right + 1, bottom + 1, -1);
DrawableHelper.fill(matrices, left, top - 1, right, top, -1);
DrawableHelper.fill(matrices, left, bottom, right, bottom + 1, -1);
private void drawRectBorder(final DrawContext drawContext, int left, int top, int right, int bottom) {
drawContext.fill(left - 1, top - 1, left, bottom + 1, -1);
drawContext.fill(right, top - 1, right + 1, bottom + 1, -1);
drawContext.fill(left, top - 1, right, top, -1);
drawContext.fill(left, bottom, right, bottom + 1, -1);
}

public void render(final MatrixStack matrices) {
DrawableHelper.fill(matrices, this.x, this.y, this.x + this.width, this.y + this.height, Color.BLACK.getRGB());
public void render(final DrawContext drawContext) {
drawContext.fill(this.x, this.y, this.x + this.width, this.y + this.height, Color.BLACK.getRGB());

final String text = this.isOpen() ? "↓" : "←";

MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text, (this.x + this.width) - MinecraftClient.getInstance().textRenderer.getWidth(text), this.y + (this.height / 2F) - 4, -1);
drawRectBorder(matrices, this.x, this.y, this.x + this.width, this.y + this.height);
final var fontRenderer = MinecraftClient.getInstance().textRenderer;
drawContext.drawTextWithShadow(fontRenderer, text, (this.x + this.width) - fontRenderer.getWidth(text), this.y + (this.height / 2) - 4, -1);
drawRectBorder(drawContext, this.x, this.y, this.x + this.width, this.y + this.height);

drawCenteredTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, Text.literal(this.options.get(this.selected)), this.x + (this.width / 2), this.y + (this.height / 2) - 4, -1);
drawContext.drawCenteredTextWithShadow(fontRenderer, Text.literal(this.options.get(this.selected)), this.x + (this.width / 2), this.y + (this.height / 2) - 4, -1);

if (this.isOpen()) {
DrawableHelper.fill(matrices, this.x, this.y + this.height, this.x + this.width, this.y + this.height + (this.options.size() * this.entryHeight), Color.BLACK.getRGB());
drawRectBorder(matrices, this.x, this.y + this.height + 1, this.x + this.width, this.y + this.height + (this.options.size() * this.entryHeight));
drawContext.fill(this.x, this.y + this.height, this.x + this.width, this.y + this.height + (this.options.size() * this.entryHeight), Color.BLACK.getRGB());
drawRectBorder(drawContext, this.x, this.y + this.height + 1, this.x + this.width, this.y + this.height + (this.options.size() * this.entryHeight));

int bypass = this.height;
for (String option : this.options) {
drawCenteredTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, Text.literal(option), this.x + this.width / 2, bypass + this.y + 1 + (this.entryHeight / 4), -1);
drawContext.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, Text.literal(option), this.x + this.width / 2, bypass + this.y + 1 + (this.entryHeight / 4), -1);
bypass += this.entryHeight;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"depends": {
"fabricloader": ">=0.14.9",
"fabric-api": "*",
"minecraft": "~1.19",
"minecraft": "~1.20",
"java": ">=17"
}
}

0 comments on commit 965e9a8

Please sign in to comment.