Skip to content

Commit

Permalink
Merge pull request #2 from ENDERZOMBI102/main
Browse files Browse the repository at this point in the history
[fix] Use correct source jar path in creation of patches
  • Loading branch information
wagyourtail authored Jan 31, 2025
2 parents f872eec + 87a839f commit c0059f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ org.gradle.parallel=true

maven_group=xyz.wagyourtail.unimined
archives_base_name=patchbase
version=1.0.0
version=1.0.2
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import xyz.wagyourtail.patchbase.gradle.tasks.CreateSourcePatchTask
import xyz.wagyourtail.unimined.api.minecraft.EnvType
import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig
import xyz.wagyourtail.unimined.api.unimined
import xyz.wagyourtail.unimined.internal.minecraft.MinecraftProvider
import xyz.wagyourtail.unimined.internal.minecraft.patch.jarmod.JarModAgentMinecraftTransformer
import xyz.wagyourtail.unimined.util.withSourceSet
import kotlin.io.path.nameWithoutExtension

@Suppress("UnstableApiUsage")
abstract class PatchExtension(val project: Project) {

fun patchBaseCreator(sourceSet: SourceSet) {
Expand All @@ -27,11 +30,13 @@ abstract class PatchExtension(val project: Project) {
project.logger.warn("[PatchBase/Creator ${this.project.path} ${sourceSet}] mcPatcher is not a JarModAgentMinecraftTransformer, this may cause issues with dev runs")
}

val mcp = mc as MinecraftProvider // needed for access to `getMcDevFile()`

project.tasks.register("createSourcePatch".withSourceSet(sourceSet), CreateSourcePatchTask::class.java) {
it.group = "patchbase"
it.sourceDir.set(project.file("src/${sourceSet.name}/java"))
it.outputDir.set(project.file("patches/${sourceSet.name}"))
val sourceFile = mc.minecraftFileDev.resolveSibling(mc.minecraftFileDev.nameWithoutExtension + "-sources.jar")
val sourceFile = mc.minecraftFileDev.resolveSibling(mcp.getMcDevFile().nameWithoutExtension + "-sources.jar")
it.sources.set(project.files(sourceFile))
if (!sourceFile.exists()) {
it.dependsOn("genSources")
Expand All @@ -42,7 +47,7 @@ abstract class PatchExtension(val project: Project) {
it.group = "patchbase"
it.patchDir.set(project.file("patches/${sourceSet.name}"))
it.outputDir.set(project.file("src/${sourceSet.name}/java"))
val sourceFile = mc.minecraftFileDev.resolveSibling(mc.minecraftFileDev.nameWithoutExtension + "-sources.jar")
val sourceFile = mc.minecraftFileDev.resolveSibling(mcp.getMcDevFile().nameWithoutExtension + "-sources.jar")
it.sources.set(project.files(sourceFile))
if (!sourceFile.exists()) {
it.dependsOn("genSources".withSourceSet(sourceSet))
Expand All @@ -56,9 +61,7 @@ abstract class PatchExtension(val project: Project) {
when (mc.side) {
EnvType.CLIENT -> it.classpath.set(project.files(mc.minecraftData.minecraftClientFile))
EnvType.SERVER -> it.classpath.set(project.files(mc.minecraftData.minecraftServerFile))
EnvType.COMBINED -> {
it.classpath.set(project.files(mc.mergedOfficialMinecraftFile))
}
EnvType.COMBINED -> it.classpath.set(project.files(mc.mergedOfficialMinecraftFile))
else -> throw IllegalStateException("Unknown side: ${mc.side}")
}

Expand Down

0 comments on commit c0059f1

Please sign in to comment.