Skip to content

Commit

Permalink
Merge pull request #25 from Basicprogrammer10/1-20-update
Browse files Browse the repository at this point in the history
Update for Minecraft 1.20
  • Loading branch information
connorslade authored Jun 28, 2023
2 parents 25d4b0a + 19dbec6 commit d0bdcbc
Show file tree
Hide file tree
Showing 42 changed files with 211 additions and 198 deletions.
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.17
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21
# Mod Properties
mod_version=0.1.3_alpha
mod_version=0.1.4_alpha
maven_group=com.connorcode
archives_base_name=sigma-utils
# Dependencies
fabric_version=0.76.0+1.19.4
mod_menu_version=6.1.0-rc.4
fabric_version=0.83.0+1.20
mod_menu_version=7.0.1
12 changes: 6 additions & 6 deletions src/main/java/com/connorcode/sigmautils/commands/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.StringVisitable;
import net.minecraft.text.Text;

Expand Down Expand Up @@ -142,19 +142,19 @@ protected void init() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
renderBackground(drawContext);

var lines = textRenderer.wrapLines(StringVisitable.plain(note.text), noteWidth);
var startX = width / 2f - noteWidth / 2f;
var height = lines.size() * 10;

fill(matrices, (int) startX, 0, (int) (startX + noteWidth), height, 0x7F000000);
drawContext.fill((int) startX, 0, (int) (startX + noteWidth), height, 0x7F000000);

for (int i = 0; i < lines.size(); i++)
textRenderer.draw(matrices, lines.get(i), startX, i * 10, 0xFFFFFF);
drawContext.drawText(textRenderer, lines.get(i), (int) startX, i * 10, 0xFFFFFF, false);

super.render(matrices, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);
}
}
}
10 changes: 5 additions & 5 deletions src/main/java/com/connorcode/sigmautils/config/ConfigGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.connorcode.sigmautils.module.Category;
import com.connorcode.sigmautils.module.Module;
import com.connorcode.sigmautils.modules.meta.Padding;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Util;

Expand Down Expand Up @@ -69,15 +69,15 @@ protected void init() {
}).position(width - githubLen - padding * 5, height - 20 - padding).size(githubLen + padding * 4, 20).build());
}

public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
int padding = getPadding();
this.renderBackground(matrices);
this.renderBackground(drawContext);

for (int x = 0; x < Category.values().length; x++)
drawCenteredTextWithShadow(matrices, textRenderer, Text.of("§f§n§l" + Category.values()[x].toString()),
drawContext.drawCenteredTextWithShadow(textRenderer, Text.of("§f§n§l" + Category.values()[x].toString()),
75 + padding + x * (150 + padding), padding, 0);

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

public void close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.connorcode.sigmautils.config.settings.Setting;
import com.connorcode.sigmautils.misc.util.Util;
import com.connorcode.sigmautils.module.Module;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Pair;

Expand Down Expand Up @@ -83,26 +83,26 @@ public void close() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
Setting.RenderData renderData = new Setting.RenderData(this, matrices, mouseX, mouseY, delta);
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
Setting.RenderData renderData = new Setting.RenderData(this, drawContext, mouseX, mouseY, delta);
int padding = getPadding();

this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
this.renderBackground(drawContext);
super.render(drawContext, mouseX, mouseY, delta);

int x = -75 + 20 + padding;
for (Pair<String, List<Setting<?>>> entry : settings) {
x += 150 + padding;
if (entry.getLeft() != null)
drawCenteredTextWithShadow(matrices, textRenderer, Text.of(String.format("§f§n§l%s", entry.getLeft())),
x,
padding * 2 + textRenderer.fontHeight, 0);
drawContext.drawCenteredTextWithShadow(textRenderer,
Text.of(String.format("§f§n§l%s", entry.getLeft())),
x, padding * 2 + textRenderer.fontHeight, 0);

for (Setting<?> setting : entry.getRight())
setting.render(renderData, x - 75, elementPositions.get(setting.getName()));
}

drawCenteredTextWithShadow(matrices, textRenderer, Text.of(String.format("§f§n§l%s Settings", module.name)),
drawContext.drawCenteredTextWithShadow(textRenderer, Text.of(String.format("§f§n§l%s Settings", module.name)),
width / 2,
padding, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public int initRender(Screen screen, int x, int y, int width) {
(button -> BoolSetting.this.value = button.isChecked()),
((button, matrices, mouseX, mouseY) -> {
if (this.description == null) return;
screen.renderOrderedTooltip(matrices,
matrices.drawOrderedTooltip(client.textRenderer,
client.textRenderer.wrapLines(getDescription(), 200),
mouseX, mouseY);
})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import com.connorcode.sigmautils.misc.Components;
import com.connorcode.sigmautils.misc.util.Util;
import com.connorcode.sigmautils.module.Module;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -171,10 +171,10 @@ public void close() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
this.searchField.render(matrices, mouseX, mouseY, delta);
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
renderBackground(drawContext);
super.render(drawContext, mouseX, mouseY, delta);
this.searchField.render(drawContext, mouseX, mouseY, delta);
}

@Override
Expand Down Expand Up @@ -250,9 +250,9 @@ public void close() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
renderBackground(drawContext);
super.render(drawContext, mouseX, mouseY, delta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public int initRender(Screen screen, int x, int y, int width) {
else editing = true;
}, (((button, matrices, mouseX, mouseY) -> {
if (this.description == null) return;
screen.renderOrderedTooltip(matrices,
matrices.drawOrderedTooltip(client.textRenderer,
client.textRenderer.wrapLines(getDescription(), 200), mouseX,
mouseY);
}))) {
Expand All @@ -116,7 +116,7 @@ public Text getMessage() {
@Override
public void render(RenderData data, int x, int y) {
if (!showTitle) return;
client.textRenderer.draw(data.matrices(), String.format("§f%s:", this.name), x, y, 0);
data.drawContext().drawText(client.textRenderer, String.format("§f%s:", this.name), x, y, 0, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public int initRender(Screen screen, SliderText slider, int x, int y, int width)
Util.addChild(screen, new Components.TooltipSlider(x, y, width, 20, slider.getText(),
MathHelper.clamp((this.value - this.min) / this.max, 0, 1)) {
@Override
protected Text getTooltip() {
protected Text tooltip() {
return Text.of(NumberSetting.this.description);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -136,9 +136,9 @@ protected void init() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.selectorWidget.render(matrices, mouseX, mouseY, delta);
super.render(matrices, mouseX, mouseY, delta);
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
this.selectorWidget.render(drawContext, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);
}

@Override
Expand Down Expand Up @@ -183,9 +183,9 @@ public boolean equals(Object obj) {
}

@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
SelectorWidget.this.client.textRenderer.drawWithShadow(matrices, this.value,
width / 2f - client.textRenderer.getWidth(this.value) / 2f, y + 1, 16777215, true);
public void render(DrawContext drawContext, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
drawContext.drawText(SelectorWidget.this.client.textRenderer, this.value,
(int) (width / 2f - client.textRenderer.getWidth(this.value) / 2f), y + 1, 16777215, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.connorcode.sigmautils.config.Config;
import com.connorcode.sigmautils.misc.util.Util;
import com.connorcode.sigmautils.module.Module;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -89,6 +89,6 @@ public boolean onKeypress(int key, int scanCode, int modifiers) {
public void onClose() {
}

public record RenderData(Screen screen, MatrixStack matrices, int mouseX, int mouseY, float delta) {
public record RenderData(Screen screen, DrawContext drawContext, int mouseX, int mouseY, float delta) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public int initRender(Screen screen, int x, int y, int width) {
@Override
public void render(RenderData data, int x, int y) {
if (!showName) return;
client.textRenderer.draw(data.matrices(), String.format("§f%s:", this.name), x,
y + getPadding(), 0);
data.drawContext().drawText(client.textRenderer, String.format("§f%s:", this.name), x,
y + getPadding(), 0, false);
}

interface Callback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ public static <T> void selector(DynamicListSetting<T> setting, T resource, Strin
setting.add(resource);
((ScreenAccessor) screen).invokeClearAndInit();
}).position(x, y).size(20, 20).tooltip(Tooltip.of(Text.of("Add element"))).build());
Util.addDrawable(screen, (matrices, mouseX, mouseY, delta) -> client.textRenderer.draw(matrices, display,
x + 20 + padding * 4 + gap, y + padding / 2f + 10 - client.textRenderer.fontHeight / 2f, 0xFFFFFF));
Util.addDrawable(screen, (matrices, mouseX, mouseY, delta) ->
matrices.drawText(client.textRenderer, display, x + 20 + padding * 4 + gap,
(int) (y + padding / 2f + 10 - client.textRenderer.fontHeight / 2f), 0xFFFFFF, false)
);
}

public static <T> void render(DynamicListSetting<T> setting, T resource, String display, Screen screen, int x, int y, int gap) {
Expand All @@ -47,8 +49,10 @@ public static <T> void render(DynamicListSetting<T> setting, T resource, String
setting.remove(resource);
((ScreenAccessor) screen).invokeClearAndInit();
}).position(x, y).size(20, 20).tooltip(Tooltip.of(Text.of("Remove element"))).build());
Util.addDrawable(screen, (matrices, mouseX, mouseY, delta) -> client.textRenderer.draw(matrices, display,
x + 20 + padding * 4 + gap, y + padding / 2f + 10 - client.textRenderer.fontHeight / 2f, 0xffffff));
Util.addDrawable(screen, (matrices, mouseX, mouseY, delta) ->
matrices.drawText(client.textRenderer, display, x + 20 + padding * 4 + gap,
(int) (y + padding / 2f + 10 - client.textRenderer.fontHeight / 2f), 0xffffff, false))
;
}


Expand Down
Loading

0 comments on commit d0bdcbc

Please sign in to comment.