Skip to content

Commit

Permalink
yeah no nevermind "finished" was a lie
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Dec 11, 2024
1 parent e79bae9 commit 4babfbb
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 9 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ dependencies {
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
if (mcData.isLegacyForge) {
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
} else if (mcData.isFabric) {
modImplementation("net.fabricmc:fabric-language-kotlin:${mcData.dependencies.fabric.fabricLanguageKotlinVersion}")
}
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pluginManagement {

plugins {
kotlin("jvm") version("2.0.0")
id("dev.deftu.gradle.multiversion-root") version("2.12.0")
id("dev.deftu.gradle.multiversion-root") version("2.12.2")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.polyfrost.crashpatch.hooks.CrashReportHook;
import org.polyfrost.crashpatch.hooks.StacktraceDeobfuscator;
import net.minecraft.crash.CrashReport;
import net.minecraftforge.fml.common.ModContainer;
import org.polyfrost.crashpatch.identifier.ModMetadata;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ private void drawWarningText(int mouseX, int mouseY, float partialTicks, Callbac
}

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
//#if FORGE
throws IOException
//#endif
{
super.mouseClicked(mouseX, mouseY, mouseButton);
if (((MinecraftHook) Minecraft.getMinecraft()).hasRecoveredFromCrash()) {
if (mouseButton == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.polyfrost.crashpatch.mixin;

//#if FORGE
import org.polyfrost.crashpatch.CrashPatch;
import org.polyfrost.universal.UDesktop;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -93,3 +94,4 @@ private void onDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackIn
}

}
//#endif
11 changes: 9 additions & 2 deletions src/main/java/org/polyfrost/crashpatch/mixin/MixinMinecraft.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.polyfrost.crashpatch.mixin;

//#if FORGE
import net.minecraftforge.fml.client.SplashProgress;
import net.minecraftforge.fml.common.FMLCommonHandler;
//#endif

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.FontRenderer;
Expand All @@ -23,8 +28,6 @@
import net.minecraft.util.MinecraftError;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.SplashProgress;
import net.minecraftforge.fml.common.FMLCommonHandler;
import org.apache.logging.log4j.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Mouse;
Expand Down Expand Up @@ -328,8 +331,10 @@ private void onGUIDisplay(GuiScreen i, CallbackInfo ci) {

this.running = true;
try {
//#if FORGE
//noinspection deprecation
SplashProgress.pause();// Disable the forge splash progress screen
//#endif
GlStateManager.disableTexture2D();
GlStateManager.enableTexture2D();
} catch (Throwable ignored) {
Expand Down Expand Up @@ -403,12 +408,14 @@ private void onGUIDisplay(GuiScreen i, CallbackInfo ci) {
}
}

//#if FORGE
@Redirect(method = "displayCrashReport", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;handleExit(I)V"))
public void redirect(FMLCommonHandler instance, int code) {
if (crashpatch$letDie) {
instance.handleExit(code);
}
}
//#endif

@Unique
private void crashpatch$resetState() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/polyfrost/crashpatch/CrashPatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object CrashPatch
}

fun initialize() {
CommandManager.registerCommand(CrashPatchCommand)
CommandManager.registerCommand(CrashPatchCommand())
CrashPatchConfig // Initialize the config
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.polyfrost.universal.ChatColor
import org.polyfrost.universal.UMinecraft

@Command(CrashPatch.ID)
object CrashPatchCommand {
class CrashPatchCommand {

@Command
fun main() {
Expand Down
60 changes: 60 additions & 0 deletions src/main/kotlin/org/polyfrost/crashpatch/mixins/MixinPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.polyfrost.crashpatch.mixins

//#if MC >= 1.16.5 || FABRIC
//$$ import org.objectweb.asm.tree.ClassNode
//#endif

import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin
import org.spongepowered.asm.mixin.extensibility.IMixinInfo

class MixinPlugin : IMixinConfigPlugin {

override fun getMixins(): MutableList<String> {
val result = mutableListOf<String>()

//#if FORGE
result.add("MixinGuiDupesFound")
result.add("MixinTileEntityRendererDispatcher")
//#endif

return result
}

override fun getRefMapperConfig(): String? = null
override fun shouldApplyMixin(targetClassName: String, mixinClassName: String): Boolean = true

override fun onLoad(mixinPackage: String) {
// no-op
}

override fun acceptTargets(myTargets: MutableSet<String>, otherTargets: MutableSet<String>) {
// no-op
}

override fun preApply(
targetClassName: String,
//#if MC >= 1.16.5 || FABRIC
//$$ targetClass: ClassNode,
//#else
targetClass: org.spongepowered.asm.lib.tree.ClassNode,
//#endif
mixinClassName: String,
mixinInfo: IMixinInfo
) {
// no-op
}

override fun postApply(
targetClassName: String,
//#if MC >= 1.16.5 || FABRIC
//$$ targetClass: ClassNode,
//#else
targetClass: org.spongepowered.asm.lib.tree.ClassNode,
//#endif
mixinClassName: String,
mixinInfo: IMixinInfo
) {
// no-op
}

}
31 changes: 31 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"schemaVersion": 1,
"id": "${mod_id}",
"version": "${mod_version}",
"name": "${mod_name}",
"authors": [
"Polyfrost",
"SkyClient"
],
"contact": {
"issues": "https://github.com/Polyfrost/${mod_name}/issues",
"sources": "https://github.com/Polyfrost/${mod_name}"
},
"license": "GPL-3.0-or-later",
"environment": "*",
"entrypoints": {
"client": [
{
"adapter": "kotlin",
"value": "org.polyfrost.crashpatch.CrashPatch"
}
]
},
"mixins": [
"mixins.${mod_id}.json"
],
"depends": {
"fabricloader": ">=0.15.11",
"fabric-language-kotlin": "*"
}
}
3 changes: 1 addition & 2 deletions src/main/resources/mixins.crashpatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compatibilityLevel": "JAVA_8",
"minVersion": "0.7",
"package": "org.polyfrost.crashpatch.mixin",
"plugin": "org.polyfrost.crashpatch.mixins.MixinPlugin",
"refmap": "mixin.crashpatch.refmap.json",
"injectors": {
"maxShiftBy": 5
Expand All @@ -11,9 +12,7 @@
"MixinCrashReport",
"MixinCrashReportCategory",
"MixinGuiConnecting",
"MixinGuiDupesFound",
"MixinMinecraft",
"MixinTileEntityRendererDispatcher",
"MixinWorldRenderer"
],
"verbose": true
Expand Down

0 comments on commit 4babfbb

Please sign in to comment.