Skip to content

Commit

Permalink
forge crashes atm
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfudge committed Jun 9, 2023
1 parent a3a228f commit 4833bc6
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 71 deletions.
6 changes: 3 additions & 3 deletions TestForgeMod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ shadowJar {
exclude "fabric.mod.json"

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "forge"
archiveClassifier.set "forge"
}

jar {
classifier "dev"
archiveClassifier.set "dev"
}


Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ allprojects {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(18))
}
withSourcesJar()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.fabricmc.api.Environment;
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.gui.Element;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.Screen;
Expand Down Expand Up @@ -356,10 +356,10 @@ public void init() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
this.list.render(matrices, mouseX, mouseY, delta);
drawCenteredTextWithShadow(matrices, textRenderer, title, width / 2, 15, 0xFFFFFF);
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context);
this.list.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xFFFFFF);

for (EntryInfo info : entries) {
if (info.id.equals(modid)) {
Expand All @@ -370,17 +370,17 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
String key = translationPrefix + info.field.getName() + ".tooltip";

if (info.error != null && text.equals(name))
renderTooltip(matrices, info.error.getValue(), mouseX, mouseY);
context.drawTooltip(textRenderer, info.error.getValue(), mouseX, mouseY);
else if (I18n.hasTranslation(key) && text.equals(name)) {
List<Text> list = new ArrayList<>();
for (String str : I18n.translate(key).split("\n"))
list.add(Text.literal(str));
renderTooltip(matrices, list, mouseX, mouseY);
context.drawTooltip(textRenderer, list, mouseX, mouseY);
}
}
}
}
super.render(matrices, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
}
}

Expand Down Expand Up @@ -438,16 +438,17 @@ public static ButtonEntry create(List<ClickableWidget> buttons, Text text, Entry
return new ButtonEntry(buttons, text, info);
}

public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
@Override
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
buttons.forEach(b -> {
b.setY(y);
b.render(matrices, mouseX, mouseY, tickDelta);
b.render(context, mouseX, mouseY, tickDelta);
});
var color = info.comment ? 0x808080 : 0xFFFFFF;
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty())) {
if (info.centered)
textRenderer.drawWithShadow(matrices, text, MinecraftClient.getInstance().getWindow().getScaledWidth() / 2f - (textRenderer.getWidth(text) / 2f), y + 5, color);
else DrawableHelper.drawTextWithShadow(matrices, textRenderer, text, 12, y + 5, color);
context.drawTextWithShadow(textRenderer, text, MinecraftClient.getInstance().getWindow().getScaledWidth() / 2 - (textRenderer.getWidth(text) / 2), y + 5, color);
else context.drawTextWithShadow(textRenderer, text, 12, y + 5, color);
}
}

Expand Down
28 changes: 14 additions & 14 deletions common/src/main/java/fudge/notenoughcrashes/gui/CrashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.crash.CrashReport;

@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -42,31 +42,31 @@ public void init() {


@Override
public void render(MatrixStack matrixStack, int mouseY, int i, float f) {
renderBackground(matrixStack);
drawCenteredTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.title"), width / 2, height / 4 - 40, 0xFFFFFF);
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context);
context.drawCenteredTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.title"), width / 2, height / 4 - 40, 0xFFFFFF);

int textColor = 0xD0D0D0;
int x = width / 2 - 155;
int y = height / 4;

drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.summary"), x, y, textColor);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph1.line1"), x, y += 18, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.summary"), x, y, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph1.line1"), x, y += 18, textColor);

y += 11;

drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line1"), x, y += 11, textColor);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line2"), x, y += 9, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line1"), x, y += 11, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line2"), x, y += 9, textColor);

drawFileNameString(matrixStack, y);
drawFileNameString(context, y);
y += 11;

drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line1"), x, y += 12, textColor);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line2"), x, y += 9, textColor);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line3"), x, y += 9, textColor);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line4"), x, y + 9, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line1"), x, y += 12, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line2"), x, y += 9, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line3"), x, y += 9, textColor);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph3.line4"), x, y + 9, textColor);

super.render(matrixStack, mouseY, i, f);
super.render(context, mouseX, mouseY, delta);
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package fudge.notenoughcrashes.gui;

import fudge.notenoughcrashes.config.NecConfig;
import fudge.notenoughcrashes.utils.NecLocalization;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.crash.CrashReport;

@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -35,25 +34,25 @@ public void init() {
}

@Override
public void render(MatrixStack matrixStack, int mouseY, int i, float f) {
renderBackground(matrixStack);
drawCenteredTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.title"), width / 2, height / 4 - 40, 0xFFFFFF);
public void render(DrawContext context, int mouseX, int i, float f) {
renderBackground(context);
context.drawCenteredTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.title"), width / 2, height / 4 - 40, 0xFFFFFF);

drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.summary"), x, y, TEXT_COLOR);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph1.line1"), x, y + 18, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.summary"), x, y, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph1.line1"), x, y + 18, TEXT_COLOR);


drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line1"), x, y + 40, TEXT_COLOR);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line2"), x, y + 49, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line1"), x, y + 40, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.crashscreen.paragraph2.line2"), x, y + 49, TEXT_COLOR);

drawFileNameString(matrixStack, y + 49);
drawFileNameString(context, y + 49);

drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line1"), x, y + 72, TEXT_COLOR);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line2"), x, y + 81, TEXT_COLOR);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line3"), x, y + 90, TEXT_COLOR);
drawTextWithShadow(matrixStack, textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line4"), x, y + 99, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line1"), x, y + 72, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line2"), x, y + 81, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line3"), x, y + 90, TEXT_COLOR);
context.drawTextWithShadow(textRenderer, NecLocalization.localize("notenoughcrashes.initerrorscreen.paragraph3.line4"), x, y + 99, TEXT_COLOR);

super.render(matrixStack, mouseY, i, f);
super.render(context, mouseX, i, f);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
Expand Down Expand Up @@ -171,21 +172,21 @@ public boolean shouldCloseOnEsc() {
}


protected void drawFileNameString(MatrixStack matrixStack, int y) {
protected void drawFileNameString(DrawContext context, int y) {
String fileNameString = report.getFile() != null ? "\u00A7n" + report.getFile().getName()
: NecLocalization.localize("notenoughcrashes.crashscreen.reportSaveFailed");
int stLen = textRenderer.getWidth(fileNameString);
xLeft = width / 2 - stLen / 2;
xRight = width / 2 + stLen / 2;
drawTextWithShadow(matrixStack, textRenderer, fileNameString, xLeft, y += 11, 0x00FF00);
context.drawTextWithShadow(textRenderer, fileNameString, xLeft, y += 11, 0x00FF00);
yTop = y;
yBottom = y + 10;
}

@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) {
for (Widget widget : widgets) widget.draw(matrixStack);
super.render(matrixStack, mouseX, mouseY, delta);
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
for (Widget widget : widgets) widget.draw(context);
super.render(context, mouseX, mouseY, delta);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import net.fabricmc.api.Environment;
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.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;

import java.util.ArrayList;
Expand Down Expand Up @@ -42,8 +41,8 @@ public TextWidget(Text text, int color, TextRenderer font, int x, int y) {
}

@Override
public void draw(MatrixStack stack) {
DrawableHelper.drawCenteredTextWithShadow(stack,font, translated, x, y, color);
public void draw(DrawContext context) {
context.drawCenteredTextWithShadow(font, translated, x, y, color);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fudge.notenoughcrashes.gui.util;

import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;

public interface Widget {
void draw(MatrixStack stack);
void draw(DrawContext context);

void onClick(double clickX, double clickY);
}
8 changes: 4 additions & 4 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {

// For config modmenu integration.
modCompileOnly("com.terraformersmc:modmenu:6.2.2")
modRuntimeOnly("com.terraformersmc:modmenu:6.2.2")
// modRuntimeOnly("com.terraformersmc:modmenu:6.2.2")

// Uncomment to add the test mod at runtime
// runtimeOnly project(path: ":TestFabricMod", configuration: "namedElements")
Expand All @@ -61,17 +61,17 @@ processResources {
shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}

remapJar {
// injectAccessWidener = true
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "fabric"
archiveClassifier.set "fabric"
}
jar {
classifier "dev"
archiveClassifier.set "dev"
}

components.java {
Expand Down
6 changes: 3 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ shadowJar {
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "forge"
archiveClassifier.set "forge"
}
jar {
manifest {
attributes([
"MixinConfigs": "notenoughcrashes.mixins.json"
])
}
classifier "dev"
archiveClassifier.set "dev"
}


Expand Down
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ mod_version = "4.4.1"

# Gradle Plugins
architectury_plugin = "3.4-SNAPSHOT"
architectury_loom = "1.0-SNAPSHOT"
architectury_loom = "1.2-SNAPSHOT"
minotaur = "2.5.0"
loom_quiltflower = "1.8.0"
cursegradle = "1.4.0" # Must be updated in settings.gradle as well!
shadow = "7.1.2"
task_tree = "2.1.0"

# Minecraft
minecraft = "1.19.4"
minecraft = "1.20"

# CurseForge & Modrinth MC overrides (or "mc" to use the main version)
overrides_curseforge = "mc"
overrides_modrinth = "mc"

# Mods & Libraries
yarn_mappings = "1.19.4+build.1"
fabric_loader = "0.14.19"
fabric_api = "0.78.0+1.19.4"
yarn_mappings = "1.20+build.1"
fabric_loader = "0.14.21"
fabric_api = "0.83.0+1.20"
quilt_loader = "0.17.6"
forge = "45.0.43"
architectury_api = "8.1.79"
forge = "46.0.2"
architectury_api = "9.0.7"

[libraries]

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pluginManagement {

plugins {
id 'de.fayard.refreshVersions' version '0.51.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'
}

include("common")
Expand Down

0 comments on commit 4833bc6

Please sign in to comment.