-
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.
base implementation of forge transformers
split platform from transformer stuff
- Loading branch information
Showing
18 changed files
with
222 additions
and
120 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
22 changes: 22 additions & 0 deletions
22
modules/core/src/main/kotlin/wtf/zani/spice/patcher/lwjgl/LibraryTransformer.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,22 @@ | ||
package wtf.zani.spice.patcher.lwjgl | ||
|
||
import org.objectweb.asm.tree.ClassNode | ||
import org.objectweb.asm.tree.LdcInsnNode | ||
import org.objectweb.asm.tree.MethodNode | ||
import wtf.zani.spice.platform.api.IClassTransformer | ||
|
||
object LibraryTransformer : IClassTransformer { | ||
override fun getClassNames(): Array<String> { | ||
return arrayOf("org.lwjgl.system.Library") | ||
} | ||
|
||
override fun transform(node: ClassNode) { | ||
node.methods.forEach { method -> | ||
(method as MethodNode).instructions | ||
.iterator() | ||
.asSequence() | ||
.filter { it is LdcInsnNode && it.cst is String && it.cst == "java.library.path" } | ||
.forEach { (it as LdcInsnNode).cst = "spice.library.path" } | ||
} | ||
} | ||
} |
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
6 changes: 0 additions & 6 deletions
6
modules/core/src/main/kotlin/wtf/zani/spice/platform/Bootstrap.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 |
---|---|---|
@@ -1,14 +1,8 @@ | ||
package wtf.zani.spice.platform | ||
|
||
import wtf.zani.spice.Spice | ||
import wtf.zani.spice.patcher.LwjglTransformer | ||
import wtf.zani.spice.platform.api.Platform | ||
|
||
fun bootstrapTransformer(platform: Platform) { | ||
platform.addTransformer(LwjglTransformer) | ||
platform.appendToClassPath(LwjglTransformer.provider.url) | ||
} | ||
|
||
fun bootstrap(platform: Platform) { | ||
Spice.initialize(platform) | ||
} |
11 changes: 11 additions & 0 deletions
11
modules/core/src/main/kotlin/wtf/zani/spice/platform/TransformerBootstrap.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,11 @@ | ||
package wtf.zani.spice.platform | ||
|
||
import wtf.zani.spice.patcher.lwjgl.LibraryTransformer | ||
import wtf.zani.spice.patcher.lwjgl.LwjglTransformer | ||
import wtf.zani.spice.platform.api.Transformer | ||
|
||
fun bootstrapTransformer(transformer: Transformer) { | ||
transformer.addTransformer(LwjglTransformer) | ||
transformer.appendToClassPath(LwjglTransformer.provider.url) | ||
transformer.addTransformer(LibraryTransformer) | ||
} |
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
5 changes: 0 additions & 5 deletions
5
modules/core/src/main/kotlin/wtf/zani/spice/platform/api/Platform.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
9 changes: 9 additions & 0 deletions
9
modules/core/src/main/kotlin/wtf/zani/spice/platform/api/Transformer.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,9 @@ | ||
package wtf.zani.spice.platform.api | ||
|
||
import java.net.URL | ||
|
||
interface Transformer { | ||
fun addTransformer(transformer: IClassTransformer) | ||
|
||
fun appendToClassPath(url: URL) | ||
} |
18 changes: 2 additions & 16 deletions
18
versions/1.8.9-fabric/src/main/kotlin/wtf/zani/spice/platform/impl/fabric/FabricPlatform.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 |
---|---|---|
@@ -1,29 +1,15 @@ | ||
package wtf.zani.spice.platform.impl.fabric | ||
|
||
import wtf.zani.spice.platform.api.IClassTransformer | ||
import wtf.zani.spice.platform.api.Platform | ||
import java.lang.reflect.Method | ||
import java.net.URL | ||
|
||
class FabricPlatform(private val loader: ClassLoader, private val addUrl: Method) : Platform { | ||
class FabricPlatform : Platform { | ||
init { | ||
instance = this | ||
} | ||
|
||
override val id = Platform.ID.Fabric | ||
internal val transformers = mutableListOf<IClassTransformer>() | ||
|
||
override fun addTransformer(transformer: IClassTransformer) { | ||
transformers += transformer | ||
} | ||
|
||
override fun appendToClassPath(url: URL) { | ||
println("appending $url to the classpath") | ||
|
||
addUrl(loader, url) | ||
} | ||
|
||
companion object { | ||
lateinit var instance: FabricPlatform | ||
var instance: FabricPlatform = FabricPlatform() | ||
} | ||
} |
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
Oops, something went wrong.