Skip to content

Commit

Permalink
1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfudge committed Aug 6, 2024
1 parent 52fef6c commit 2a9c9dc
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion TestFabricMod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ publishing {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
}
withSourcesJar()
}
2 changes: 1 addition & 1 deletion TestFabricMod/src/main/resources/nec_testmod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "io.github.natanfudge.nectest.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
"MixinMinecraftServer"
],
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ allprojects {
task publishAll {
group = "upload"
dependsOn("fabric:publishFabric")
dependsOn("forge:publishForge")
// dependsOn("forge:publishForge")
}

task addTestFabricMod(type: Copy) {
Expand All @@ -70,7 +70,7 @@ task addTestFabricMod(type: Copy) {
}

task addTestForgeMod(type: Copy) {
dependsOn project(":TestForgeMod").tasks.build
// dependsOn project(":TestForgeMod").tasks.build
// Copy dev jar because there is no support for automatic remapping
from "TestForgeMod/build/libs/nec_testmod-1.0.0-dev-shadow.jar"
into "forge/run/mods"
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ artifacts {
}

architectury {
common("fabric","forge")
common("fabric"/*,"forge"*/)
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void fillList() {
info.index = 0;
list.clear();
fillList();
}), true).texture(new Identifier(NotEnoughCrashes.MOD_ID,"icon/reset"), 12, 12).dimension(40, 20).build();
}), true).texture(Identifier.of(NotEnoughCrashes.MOD_ID,"icon/reset"), 12, 12).dimension(40, 20).build();
resetButton.setPosition(width - 205, 0);

if (info.widget instanceof Map.Entry) {
Expand Down
20 changes: 11 additions & 9 deletions common/src/main/java/fudge/notenoughcrashes/gui/ProblemScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import net.minecraft.text.*;
import net.minecraft.util.Util;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.ReportType;

import java.io.File;
import java.nio.file.Path;
import java.util.*;

@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -92,7 +94,7 @@ private void addSuspectedModsWidget() {
private void handleLegacyLinkClick(ButtonWidget buttonWidget) {
try {
if (uploadedCrashLink == null) {
uploadedCrashLink = LegacyCrashLogUpload.upload(report.asString());
uploadedCrashLink = LegacyCrashLogUpload.upload(report. asString(ReportType.MINECRAFT_CRASH_REPORT));
}
Util.getOperatingSystem().open(uploadedCrashLink);
} catch (Throwable e) {
Expand All @@ -110,7 +112,7 @@ private void handleCrashyUploadClick(ButtonWidget buttonWidget) {
if (crashyLink == null) {
buttonWidget.active = false;
buttonWidget.setMessage(uploadToCrashyLoadingText);
CrashyUpload.uploadToCrashy(report.asString()).thenAccept(link -> {
CrashyUpload.uploadToCrashy(report.asString(ReportType.MINECRAFT_CRASH_REPORT)).thenAccept(link -> {
crashyLink = link;
buttonWidget.active = true;
buttonWidget.setMessage(uploadToCrashyText);
Expand Down Expand Up @@ -140,11 +142,11 @@ public void init() {
.build()
);

addDrawableChild(
ButtonWidget.builder(uploadToCrashyText,this::handleCrashyUploadClick)
.dimensions(width / 2 - 155 + 160, height / 4 + 120 + 12, 150, 20)
.build()
);
// addDrawableChild(
// ButtonWidget.builder(uploadToCrashyText,this::handleCrashyUploadClick)
// .dimensions(width / 2 - 155 + 160, height / 4 + 120 + 12, 150, 20)
// .build()
// );


x = width / 2 - 155;
Expand All @@ -156,7 +158,7 @@ public void init() {
public boolean mouseClicked(double x, double y, int int_1) {
for (Widget widget : widgets) widget.onClick(x, y);
if (x >= xLeft && x <= xRight && y >= yTop && y <= yBottom) {
File file = report.getFile();
Path file = report.getFile();
if (file != null) {
Util.getOperatingSystem().open(file);
}
Expand All @@ -171,7 +173,7 @@ public boolean shouldCloseOnEsc() {


protected void drawFileNameString(DrawContext context, int y) {
String fileNameString = report.getFile() != null ? "\u00A7n" + report.getFile().getName()
String fileNameString = report.getFile() != null ? "\u00A7n" + report.getFile().getFileName()
: NecLocalization.localize("notenoughcrashes.crashscreen.reportSaveFailed");
int stLen = textRenderer.getWidth(fileNameString);
xLeft = width / 2 - stLen / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void addInfoToCrash(CrashReport report) {
report.getSystemDetailsSection().addSection("Integrated Server Crashes Since Restart", () -> String.valueOf(serverCrashCount));
}

private static void displayCrashScreen(CrashReport report, int crashCount, boolean clientCrash) {
public static void displayCrashScreen(CrashReport report, int crashCount, boolean clientCrash) {
crashScreenActive = true;
try {
if (EntryPointCatcher.crashedDuringStartup()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private CrashReport getThis() {
/**
* @reason Adds a list of mods which may have caused the crash to the report.
*/
@Inject(method = "addStackTrace", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/SystemDetails;writeTo(Ljava/lang/StringBuilder;)V"))
@Inject(method = "addDetails", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/SystemDetails;writeTo(Ljava/lang/StringBuilder;)V"))
private void beforeSystemDetailsAreWritten(CallbackInfo ci) {
systemDetailsSection.addSection("Suspected Mods", () -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import fudge.notenoughcrashes.StateManager;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BuiltBuffer;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.util.BufferAllocator;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -13,10 +16,10 @@ public abstract class MixinBufferBuilder implements StateManager.IResettable {

@Shadow private boolean building;

@Shadow public abstract BufferBuilder.BuiltBuffer end();
@Shadow public abstract BuiltBuffer end();

@Inject(method = "<init>", at = @At("RETURN"))
public void onInit(int bufferSizeIn, CallbackInfo ci) {
public void onInit(BufferAllocator allocator, VertexFormat.DrawMode drawMode, VertexFormat format, CallbackInfo ci) {
register();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import fudge.notenoughcrashes.NotEnoughCrashes;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.ReportType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.io.File;
import java.nio.file.Path;

/**
* Only applied to client side because we aim to change the functionality of the integrated server (and not the dedicated one)
Expand All @@ -18,9 +20,9 @@ public class MixinMinecraftServerClientOnly {
* We write the log anyway using CrashUtils.outputReport in
* {@link fudge.notenoughcrashes.mixinhandlers.InGameCatcher#displayCrashScreen(CrashReport, int, boolean)}
*/
@Redirect(method = "runServer()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;writeToFile(Ljava/io/File;)Z"))
private boolean disableIntegratedServerWriteToFileOnCrash(CrashReport instance, File file) {
@Redirect(method = "runServer()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;writeToFile(Ljava/nio/file/Path;Lnet/minecraft/util/crash/ReportType;)Z"))
private boolean disableIntegratedServerWriteToFileOnCrash(CrashReport instance, Path path, ReportType type) {
if (NotEnoughCrashes.enableGameloopCatching()) return true;
else return instance.writeToFile(file);
else return instance.writeToFile(path, type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.ReportType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;

Expand Down Expand Up @@ -37,17 +39,17 @@ public static void outputReport(CrashReport report, boolean isClient) {
reportName += isClient && MinecraftClient.getInstance().isOnThread() ? "-client" : "-server";
reportName += ".txt";

File reportsDir = new File(NecPlatform.instance().getGameDirectory().toFile(), "crash-reports");
File reportFile = new File(reportsDir, reportName);
Path reportsDir = NecPlatform.instance().getGameDirectory().resolve("crash-reports");
Path reportFile = reportsDir.resolve(reportName);

report.writeToFile(reportFile);
report.writeToFile(reportFile, ReportType.MINECRAFT_CRASH_REPORT);
}
} catch (Throwable e) {
NotEnoughCrashes.getLogger().fatal("Failed saving report", e);
}

NotEnoughCrashes.getLogger().fatal("Minecraft ran into a problem! " + (report.getFile() != null ? "Report saved to: " + report.getFile() :
"Crash report could not be saved.") + "\n" +
report.asString());
report.asString(ReportType.MINECRAFT_CRASH_REPORT));
}
}
2 changes: 1 addition & 1 deletion common/src/main/resources/notenoughcrashes.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"package": "fudge.notenoughcrashes.mixins",
"required": true,
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"minVersion": "0.8",
"mixins": [
"MixinCrashReport",
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ shadow = "8.1.1"
task_tree = "4.0.0"

# Minecraft
minecraft = "1.20.6"
minecraft = "1.21"

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

# Mods & Libraries
yarn_mappings = "1.20.6+build.1"
fabric_loader = "0.15.11"
fabric_api = "0.100.0+1.20.6"
modmenu = "10.0.0-beta.1"
yarn_mappings = "1.21+build.9"
fabric_loader = "0.16.0"
fabric_api = "0.101.2+1.21"
modmenu = "11.0.1"

quilt_loader = "0.26.0"
forge = "50.1.0"
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ plugins {

include("common")
include("fabric")
include("forge")
//include("forge")
include("TestFabricMod")
include("TestForgeMod")
//include("TestForgeMod")

rootProject.name = "notenoughcrashes"

0 comments on commit 2a9c9dc

Please sign in to comment.