Skip to content

Commit eaf6ba7

Browse files
committed
Improve datagen mixin to not hang if something fails
1 parent ec8d702 commit eaf6ba7

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Forge/src/main/java/gay/object/hexdebug/forge/mixin/ForgeHexDebugMixinConfigPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
2323
if (mixinClassName.equals("gay.object.hexdebug.forge.mixin.MixinDatagenMain")) {
2424
var shouldApply = System.getProperty("hexdebug.apply-datagen-mixin", "false").equals("true");
2525
if (shouldApply) {
26-
HexDebug.LOGGER.error("Applying scuffed datagen mixin. This should not happen if not running datagen!");
26+
HexDebug.LOGGER.warn("Applying scuffed datagen mixin. This should not happen if not running datagen!");
2727
}
2828
return shouldApply;
2929
}
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package gay.object.hexdebug.forge.mixin;
22

3+
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
35
import gay.object.hexdebug.HexDebug;
46
import org.spongepowered.asm.mixin.Mixin;
57
import org.spongepowered.asm.mixin.injection.At;
@@ -9,9 +11,15 @@
911
// scuffed workaround for https://github.com/architectury/architectury-loom/issues/189
1012
@Mixin(net.minecraft.data.Main.class)
1113
public class MixinDatagenMain {
12-
@Inject(method = "main", at = @At("TAIL"), remap = false)
13-
private static void hexdebug$systemExitAfterDatagenFinishes(String[] strings, CallbackInfo ci) {
14-
HexDebug.LOGGER.info("Terminating datagen.");
14+
@WrapMethod(method = "main", remap = false)
15+
private static void hexdummyexample$systemExitAfterDatagenFinishes(String[] strings, Operation<Void> original) {
16+
try {
17+
original.call((Object) strings);
18+
} catch (Throwable throwable) {
19+
HexDebug.LOGGER.error("Datagen failed!", throwable);
20+
System.exit(1);
21+
}
22+
HexDebug.LOGGER.info("Datagen succeeded, terminating.");
1523
System.exit(0);
1624
}
1725
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ patchouli-forge = "1.20.1-84-FORGE"
3333

3434
cardinalComponents = "5.2.1"
3535
serializationHooks = "0.4.99999"
36-
mixinExtras = "0.3.6"
36+
mixinExtras = "0.5.0"
3737
trinkets = "3.7.0"
3838
clothConfig = "11.1.106"
3939
modMenu = "7.1.0"

0 commit comments

Comments
 (0)