Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mod patching gradle plugin #163

Merged
merged 8 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ insert_final_newline = true
[*.patch]
trim_trailing_whitespace = false
insert_final_newline = false

[*.java]
indent_size = 3
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ jobs:
with:
java-version: 8

- uses: eskatos/gradle-command-action@v1
- name: prepare patching environment
uses: eskatos/gradle-command-action@v1
with:
arguments: prepareMods
arguments: preparePatchingEnvironment

# Runs a single command using the runners shell
- name: apply patches
run: ./apply_patch.sh
run: ./pm.apply-patches

- uses: eskatos/gradle-command-action@v1
- name: setup workspace
uses: eskatos/gradle-command-action@v1
with:
arguments: setupCiWorkspace

- uses: eskatos/gradle-command-action@v1
- name: build
uses: eskatos/gradle-command-action@v1
with:
arguments: build
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_NAME_IN: ${{ github.event.inputs.version_name }}

- name: prepare mods
- name: prepare patching environment
uses: eskatos/gradle-command-action@v1
with:
arguments: prepareMods
arguments: preparePatchingEnvironment

- name: apply patches
run: ./apply_patch.sh
run: ./pm.apply-patches

- name: setup workspace
uses: eskatos/gradle-command-action@v1
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Build
uses: eskatos/gradle-command-action@v1
with:
arguments: makeFixrtmJar
arguments: build

- name: push releases
id: publish_releases
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,7 @@ gradle-app.setting
/src/main/rtm
/src/main/ngtlibResources
/src/main/rtmResources

/pm.*
/src/main/ngtlib-1
/src/main/rtm-1
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added .patching-mods/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions .patching-mods/ngtlib.patching-mod/modified-classes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
jp.ngt.ngtlib.NGTCore
jp.ngt.ngtlib.io.NGTLog
jp.ngt.ngtlib.item.craft.RecipeManager
jp.ngt.ngtlib.item.craft.ShapedRecipes55
jp.ngt.ngtlib.renderer.model.ModelLoader
jp.ngt.ngtlib.renderer.model.ObjModel
jp.ngt.ngtlib.renderer.model.PolygonModel
jp.ngt.ngtlib.util.PermissionManager
1 change: 1 addition & 0 deletions .patching-mods/ngtlib.patching-mod/on-vcs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PATCHES
40 changes: 40 additions & 0 deletions .patching-mods/rtm.patching-mod/modified-classes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
jp.ngt.rtm.RTMItem
jp.ngt.rtm.RTMRecipe
jp.ngt.rtm.block.tileentity.TileEntityMachineBase
jp.ngt.rtm.block.tileentity.TileEntityMechanism
jp.ngt.rtm.block.tileentity.TileEntityOrnament
jp.ngt.rtm.electric.TileEntityConnectorBase
jp.ngt.rtm.electric.TileEntitySignal
jp.ngt.rtm.entity.ai.EntityAITravelByTrain
jp.ngt.rtm.entity.npc.EntityNPC
jp.ngt.rtm.entity.train.EntityBogie
jp.ngt.rtm.entity.train.EntityTrainBase
jp.ngt.rtm.entity.train.parts.EntityCargoWithModel
jp.ngt.rtm.entity.vehicle.EntityTrolley
jp.ngt.rtm.entity.vehicle.EntityVehicleBase
jp.ngt.rtm.entity.vehicle.RenderVehicleBase
jp.ngt.rtm.entity.vehicle.VehicleTrackerEntry
jp.ngt.rtm.entity.vehicle.WeatherEffectDummy
jp.ngt.rtm.event.RTMEventHandler
jp.ngt.rtm.item.ItemPaintTool
jp.ngt.rtm.modelpack.ModelPackManager
jp.ngt.rtm.modelpack.cfg.ResourceConfig
jp.ngt.rtm.modelpack.init.ModelPackConstructThread
jp.ngt.rtm.modelpack.init.ModelPackLoadThread
jp.ngt.rtm.modelpack.modelset.ModelSetBase
jp.ngt.rtm.modelpack.modelset.ModelSetNPC
jp.ngt.rtm.modelpack.modelset.ModelSetSignal
jp.ngt.rtm.modelpack.modelset.ModelSetTrain
jp.ngt.rtm.modelpack.modelset.ModelSetVehicleBase
jp.ngt.rtm.modelpack.modelset.ResourceSet
jp.ngt.rtm.modelpack.state.ResourceState
jp.ngt.rtm.rail.BlockLargeRailBase
jp.ngt.rtm.rail.BlockMarker
jp.ngt.rtm.rail.RenderMarkerBlock
jp.ngt.rtm.rail.util.RailMaker
jp.ngt.rtm.rail.util.SwitchType
jp.ngt.rtm.render.ModelObject
jp.ngt.rtm.render.PartsRenderer
jp.ngt.rtm.render.RTMRenderers
jp.ngt.rtm.sound.MovingSoundMaker
jp.ngt.rtm.world.RTMChunkManager
1 change: 1 addition & 0 deletions .patching-mods/rtm.patching-mod/on-vcs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PATCHES
50 changes: 39 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
kotlin("jvm") version "1.4.20"
id("com.anatawa12.jasm")
id("net.minecraftforge.gradle.forge")
id("com.anatawa12.mod-patching")
id("com.matthewprenger.cursegradle") version "1.4.0"
}

Expand Down Expand Up @@ -68,26 +69,26 @@ dependencies {
shade("com.anatawa12.sai:sai:0.0.2")

compileOnly(files(file("run/fixrtm-cache/script-compiled-class")))
compileOnly(files(sourceSets.main.get().jasm.outputDir))
compileOnly(files(projectDir.resolve("mods/rtm.deobf.jar"),
projectDir.resolve("mods/ngtlib.deobf.jar")))
// compileOnly(files(sourceSets.main.get().jasm.outputDir))
// compileOnly(files(projectDir.resolve("mods/rtm.deobf.jar"),
// projectDir.resolve("mods/ngtlib.deobf.jar")))

// https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core
apiCompile("org.twitter4j:twitter4j-core:4.0.7")
apiImplementation("org.twitter4j:twitter4j-core:4.0.7")
// https://mvnrepository.com/artifact/com.github.sarxos/webcam-capture
apiCompile("com.github.sarxos:webcam-capture:0.3.12")
apiImplementation("com.github.sarxos:webcam-capture:0.3.12")

// https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core
compile("org.twitter4j:twitter4j-core:4.0.7")
implementation("org.twitter4j:twitter4j-core:4.0.7")
// https://mvnrepository.com/artifact/com.github.sarxos/webcam-capture
compile("com.github.sarxos:webcam-capture:0.3.12")
implementation("com.github.sarxos:webcam-capture:0.3.12")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.1")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.7.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.1")
}

val processResources by tasks.getting(Copy::class) {
fun Copy.configure() {
// this will ensure that this task is redone when the versions change.
inputs.property("version", project.version)
inputs.property("mcversion", project.minecraft.version)
Expand All @@ -109,15 +110,23 @@ val processResources by tasks.getting(Copy::class) {
}
}

val processResources by tasks.getting(Copy::class) {
configure()
}
val reprocessResources by tasks.getting(Copy::class) {
configure()
}

val runClient by tasks.getting(JavaExec::class) {
environment("fml.coreMods.load", "com.anatawa12.fixRtm.asm.FixRtmCorePlugin")
/*
systemProperties["legacy.debugClassLoading"] = "true"
/*
systemProperties["legacy.debugClassLoadingSave"] = "true"
// */
//*
if (!project.hasProperty("noLogin") && project.hasProperty("minecraft.login.username") && project.hasProperty("minecraft.login.password"))
args = args.orEmpty() + listOf(
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
args = args!! + listOf(
"-username", project.property("minecraft.login.username").toString(),
"-password", project.property("minecraft.login.password").toString()
)
Expand Down Expand Up @@ -151,6 +160,7 @@ val generateJavaStab by tasks.creating(GenerateJavaStab::class) {
}

tasks.compileKotlin {
dependsOn(tasks.generateUnmodifieds.get())
dependsOn(generateJavaStab)
source(generateJavaStab.generatedDir!!)
include("**/*.java")
Expand Down Expand Up @@ -181,8 +191,26 @@ tasks.test {

runClient.outputs.upToDateWhen { false }

@Suppress("SpellCheckingInspection")
val rtm = mods.curse(id = "realtrainmod", version = "2.4.21") {
name = "rtm"
targetVersions("1.12.2")
}

@Suppress("SpellCheckingInspection")
val ngtlib = mods.curse(id = "ngtlib", version = "2.4.18") {
name = "ngtlib"
targetVersions("1.12.2")
}

patching {
patch(rtm)
patch(ngtlib)
bsdiffPrefix = "com/anatawa12/fixRtm/asm/patches"
sourceNameSuffix = "(modified by fixrtm)"
}

apply(from = "./processMods.gradle")
apply(from = "./makePatch.gradle")

curseforge {
apiKey = project.findProperty("com.anatawa12.curse.api-key").toString()
Expand Down
Loading