-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly shade lwjgl & forge fixes
- Loading branch information
Showing
9 changed files
with
177 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
modules/core/src/main/kotlin/org/polyfrost/spice/patcher/lwjgl/MemoryStackTransformer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.polyfrost.spice.patcher.lwjgl | ||
|
||
import net.weavemc.loader.api.util.asm | ||
import org.objectweb.asm.Opcodes.ARETURN | ||
import org.objectweb.asm.tree.ClassNode | ||
import org.objectweb.asm.tree.MethodNode | ||
import org.polyfrost.spice.platform.api.IClassTransformer | ||
|
||
object MemoryStackTransformer : IClassTransformer { | ||
override val targets = arrayOf("org.lwjgl.system.MemoryStack") | ||
|
||
override fun transform(node: ClassNode) { | ||
val method = node.methods.find { method -> | ||
method as MethodNode | ||
method.name == "create" && method.desc == "(Ljava/nio/ByteBuffer;)Lorg/lwjgl/system/MemoryStack;" | ||
}!! as MethodNode | ||
|
||
method | ||
.instructions | ||
.insertBefore( | ||
method | ||
.instructions | ||
.toArray() | ||
.find { insn -> insn.opcode == ARETURN }, | ||
asm { checkcast("org/lwjgl/system/MemoryStack") } | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,5 @@ tasks.jar { | |
} | ||
|
||
tasks.shadowJar { | ||
archiveFileName = "lwjgl.jar" | ||
archiveFileName = "lwjgl-bundle" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/util/Relaunch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.polyfrost.spice.platform.impl.forge.util | ||
|
||
import java.lang.management.ManagementFactory | ||
import kotlin.io.path.Path | ||
|
||
fun relaunch() { | ||
val runtimeBean = ManagementFactory.getRuntimeMXBean() | ||
val binary = Path(System.getProperty("sun.boot.library.path")).resolve("java.exe") | ||
|
||
val builder = ProcessBuilder() | ||
.command( | ||
binary.toAbsolutePath().toString(), | ||
*runtimeBean.inputArguments.toTypedArray(), | ||
"-cp", | ||
runtimeBean.classPath, | ||
*System.getProperty("sun.java.command").split(" ").toTypedArray() | ||
) | ||
|
||
println("Starting process: ${builder.command().joinToString(" ")}") | ||
|
||
val process = | ||
builder | ||
.inheritIO() | ||
.start() | ||
|
||
Runtime.getRuntime().addShutdownHook(Thread(process::destroy)) | ||
Runtime.getRuntime().halt(process.waitFor()) | ||
} |