1
1
package xyz.wagyourtail.patchbase.gradle
2
2
3
3
import org.gradle.api.Project
4
+ import org.gradle.api.artifacts.component.ModuleComponentIdentifier
4
5
import xyz.wagyourtail.patchbase.installer.PatchbaseInstaller
5
6
import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig
7
+ import xyz.wagyourtail.unimined.api.minecraft.MinecraftJar
6
8
import xyz.wagyourtail.unimined.internal.minecraft.MinecraftProvider
7
- import xyz.wagyourtail.unimined.internal.minecraft.patch.MinecraftJar
8
9
import xyz.wagyourtail.unimined.internal.minecraft.patch.jarmod.JarModAgentMinecraftTransformer
9
- import xyz.wagyourtail.unimined.internal.minecraft.patch.jarmod.JarModMinecraftTransformer
10
10
import xyz.wagyourtail.unimined.util.withSourceSet
11
11
12
+
12
13
fun MinecraftConfig.patchBase (action : PatchBaseMinecraftTransformer .() -> Unit = {}) {
13
14
customPatcher(PatchBaseMinecraftTransformer (this .project, this as MinecraftProvider ), action)
14
15
}
@@ -18,14 +19,17 @@ class PatchBaseMinecraftTransformer(project: Project, provider: MinecraftProvide
18
19
19
20
override fun transform (minecraft : MinecraftJar ): MinecraftJar {
20
21
val patchDep = patchBase.dependencies.last()
21
- val patchJar = patchBase.files(patchDep).first { it.extension == " jar" || it.extension == " zip" }
22
- val outputFolder = minecraft.path.parent.resolve(patchDep.name).resolve(patchDep.version)
23
-
24
- val patchedMC = MinecraftJar (
25
- minecraft,
26
- parentPath = outputFolder,
27
- patches = minecraft.patches + " patchbase"
28
- )
22
+ val patchJar = patchBase
23
+ .incoming
24
+ .artifactView { view -> view.componentFilter { it is ModuleComponentIdentifier && it.group == patchDep.group && it.version == patchDep.version && it.module == patchDep.name } }
25
+ .files
26
+ .first { it.extension == " jar" || it.extension == " zip" }
27
+ val outputFolder = minecraft.path
28
+ .parent
29
+ .resolve(patchDep.name)
30
+ .resolve(patchDep.version!! )
31
+
32
+ val patchedMC = MinecraftJar (minecraft, outputFolder, patches = minecraft.patches + " patchbase" )
29
33
30
34
PatchbaseInstaller ().patch(patchJar.toPath(), minecraft.path, patchedMC.path)
31
35
0 commit comments