From 3cbac14dc2b80fa415191b72f149e50f5a7ad7d5 Mon Sep 17 00:00:00 2001 From: MartinSVK12 <37455793+MartinSVK12@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:28:37 +0100 Subject: [PATCH] Fixed default entrypoints not being called. --- .../impl/game/minecraft/patch/EntrypointPatch.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/patch/EntrypointPatch.java b/minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/patch/EntrypointPatch.java index 72083ac71..3cf7b8ed8 100644 --- a/minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/patch/EntrypointPatch.java +++ b/minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/patch/EntrypointPatch.java @@ -16,10 +16,14 @@ package net.fabricmc.loader.impl.game.minecraft.patch; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.ListIterator; +import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; +import java.util.stream.Collectors; import net.fabricmc.loader.impl.game.minecraft.applet.AppletLauncher; @@ -460,12 +464,13 @@ public void process(FabricLauncher launcher, Function classSo moveAfter(it, Opcodes.INVOKESPECIAL); /* Object.init */ it.add(new FieldInsnNode(Opcodes.GETSTATIC, gameClass.name, runDirectory.name, runDirectory.desc)); it.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/fabricmc/loader/impl/game/minecraft/applet/AppletMain", "hookGameDir", "(Ljava/io/File;)Ljava/io/File;", false)); - it.add(new FieldInsnNode(Opcodes.PUTSTATIC, gameClass.name, runDirectory.name, runDirectory.desc)); + FieldInsnNode node = new FieldInsnNode(Opcodes.PUTSTATIC, gameClass.name, runDirectory.name, runDirectory.desc); + it.add(node); it = gameMethod.instructions.iterator(); if (gameConstructor == gameMethod) { - moveBefore(it, Opcodes.RETURN); + moveBefore(it,Opcodes.IFEQ); } it.add(new FieldInsnNode(Opcodes.GETSTATIC, gameClass.name, runDirectory.name, runDirectory.desc)); @@ -532,7 +537,7 @@ public void process(FabricLauncher launcher, Function classSo classEmitter.accept(mainClass); } - if (isApplet) { + if (isApplet || isDirect) { Hooks.appletMainClass = entrypoint; } }