From 290ba856d7d21f5eb3053e538d992cc4bc10f45e Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 2 Mar 2021 18:15:47 +0900 Subject: [PATCH 1/8] initial commit for mod-patching --- .gitignore | 4 +++ .patching-mods/.gitkeep | 0 .../ngtlib.patching-mod/modified-classes.txt | 0 .patching-mods/ngtlib.patching-mod/on-vcs.txt | 1 + .../rtm.patching-mod/modified-classes.txt | 0 .patching-mods/rtm.patching-mod/on-vcs.txt | 1 + build.gradle.kts | 35 ++++++++++++++++--- processMods.gradle | 4 +-- settings.gradle.kts | 6 ++++ 9 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 .patching-mods/.gitkeep create mode 100644 .patching-mods/ngtlib.patching-mod/modified-classes.txt create mode 100644 .patching-mods/ngtlib.patching-mod/on-vcs.txt create mode 100644 .patching-mods/rtm.patching-mod/modified-classes.txt create mode 100644 .patching-mods/rtm.patching-mod/on-vcs.txt diff --git a/.gitignore b/.gitignore index 4c585679..59a79972 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.patching-mods/.gitkeep b/.patching-mods/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/.patching-mods/ngtlib.patching-mod/modified-classes.txt b/.patching-mods/ngtlib.patching-mod/modified-classes.txt new file mode 100644 index 00000000..e69de29b diff --git a/.patching-mods/ngtlib.patching-mod/on-vcs.txt b/.patching-mods/ngtlib.patching-mod/on-vcs.txt new file mode 100644 index 00000000..c77e2a4e --- /dev/null +++ b/.patching-mods/ngtlib.patching-mod/on-vcs.txt @@ -0,0 +1 @@ +PATCHES \ No newline at end of file diff --git a/.patching-mods/rtm.patching-mod/modified-classes.txt b/.patching-mods/rtm.patching-mod/modified-classes.txt new file mode 100644 index 00000000..e69de29b diff --git a/.patching-mods/rtm.patching-mod/on-vcs.txt b/.patching-mods/rtm.patching-mod/on-vcs.txt new file mode 100644 index 00000000..c77e2a4e --- /dev/null +++ b/.patching-mods/rtm.patching-mod/on-vcs.txt @@ -0,0 +1 @@ +PATCHES \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index fe270271..a36ee919 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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" } @@ -68,9 +69,9 @@ 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") @@ -87,7 +88,7 @@ dependencies { 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) @@ -109,6 +110,13 @@ 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") /* @@ -181,6 +189,25 @@ 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") diff --git a/processMods.gradle b/processMods.gradle index 116739dd..6ca0a810 100644 --- a/processMods.gradle +++ b/processMods.gradle @@ -86,7 +86,7 @@ task copyNgtLibResources(type: Copy) { into(file("src/main/ngtlibResources")) } -task decompileMods() { +decompileMods { dependsOn disassembleRTM, disassembleNgtLib } @@ -159,7 +159,7 @@ task printModelPackLoadMethodCode(type: PrintMethodCode) { methodDesc = "(Ljp/ngt/rtm/modelpack/init/ModelPackLoadThread;)V" } -task prepareMods() { +prepareMods { dependsOn decompileMods dependsOn archiveRTMResourcesZip dependsOn copyRTMResources, copyNgtLibResources diff --git a/settings.gradle.kts b/settings.gradle.kts index 3a8f3fbf..05901c33 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,9 @@ buildscript { repositories { mavenCentral() + maven(url = "https://oss.sonatype.org/content/repositories/snapshots/") { + name = "ossrh-snapshot" + } maven(url = "https://files.minecraftforge.net/maven") { name = "forge" } @@ -15,5 +18,8 @@ buildscript { exclude(group = "org.ow2.asm", module = "asm-debug-all") } classpath("com.anatawa12.java-stab-gen:gradle-library:1.0.0") + classpath("com.anatawa12.mod-patching:mod-patching-gradle-plugin:1.0.0-SNAPSHOT") { + isChanging = true + } } } From 93958a58e52a644171e2e8bb6ead02c1570772a6 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 2 Mar 2021 19:12:57 +0900 Subject: [PATCH 2/8] remove unused script --- build.gradle.kts | 1 - buildSrc/src/main/kotlin/CheckClassesSame.kt | 274 ------------------ buildSrc/src/main/kotlin/DeObfuscateJar.kt | 28 -- buildSrc/src/main/kotlin/DownloadModJar.kt | 48 --- .../src/main/kotlin/MakeClassBsdiffPatch.kt | 66 ----- .../kotlin/RemakeClassWithConstantPool.kt | 55 ---- .../gradle/AbstractInsnNodePatchPrinter.kt | 102 ------- .../anatawa12/fixrtm/gradle/DeObfuscator.kt | 78 ----- makePatch.gradle | 80 ----- processMods.gradle | 145 +-------- 10 files changed, 10 insertions(+), 867 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/CheckClassesSame.kt delete mode 100644 buildSrc/src/main/kotlin/DeObfuscateJar.kt delete mode 100644 buildSrc/src/main/kotlin/DownloadModJar.kt delete mode 100644 buildSrc/src/main/kotlin/MakeClassBsdiffPatch.kt delete mode 100644 buildSrc/src/main/kotlin/RemakeClassWithConstantPool.kt delete mode 100644 buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/AbstractInsnNodePatchPrinter.kt delete mode 100644 buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/DeObfuscator.kt delete mode 100644 makePatch.gradle diff --git a/build.gradle.kts b/build.gradle.kts index a36ee919..dbe0c03a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -209,7 +209,6 @@ patching { } apply(from = "./processMods.gradle") -apply(from = "./makePatch.gradle") curseforge { apiKey = project.findProperty("com.anatawa12.curse.api-key").toString() diff --git a/buildSrc/src/main/kotlin/CheckClassesSame.kt b/buildSrc/src/main/kotlin/CheckClassesSame.kt deleted file mode 100644 index 1bd0a3ad..00000000 --- a/buildSrc/src/main/kotlin/CheckClassesSame.kt +++ /dev/null @@ -1,274 +0,0 @@ -import com.anatawa12.fixrtm.gradle.AbstractInsnNodePatchPrinter -import com.github.difflib.DiffUtils -import com.github.difflib.patch.Patch -import org.gradle.api.DefaultTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.TaskAction -import org.objectweb.asm.ClassReader -import org.objectweb.asm.tree.* -import org.slf4j.LoggerFactory -import java.io.File -import java.util.zip.ZipFile - -open class CheckClassesSame : DefaultTask() { - private val logger = LoggerFactory.getLogger("CheckClassesSame") - @InputFile - var src: File? = null - @InputFile - var dst: File? = null - @Input - var rootPackage: String? = null - - private val differences = mutableSetOf() - - @TaskAction - fun check() { - val src = src ?: error("src not initialized") - val dst = dst ?: error("dst not initialized") - val rootPackagePath = rootPackage?.replace('.', '/') ?: error("rootPackage not initialized") - - differences.clear() - - val srcZip = ZipFile(src) - val dstZip = ZipFile(dst) - - val srcClasses = mutableSetOf() - - srcZip.entries().asSequence().forEach { srcEntry -> - if (!srcEntry.name.endsWith(".class")) return@forEach - if (!srcEntry.name.startsWith(rootPackagePath)) return@forEach - srcClasses.add(srcEntry.name) - val dstEntry = dstZip.getEntry(srcEntry.name) - if (dstEntry == null) return@forEach addDiff(Difference.ClassOnlyInSrc(srcEntry.name.removeSuffix(".class"))) - val srcClass = readClass(srcZip.getInputStream(srcEntry).readBytes(1024)) - val dstClass = readClass(dstZip.getInputStream(dstEntry).readBytes(1024)) - - checkClass(srcEntry.name.removeSuffix(".class"), srcClass, dstClass) - } - - srcZip.entries().asSequence().forEach { dstEntry -> - if (!dstEntry.name.endsWith(".class")) return@forEach - if (!dstEntry.name.startsWith(rootPackagePath)) return@forEach - if (dstEntry.name !in srcClasses) - addDiff(Difference.ClassOnlyInDst(dstEntry.name.removeSuffix(".class"))) - } - - for (difference in differences) { - when (difference) { - is Difference.ClassOnlyInSrc -> - logger.error("${difference.name} is only in src") - is Difference.ClassOnlyInDst -> - logger.error("${difference.name} is only in dst") - is Difference.FieldOnlyInSrc -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} is only in src") - is Difference.FieldOnlyInDst -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} is only in dst") - is Difference.MethodOnlyInSrc -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} is only in dst") - is Difference.MethodOnlyInDst -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} is only in dst") - is Difference.ClassSignatureChanged -> - logger.error("${difference.className} signature changed. src: '${difference.src}' dst: '${difference.dst}'") - is Difference.FieldSignatureChanged -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} signature changed. src: '${difference.src}' dst: '${difference.dst}'") - is Difference.MethodSignatureChanged -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} signature changed. src: '${difference.src}' dst: '${difference.dst}'") - is Difference.FieldAccessChanged -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} access changed") - is Difference.MethodAccessChanged -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} access changed") - is Difference.FieldValueChanged -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} value changed") - is Difference.MethodCodeChanged -> - logger.error(buildString { - appendln("${difference.owner}.${difference.name}:${difference.desc} code changed") - appendln(AbstractInsnNodePatchPrinter.print(difference.source, difference.patch)) - }) - is Difference.AnnotationDefaultChanged -> - logger.error("${difference.owner}.${difference.name}:${difference.desc} annotation default changed") - } - } - } - - private fun checkClass(className: String, srcClass: ClassNode, dstClass: ClassNode) { - if (srcClass.signature != dstClass.signature) - addDiff(Difference.ClassSignatureChanged(className, srcClass.signature, dstClass.signature)) - - val srcFields = srcClass.fields.map { it.name to it.desc to it }.toMap() - val dstFields = dstClass.fields.map { it.name to it.desc to it }.toMap() - srcFields.zipNullable(dstFields).forEach { (k, v) -> - val (name, desc) = k - val (srcField, dstField) = v - if (dstField == null) return@forEach addDiff(Difference.FieldOnlyInSrc(className, name, desc)) - if (srcField == null) return@forEach addDiff(Difference.FieldOnlyInDst(className, name, desc)) - checkField(className, name, desc, srcField, dstField) - } - val srcMethods = srcClass.methods.map { it.name to it.desc to it }.toMap() - val dstMethods = dstClass.methods.map { it.name to it.desc to it }.toMap() - srcMethods.zipNullable(dstMethods).forEach { (k, v) -> - val (name, desc) = k - val (srcMethod, dstMethod) = v - if (dstMethod == null) return@forEach addDiff(Difference.MethodOnlyInSrc(className, name, desc)) - if (srcMethod == null) return@forEach addDiff(Difference.MethodOnlyInDst(className, name, desc)) - checkMethod(className, name, desc, srcMethod, dstMethod) - } - } - - private fun checkField(owner: String, name: String, desc: String, srcField: FieldNode, dstField: FieldNode) { - if (srcField.access != dstField.access) - addDiff(Difference.FieldAccessChanged(owner, name, desc)) - if (srcField.signature != dstField.signature) - addDiff(Difference.FieldSignatureChanged(owner, name, desc, srcField.signature, dstField.signature)) - if (srcField.value != dstField.value) - addDiff(Difference.FieldValueChanged(owner, name, desc)) - } - - private fun checkMethod(owner: String, name: String, desc: String, srcMethod: MethodNode, dstMethod: MethodNode) { - if (srcMethod.access != dstMethod.access) - addDiff(Difference.MethodAccessChanged(owner, name, desc)) - if (srcMethod.signature != dstMethod.signature) - addDiff(Difference.MethodSignatureChanged(owner, name, desc, srcMethod.signature, dstMethod.signature)) - if (srcMethod.annotationDefault != dstMethod.annotationDefault) - addDiff(Difference.AnnotationDefaultChanged(owner, name, desc)) - val srcInsns = srcMethod.instructions.iterator().asSequence().filter { it.opcode != -1 }.toList() - val dstInsns = dstMethod.instructions.iterator().asSequence().filter { it.opcode != -1 }.toList() - val patch = DiffUtils.diff(srcInsns, dstInsns, ::checkInsn) - if (patch.deltas.isEmpty()) return - - addDiff(Difference.MethodCodeChanged(owner, name, desc, srcInsns, patch)) - } - - private fun checkInsn(srcInsn: AbstractInsnNode, dstInsn: AbstractInsnNode): Boolean { - if (srcInsn.opcode != dstInsn.opcode) return false - if (srcInsn.javaClass != dstInsn.javaClass) return false - when (srcInsn) { - is FieldInsnNode -> { - dstInsn as FieldInsnNode - if (srcInsn.owner != dstInsn.owner) return false - if (srcInsn.name != dstInsn.name) return false - if (srcInsn.desc != dstInsn.desc) return false - } - is IincInsnNode -> { - dstInsn as IincInsnNode - if (srcInsn.`var` != dstInsn.`var`) return false - if (srcInsn.incr != dstInsn.incr) return false - } - is InsnNode -> { - dstInsn as InsnNode - } - is IntInsnNode -> { - dstInsn as IntInsnNode - if (srcInsn.operand != dstInsn.operand) return false - } - is InvokeDynamicInsnNode -> { - dstInsn as InvokeDynamicInsnNode - if (srcInsn.name != dstInsn.name) return false - if (srcInsn.desc != dstInsn.desc) return false - if (srcInsn.bsm != dstInsn.bsm) return false - if (!srcInsn.bsmArgs.contentEquals(dstInsn.bsmArgs)) return false - } - is JumpInsnNode -> { - dstInsn as JumpInsnNode - //if (srcInsn.label != dstInsn.label) return false - } - is LdcInsnNode -> { - dstInsn as LdcInsnNode - if (srcInsn.cst != dstInsn.cst) return false - } - is LookupSwitchInsnNode -> { - dstInsn as LookupSwitchInsnNode - //if (srcInsn.dflt != dstInsn.dflt) return false - if (srcInsn.keys != dstInsn.keys) return false - //if (srcInsn.labels != dstInsn.labels) return false - } - is MethodInsnNode -> { - dstInsn as MethodInsnNode - if (srcInsn.owner != dstInsn.owner) return false - if (srcInsn.name != dstInsn.name) return false - if (srcInsn.desc != dstInsn.desc) return false - if (srcInsn.itf != dstInsn.itf) return false - } - is MultiANewArrayInsnNode -> { - dstInsn as MultiANewArrayInsnNode - if (srcInsn.desc != dstInsn.desc) return false - if (srcInsn.dims != dstInsn.dims) return false - } - is TableSwitchInsnNode -> { - dstInsn as TableSwitchInsnNode - if (srcInsn.min != dstInsn.min) return false - if (srcInsn.max != dstInsn.max) return false - //if (srcInsn.dflt != dstInsn.dflt) return false - //if (srcInsn.labels != dstInsn.labels) return false - } - is TypeInsnNode -> { - dstInsn as TypeInsnNode - if (srcInsn.desc != dstInsn.desc) return false - } - is VarInsnNode -> { - dstInsn as VarInsnNode - if (srcInsn.`var` != dstInsn.`var`) return false - } - else -> error("Not yet implemented: ${srcInsn.javaClass.simpleName}") - } - return true - } - - private fun readClass(byteArray: ByteArray): ClassNode = ClassNode().apply { - ClassReader(byteArray) - .accept(this, ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES) - } - - private fun Map.zipNullable(other: Map): Map> { - val result = mutableMapOf>() - for ((k, v) in this) { - result[k] = v to other[k] - } - for (k in (other.keys - keys)) { - result[k] = null to other[k] - } - return result - } - - private fun addDiff(diff: Difference) { - differences.add(diff) - } - - private sealed class Difference { - data class ClassOnlyInSrc(val name: String) : Difference() - data class ClassOnlyInDst(val name: String) : Difference() - data class FieldOnlyInSrc(val owner: String, val name: String, val desc: String) : Difference() - data class FieldOnlyInDst(val owner: String, val name: String, val desc: String) : Difference() - data class MethodOnlyInSrc(val owner: String, val name: String, val desc: String) : Difference() - data class MethodOnlyInDst(val owner: String, val name: String, val desc: String) : Difference() - data class ClassSignatureChanged(val className: String, val src: String?, val dst: String?) : Difference() - data class FieldSignatureChanged( - val owner: String, - val name: String, - val desc: String, - val src: String?, - val dst: String? - ) : Difference() - - data class MethodSignatureChanged( - val owner: String, - val name: String, - val desc: String, - val src: String?, - val dst: String? - ) : Difference() - - data class FieldAccessChanged(val owner: String, val name: String, val desc: String) : Difference() - data class MethodAccessChanged(val owner: String, val name: String, val desc: String) : Difference() - data class FieldValueChanged(val owner: String, val name: String, val desc: String) : Difference() - data class MethodCodeChanged( - val owner: String, - val name: String, - val desc: String, - val source: List, - val patch: Patch - ) : Difference() - - data class AnnotationDefaultChanged(val owner: String, val name: String, val desc: String) : Difference() - } -} diff --git a/buildSrc/src/main/kotlin/DeObfuscateJar.kt b/buildSrc/src/main/kotlin/DeObfuscateJar.kt deleted file mode 100644 index 568a4d7e..00000000 --- a/buildSrc/src/main/kotlin/DeObfuscateJar.kt +++ /dev/null @@ -1,28 +0,0 @@ -import com.anatawa12.fixrtm.gradle.DeObfuscator -import org.gradle.api.DefaultTask -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction -import java.io.File - -open class DeObfuscateJar : DefaultTask() { - @InputFile - var srgFile: File? = null - - @InputFile - var obfuscatedJar: File? = null - - @OutputFile - var deObfuscatedJar: File? = null - - @TaskAction - fun run() { - srgFile ?: error("srgFile not initialized") - obfuscatedJar ?: error("obfuscatedJar not initialized") - deObfuscatedJar ?: error("deObfuscatedJar not initialized") - - val deObfuscator = DeObfuscator(srgFile!!) - deObfuscatedJar!!.parentFile.mkdirs() - deObfuscator.deObfuscateJar(obfuscatedJar!!.inputStream(), deObfuscatedJar!!.outputStream()) - } -} diff --git a/buildSrc/src/main/kotlin/DownloadModJar.kt b/buildSrc/src/main/kotlin/DownloadModJar.kt deleted file mode 100644 index 2f208866..00000000 --- a/buildSrc/src/main/kotlin/DownloadModJar.kt +++ /dev/null @@ -1,48 +0,0 @@ -import com.therandomlabs.curseapi.CurseAPI -import okhttp3.OkHttpClient -import okhttp3.Request -import org.gradle.api.DefaultTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction -import java.io.File -import kotlin.properties.Delegates - -open class DownloadModJar : DefaultTask() { - @get:Input - var projectId: Int by Delegates.notNull() - - @OutputFile - lateinit var to: File - @Input - lateinit var version: String - - @TaskAction - fun download() { - version // check init - to // check init - - val files = CurseAPI.files(projectId) - if (!files.isPresent) - error("project#$projectId files not found") - - val file = files.get() - .filterNot { "1.12.2" !in it.gameVersionStrings() } - .filter { version in it.displayName() } - .singleOrNull() - ?: error("project#$projectId version $version not found or found two or more") - - println("file name is: ${file.displayName()}, id: ${file.id()}") - - val url = file.downloadURL() - - val response = OkHttpClient().newCall(Request.Builder().url(url).get().build()).execute() - - if (!response.isSuccessful) - error("http request is not succeed: $url returns ${response.code()}") - - to.parentFile.mkdirs() - response.body()!!.byteStream().copyTo(to.outputStream()) - } - -} diff --git a/buildSrc/src/main/kotlin/MakeClassBsdiffPatch.kt b/buildSrc/src/main/kotlin/MakeClassBsdiffPatch.kt deleted file mode 100644 index ddc8afb2..00000000 --- a/buildSrc/src/main/kotlin/MakeClassBsdiffPatch.kt +++ /dev/null @@ -1,66 +0,0 @@ -import io.sigpipe.jbsdiff.Diff -import org.gradle.api.DefaultTask -import org.gradle.api.file.FileTree -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.TaskAction -import java.io.File -import java.security.MessageDigest - -open class MakeClassBsdiffPatch : DefaultTask() { - @InputFiles - var oldFiles: FileTree = project.files().asFileTree - @InputFiles - var newFiles: FileTree = project.files().asFileTree - @OutputDirectory - var outTo: File? = null - @Input - var patchPrefix: String? = null - - @TaskAction - fun run() { - val oldFiles = getAllFiles(oldFiles) - val newFiles = getAllFiles(newFiles) - val outTo = outTo ?: error("outTo not inited") - val patchPrefix = patchPrefix ?: error("patchPrefix not inited") - - check((oldFiles.keys - newFiles.keys).isEmpty()) { "some files are deleted: ${oldFiles.keys - newFiles.keys}" } - check((newFiles.keys - oldFiles.keys).isEmpty()) { "some files are added: ${newFiles.keys - oldFiles.keys}" } - - val patchDir = outTo.resolve(patchPrefix) - val sha1 = MessageDigest.getInstance("SHA-1") - - for ((newPath, newFile) in newFiles) { - val oldFile = oldFiles[newPath] ?: continue - - val oldBytes = oldFile.readBytes() - val newBytes = newFile.readBytes() - - val oldHashFile = patchDir.resolve("$newPath.old.sha1") - oldHashFile.parentFile.mkdirs() - oldHashFile.writeBytes(sha1.digest(oldBytes)) - - if (oldBytes.contentEquals(newBytes)) - continue - - val bsDiffFile = patchDir.resolve("$newPath.bsdiff") - val newHashFile = patchDir.resolve("$newPath.new.sha1") - - bsDiffFile.parentFile.mkdirs() - newHashFile.parentFile.mkdirs() - - Diff.diff(oldBytes, newBytes, bsDiffFile.outputStream()) - newHashFile.writeBytes(sha1.digest(newBytes)) - } - } - - private fun getAllFiles(fileTree: FileTree): Map { - val files = mutableMapOf() - fileTree.visit { - if (isDirectory) return@visit - files[path] = file - } - return files - } -} diff --git a/buildSrc/src/main/kotlin/RemakeClassWithConstantPool.kt b/buildSrc/src/main/kotlin/RemakeClassWithConstantPool.kt deleted file mode 100644 index 4fb9b408..00000000 --- a/buildSrc/src/main/kotlin/RemakeClassWithConstantPool.kt +++ /dev/null @@ -1,55 +0,0 @@ -import org.gradle.api.DefaultTask -import org.gradle.api.file.FileTree -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.TaskAction -import org.objectweb.asm.ClassReader -import org.objectweb.asm.ClassWriter -import java.io.File - -open class RemakeClassWithConstantPool : DefaultTask() { - @InputFiles - var oldFiles: FileTree = project.files().asFileTree - @InputFiles - var newFiles: FileTree = project.files().asFileTree - @OutputDirectory - var outTo: File? = null - - @TaskAction - fun run() { - val oldFiles = getAllFiles(oldFiles) - val newFiles = getAllFiles(newFiles) - val outTo = outTo ?: error("outTo not inited") - - check((oldFiles.keys - newFiles.keys).isEmpty()) { "some files are deleted: ${oldFiles.keys - newFiles.keys}" } - check((newFiles.keys - oldFiles.keys).isEmpty()) { "some files are added: ${newFiles.keys - oldFiles.keys}" } - - for ((newPath, newFile) in newFiles) { - val oldFile = oldFiles[newPath] - - outTo.resolve(newPath).parentFile.mkdirs() - - if (oldFile == null) { - newFile.copyTo(outTo.resolve(newPath), overwrite = true) - continue - } - - outTo.resolve(newPath).writeBytes(remakeClass(oldFile.readBytes(), newFile.readBytes())) - } - } - - private fun remakeClass(oldBytes: ByteArray, readBytes: ByteArray): ByteArray { - return ClassWriter(ClassReader(oldBytes), 0) - .also { ClassReader(readBytes).accept(it, 0) } - .toByteArray() - } - - private fun getAllFiles(fileTree: FileTree): Map { - val files = mutableMapOf() - fileTree.visit { - if (isDirectory) return@visit - files[path] = file - } - return files - } -} diff --git a/buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/AbstractInsnNodePatchPrinter.kt b/buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/AbstractInsnNodePatchPrinter.kt deleted file mode 100644 index f2386440..00000000 --- a/buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/AbstractInsnNodePatchPrinter.kt +++ /dev/null @@ -1,102 +0,0 @@ -package com.anatawa12.fixrtm.gradle - -import com.github.difflib.patch.Patch -import org.objectweb.asm.tree.* -import org.objectweb.asm.util.Printer -import kotlin.math.max - -object AbstractInsnNodePatchPrinter { - private val size = 10 - - fun print(source: List, patch: Patch) = buildString { - var insnIndex = 0 - for (delta in patch.deltas) { - printNonPatches(source, insnIndex, delta.source.position) - insnIndex = delta.source.position + delta.source.lines.size - for (line in delta.source.lines) { - append('-').printInsn(line) - } - for (line in delta.target.lines) { - append('+').printInsn(line) - } - } - val end = kotlin.math.min(insnIndex + size, source.size) - for (line in source.subList(insnIndex, end)) { - append(' ').printInsn(line) - } - if (end != source.size) - appendln("@@@ $end ${source.size} @@@") - } - - fun Appendable.printNonPatches(source: List, insnIndex: Int, sourcePosition: Int) { - if (insnIndex == 0) { - val start = max(0, sourcePosition - size) - if (start != 0) - appendln("@@@ 0 $start @@@") - for (line in source.subList(start, sourcePosition)) { - append(' ').printInsn(line) - } - } else if (sourcePosition - insnIndex <= size * 2) { - for (line in source.subList(insnIndex, sourcePosition)) { - append(' ').printInsn(line) - } - } else { - for (line in source.subList(insnIndex, insnIndex + size)) { - append(' ').printInsn(line) - } - appendln("@@@ ${insnIndex + size} ${sourcePosition - size} @@@") - for (line in source.subList(sourcePosition - size, sourcePosition)) { - append(' ').printInsn(line) - } - } - } - - - private fun Appendable.printInsn(insn: AbstractInsnNode) { - val insnName = Printer.OPCODES[insn.opcode] - insn.run { - when (this) { - is FieldInsnNode -> { - appendln("$insnName $owner.$name $desc") - } - is IincInsnNode -> { - appendln("$insnName $`var` $incr") - } - is InsnNode -> { - appendln(insnName) - } - is IntInsnNode -> { - appendln("$insnName $operand") - } - is InvokeDynamicInsnNode -> { - appendln("$insnName $name$desc $bsm ${bsmArgs!!.contentToString()}") - } - is JumpInsnNode -> { - appendln("$insnName :Label") - } - is LdcInsnNode -> { - appendln("$insnName $cst") - } - is LookupSwitchInsnNode -> { - appendln("$insnName $keys") - } - is MethodInsnNode -> { - appendln("$insnName $owner.$name $desc $itf") - } - is MultiANewArrayInsnNode -> { - appendln("$insnName $desc $dims") - } - is TableSwitchInsnNode -> { - appendln("$insnName $min $max") - } - is TypeInsnNode -> { - appendln("$insnName $desc") - } - is VarInsnNode -> { - appendln("$insnName $`var`") - } - else -> error("Not yet implemented: ${insn.javaClass.simpleName}") - } - } - } -} diff --git a/buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/DeObfuscator.kt b/buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/DeObfuscator.kt deleted file mode 100644 index f31f776e..00000000 --- a/buildSrc/src/main/kotlin/com/anatawa12/fixrtm/gradle/DeObfuscator.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.anatawa12.fixrtm.gradle - -import org.objectweb.asm.ClassReader -import org.objectweb.asm.ClassWriter -import org.objectweb.asm.commons.ClassRemapper -import org.objectweb.asm.commons.Remapper -import java.io.File -import java.io.InputStream -import java.io.OutputStream -import java.util.zip.ZipEntry -import java.util.zip.ZipInputStream -import java.util.zip.ZipOutputStream - -class DeObfuscator(srgFile: File) { - private val remapper = SrgRemapper(srgFile.readText()) - - fun deObfuscateJar(inputJar: InputStream, outputJar: OutputStream) { - ZipInputStream(inputJar).use { zis -> - ZipOutputStream(outputJar).use { zos -> - while (true) { - val entry = zis.nextEntry ?: break - zos.putNextEntry(ZipEntry(entry.name).apply { - time = entry.time - if (entry.creationTime != null) - creationTime = entry.creationTime - if (entry.lastAccessTime != null) - lastAccessTime = entry.lastAccessTime - if (entry.lastModifiedTime != null) - lastModifiedTime = entry.lastModifiedTime - }) - if (entry.name.endsWith(".class")) { - @Suppress("DEPRECATION") - zos.write(deObfuscate(zis.readBytes(1024))) - } else { - zis.copyTo(zos) - } - zos.closeEntry() - zis.closeEntry() - } - } - } - } - - fun deObfuscate(classFile: ByteArray): ByteArray { - val writer = ClassWriter(0) - ClassReader(classFile).accept(ClassRemapper(writer, remapper), 0) - return writer.toByteArray() - } - - private class SrgRemapper(srg: String) : Remapper() { - val classMap: Map - val fieldMap: Map - val methodMap: Map - - init { - val classMap = mutableMapOf() - val fieldMap = mutableMapOf() - val methodMap = mutableMapOf() - for (s in srg.lineSequence()) { - val elements = s.split(' ') - if (elements.isEmpty()) continue - when (elements[0]) { - "CL:" -> classMap[elements[1]] = elements[2] - "MD:" -> methodMap[elements[1].substringAfterLast('/')] = elements[3].substringAfterLast('/') - "FD:" -> fieldMap[elements[1].substringAfterLast('/')] = elements[2].substringAfterLast('/') - } - } - this.classMap = classMap - this.fieldMap = fieldMap - this.methodMap = methodMap - } - - override fun map(typeName: String): String = classMap[typeName] ?: typeName - override fun mapFieldName(owner: String, name: String, desc: String): String = fieldMap[name] ?: name - override fun mapMethodName(owner: String, name: String, desc: String): String = methodMap[name] ?: name - override fun mapInvokeDynamicMethodName(name: String, desc: String): String = methodMap[name] ?: name - } -} diff --git a/makePatch.gradle b/makePatch.gradle deleted file mode 100644 index 53e119fd..00000000 --- a/makePatch.gradle +++ /dev/null @@ -1,80 +0,0 @@ -def buildDir = file("${buildDir}/fixrtm") - -def oldRTM = file("${projectDir}/mods/rtm.jar") -def oldNGTLib = file("${projectDir}/mods/ngtlib.jar") -def fixRtmBuiltJar = jar.archivePath - -def patchesDir = file("${buildDir}/resources/patches") -def unzippedJarDir = file("$buildDir/unzipped") -def fixRtmOutputDir = file("$buildDir/libs") -def remadeClassesDir = file("$buildDir/remade-classes") -def unzippedNgtsDir = file("$buildDir/unzipped-ngts") - -task unzipNgtsDir(type: Copy) { - from(zipTree(oldRTM) + zipTree(oldNGTLib)) { - include("**/*.class") - } - into unzippedNgtsDir -} - -task remakeClasses(type: RemakeClassWithConstantPool) { - dependsOn build - dependsOn unzipNgtsDir - - oldFiles = fileTree(unzippedNgtsDir) - newFiles = zipTree(fixRtmBuiltJar).matching { - include("jp/ngt/**/*.class") - } - outTo = remadeClassesDir -} - -task makeRtmPatch(type: MakeClassBsdiffPatch) { - dependsOn remakeClasses - dependsOn unzipNgtsDir - dependsOn build - - oldFiles = fileTree(unzippedNgtsDir) - newFiles = fileTree(remadeClassesDir) - - outTo = patchesDir - patchPrefix = "com/anatawa12/fixRtm/asm/patches" -} - -task unzipFixRTM(type: Copy) { - dependsOn build - - from(zipTree(fixRtmBuiltJar)) { - include("**/*.class") - exclude("jp/**/*.class") - exclude("jp/**") - } - - destinationDir = unzippedJarDir -} - -task makeFixrtmJar(type: Jar) { - dependsOn build - dependsOn makeRtmPatch - dependsOn unzipFixRTM - - from("src/main/resources") { - include "mcmod.info" - expand "version": project.version, "mcversion": project.minecraft.version - } - from("src/main/resources") { - exclude "mcmod.info" - } - from unzippedJarDir - from patchesDir - - destinationDir = fixRtmOutputDir - baseName = jar.baseName - version = project.version - - manifest { - attributes("FMLCorePlugin": "com.anatawa12.fixRtm.asm.FixRtmCorePlugin", - "FMLCorePluginContainsFMLMod": "*", - 'FMLAT': 'fix-rtm_at.cfg', - ) - } -} diff --git a/processMods.gradle b/processMods.gradle index 6ca0a810..7e94d602 100644 --- a/processMods.gradle +++ b/processMods.gradle @@ -1,106 +1,3 @@ -task CopyJarToTest(type: Copy, dependsOn: reobfJar) { - from jar.archivePath - into new File(projectDir, "../fixRtmTest/mods") -} - -task downloadRTM(type: DownloadModJar) { - projectId = 288988 - version = "2.4.21" - to = new File(projectDir, "mods/rtm.jar") -} - -task downloadNgtLib(type: DownloadModJar) { - projectId = 288989 - version = "2.4.18" - to = new File(projectDir, "mods/ngtlib.jar") -} - -def srgMcpsrgFile = file("${project.gradle.gradleUserHomeDir}" + - "/caches/minecraft/de/oceanlabs/mcp" + - "/mcp_${minecraft.mappingsChannel}/${minecraft.mappings.substring(minecraft.mappings.indexOf('_') + 1)}" + - "/${minecraft.version}/srgs/srg-mcp.srg") - -static String deObfuscatedJarPath(String path) { - return path.substring(0, path.lastIndexOf('.')) + ".deobf.jar" -} - -task deObfuscateRTM(type: DeObfuscateJar) { - dependsOn downloadRTM - dependsOn genSrgs - - srgFile = srgMcpsrgFile - obfuscatedJar = downloadRTM.to - deObfuscatedJar = file(deObfuscatedJarPath("${downloadRTM.to}")) -} - -task deObfuscateNgtLib(type: DeObfuscateJar) { - dependsOn downloadNgtLib - dependsOn genSrgs - - srgFile = srgMcpsrgFile - obfuscatedJar = downloadNgtLib.to - deObfuscatedJar = file(deObfuscatedJarPath("${downloadNgtLib.to}")) -} - -task disassembleRTM(type: com.anatawa12.jasm.plugins.gradle.DisassembleToJasm) { - dependsOn deObfuscateRTM - - files = zipTree(deObfuscateRTM.deObfuscatedJar).matching { - include "**/*.class" - } - - outputTo = file("${deObfuscateRTM.deObfuscatedJar}.src") -} - -task disassembleNgtLib(type: com.anatawa12.jasm.plugins.gradle.DisassembleToJasm) { - dependsOn deObfuscateNgtLib - - files = zipTree(deObfuscateNgtLib.deObfuscatedJar).matching { - include "**/*.class" - } - - outputTo = file("${deObfuscateNgtLib.deObfuscatedJar}.src") -} - -task copyRTMResources(type: Copy) { - dependsOn downloadRTM - - from(zipTree(downloadRTM.to)) { - exclude("**/*.class") - } - - includeEmptyDirs = false - - into(file("src/main/rtmResources")) -} - -task copyNgtLibResources(type: Copy) { - dependsOn downloadNgtLib - - from(zipTree(downloadNgtLib.to)) { - exclude("**/*.class") - } - - includeEmptyDirs = false - - into(file("src/main/ngtlibResources")) -} - -decompileMods { - dependsOn disassembleRTM, disassembleNgtLib -} - -task archiveRTMResourcesZip(type: Zip) { - dependsOn downloadRTM - - from(zipTree(downloadRTM.to)) { - exclude("**/*.class") - } - - destinationDir = file('run/mods') - archiveName 'RTMResources.zip' -} - final importantStructureDir = new File(projectDir, "important-structure") task addImportantStructureDir(type: Exec) { @@ -108,10 +5,10 @@ task addImportantStructureDir(type: Exec) { } task printResourceConfigFieldStructure(type: PrintFieldStructure) { - dependsOn downloadRTM + dependsOn downloadModRtm finalizedBy addImportantStructureDir - files = zipTree(downloadRTM.to).matching { + files = zipTree(downloadModRtm.destniation).matching { include "**/*.class" } outTo = new File(importantStructureDir, "fields-ResourceConfig") @@ -119,10 +16,10 @@ task printResourceConfigFieldStructure(type: PrintFieldStructure) { } task printResourceSetFieldStructure(type: PrintFieldStructure) { - dependsOn downloadRTM + dependsOn downloadModRtm finalizedBy addImportantStructureDir - files = zipTree(downloadRTM.to).matching { + files = zipTree(downloadModRtm.destniation).matching { include "**/*.class" } outTo = new File(importantStructureDir, "fields-ResourceSet") @@ -136,10 +33,10 @@ task printResourceSetFieldStructure(type: PrintFieldStructure) { } task printRTMResourceStaticFields(type: PrintStaticFields) { - dependsOn downloadRTM + dependsOn downloadModRtm finalizedBy addImportantStructureDir - files = zipTree(downloadRTM.to).matching { + files = zipTree(downloadModRtm.destniation).matching { include "**/*.class" } outTo = new File(importantStructureDir, "fields-RTMResource.txt") @@ -147,10 +44,10 @@ task printRTMResourceStaticFields(type: PrintStaticFields) { } task printModelPackLoadMethodCode(type: PrintMethodCode) { - dependsOn downloadRTM + dependsOn downloadModRtm finalizedBy addImportantStructureDir - files = zipTree(downloadRTM.to).matching { + files = zipTree(downloadModRtm.destniation).matching { include "**/*.class" } outTo = new File(importantStructureDir, "fields-ModelPackLoadMethodCode.txt") @@ -159,33 +56,11 @@ task printModelPackLoadMethodCode(type: PrintMethodCode) { methodDesc = "(Ljp/ngt/rtm/modelpack/init/ModelPackLoadThread;)V" } -prepareMods { - dependsOn decompileMods - dependsOn archiveRTMResourcesZip - dependsOn copyRTMResources, copyNgtLibResources - +task printImportantStructure { dependsOn printResourceConfigFieldStructure dependsOn printResourceSetFieldStructure dependsOn printRTMResourceStaticFields dependsOn printModelPackLoadMethodCode } -task checkNgtLibClasses(type: CheckClassesSame) { - dependsOn jar, deObfuscateNgtLib - src = deObfuscateNgtLib.deObfuscatedJar - dst = jar.archivePath - rootPackage = "jp.ngt.ngtlib" -} - -task checkRtmClasses(type: CheckClassesSame) { - dependsOn jar, deObfuscateRTM - src = deObfuscateRTM.deObfuscatedJar - dst = jar.archivePath - rootPackage = "jp.ngt.rtm" -} - -task checkClasses { - dependsOn checkNgtLibClasses, checkRtmClasses -} - -build.dependsOn prepareMods +build.dependsOn printImportantStructure From 89f6ce320250db855831422a23aba117cdfc31da Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 2 Mar 2021 19:14:04 +0900 Subject: [PATCH 3/8] use implementation instead --- build.gradle.kts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index dbe0c03a..5fffdb8f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -74,14 +74,14 @@ dependencies { // 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") @@ -125,7 +125,7 @@ val runClient by tasks.getting(JavaExec::class) { // */ //* if (!project.hasProperty("noLogin") && project.hasProperty("minecraft.login.username") && project.hasProperty("minecraft.login.password")) - args = args.orEmpty() + listOf( + args = args + listOf( "-username", project.property("minecraft.login.username").toString(), "-password", project.property("minecraft.login.password").toString() ) From 139fd49b5100545ca6574120300431719c68bffe Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 3 Mar 2021 12:06:22 +0900 Subject: [PATCH 4/8] fix buildscript --- build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5fffdb8f..84a74552 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -125,7 +125,8 @@ val runClient by tasks.getting(JavaExec::class) { // */ //* if (!project.hasProperty("noLogin") && project.hasProperty("minecraft.login.username") && project.hasProperty("minecraft.login.password")) - args = args + listOf( + @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") + args = args!! + listOf( "-username", project.property("minecraft.login.username").toString(), "-password", project.property("minecraft.login.password").toString() ) From 5b9b37eb22efb835fcd54031fbc717209676023f Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 3 Mar 2021 14:12:14 +0900 Subject: [PATCH 5/8] fix warnings --- buildSrc/src/main/kotlin/PrintFieldStructure.kt | 10 +++++----- buildSrc/src/main/kotlin/PrintStaticFields.kt | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/kotlin/PrintFieldStructure.kt b/buildSrc/src/main/kotlin/PrintFieldStructure.kt index c1b67158..2a189407 100644 --- a/buildSrc/src/main/kotlin/PrintFieldStructure.kt +++ b/buildSrc/src/main/kotlin/PrintFieldStructure.kt @@ -41,14 +41,14 @@ open class PrintFieldStructure : DefaultTask() { for (hClass in printClasses) { val file = buildString { if (condition.test(hClass.internalName) && hClass.isLoaded) { - appendln("super: ${hClass.parentClass?.internalName}") + append("super: ${hClass.parentClass?.internalName}\n") for (field in hClass.fields.filter { !it.isStatic }.sortedBy { it.name }) { - appendln("name: ${field.name}") - appendln("type: ${field.type}") - appendln() + append("name: ${field.name}\n") + append("type: ${field.type}\n") + append("\n") } } else { - appendln("not loaded class") + append("not loaded class\n") } } diff --git a/buildSrc/src/main/kotlin/PrintStaticFields.kt b/buildSrc/src/main/kotlin/PrintStaticFields.kt index 81923712..ca852694 100644 --- a/buildSrc/src/main/kotlin/PrintStaticFields.kt +++ b/buildSrc/src/main/kotlin/PrintStaticFields.kt @@ -29,9 +29,9 @@ open class PrintStaticFields : DefaultTask() { val file = buildString { for (field in theClass.fields.filter { it.isStatic }) { - appendln("name: ${field.name}") - appendln("type: ${field.type}") - appendln() + append("name: ${field.name}\n") + append("type: ${field.type}\n") + append("\n") } } From 3324cacef0c2fbc5ce39913419fea1fac288f359 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 3 Mar 2021 19:01:44 +0900 Subject: [PATCH 6/8] apply and make patches see https://github.com/fixrtm/fixRTM/blame/8d4476c/patches/rtm.patch see https://github.com/fixrtm/fixRTM/blame/8d4476c/patches/ngtlib.patch --- .editorconfig | 3 + .idea/codeStyles/codeStyleConfig.xml | 2 +- .../ngtlib.patching-mod/modified-classes.txt | 8 ++ .patching-mods/ngtlib.patching-mod/on-vcs.txt | 2 +- .../rtm.patching-mod/modified-classes.txt | 40 ++++++ .patching-mods/rtm.patching-mod/on-vcs.txt | 2 +- build.gradle.kts | 3 +- settings.gradle.kts | 2 + .../jp/ngt/ngtlib/NGTCore.java.pm.patch | 20 +++ .../jp/ngt/ngtlib/io/NGTLog.java.pm.patch | 39 ++++++ .../item/craft/RecipeManager.java.pm.patch | 15 ++ .../item/craft/ShapedRecipes55.java.pm.patch | 31 +++++ .../renderer/model/ModelLoader.java.pm.patch | 17 +++ .../renderer/model/ObjModel.java.pm.patch | 16 +++ .../renderer/model/PolygonModel.java.pm.patch | 80 +++++++++++ .../util/PermissionManager.java.pm.patch | 32 +++++ .../jp/ngt/rtm/RTMItem.java.pm.patch | 15 ++ .../jp/ngt/rtm/RTMRecipe.java.pm.patch | 24 ++++ .../TileEntityMachineBase.java.pm.patch | 15 ++ .../TileEntityMechanism.java.pm.patch | 15 ++ .../TileEntityOrnament.java.pm.patch | 15 ++ .../TileEntityConnectorBase.java.pm.patch | 15 ++ .../electric/TileEntitySignal.java.pm.patch | 15 ++ .../ai/EntityAITravelByTrain.java.pm.patch | 19 +++ .../rtm/entity/npc/EntityNPC.java.pm.patch | 15 ++ .../entity/train/EntityBogie.java.pm.patch | 35 +++++ .../train/EntityTrainBase.java.pm.patch | 75 ++++++++++ .../parts/EntityCargoWithModel.java.pm.patch | 15 ++ .../vehicle/EntityTrolley.java.pm.patch | 15 ++ .../vehicle/EntityVehicleBase.java.pm.patch | 36 +++++ .../vehicle/RenderVehicleBase.java.pm.patch | 15 ++ .../vehicle/VehicleTrackerEntry.java.pm.patch | 45 ++++++ .../vehicle/WeatherEffectDummy.java.pm.patch | 14 ++ .../rtm/event/RTMEventHandler.java.pm.patch | 23 +++ .../ngt/rtm/item/ItemPaintTool.java.pm.patch | 15 ++ .../modelpack/ModelPackManager.java.pm.patch | 131 ++++++++++++++++++ .../cfg/ResourceConfig.java.pm.patch | 14 ++ .../ModelPackConstructThread.java.pm.patch | 27 ++++ .../init/ModelPackLoadThread.java.pm.patch | 15 ++ .../modelset/ModelSetBase.java.pm.patch | 51 +++++++ .../modelset/ModelSetNPC.java.pm.patch | 14 ++ .../modelset/ModelSetSignal.java.pm.patch | 14 ++ .../modelset/ModelSetTrain.java.pm.patch | 14 ++ .../ModelSetVehicleBase.java.pm.patch | 41 ++++++ .../modelset/ResourceSet.java.pm.patch | 14 ++ .../state/ResourceState.java.pm.patch | 15 ++ .../rtm/rail/BlockLargeRailBase.java.pm.patch | 15 ++ .../jp/ngt/rtm/rail/BlockMarker.java.pm.patch | 14 ++ .../rtm/rail/RenderMarkerBlock.java.pm.patch | 44 ++++++ .../ngt/rtm/rail/util/RailMaker.java.pm.patch | 15 ++ .../rtm/rail/util/SwitchType.java.pm.patch | 17 +++ .../ngt/rtm/render/ModelObject.java.pm.patch | 44 ++++++ .../rtm/render/PartsRenderer.java.pm.patch | 15 ++ .../ngt/rtm/render/RTMRenderers.java.pm.patch | 23 +++ .../rtm/sound/MovingSoundMaker.java.pm.patch | 14 ++ .../rtm/world/RTMChunkManager.java.pm.patch | 22 +++ 56 files changed, 1317 insertions(+), 4 deletions(-) create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/NGTCore.java.pm.patch create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/io/NGTLog.java.pm.patch create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/RecipeManager.java.pm.patch create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/ShapedRecipes55.java.pm.patch create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ModelLoader.java.pm.patch create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ObjModel.java.pm.patch create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/PolygonModel.java.pm.patch create mode 100644 src/main/ngtlib-patches/jp/ngt/ngtlib/util/PermissionManager.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/RTMItem.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/RTMRecipe.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMachineBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMechanism.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityOrnament.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/electric/TileEntityConnectorBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/electric/TileEntitySignal.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/ai/EntityAITravelByTrain.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/npc/EntityNPC.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityBogie.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityTrainBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/train/parts/EntityCargoWithModel.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityTrolley.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/RenderVehicleBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/event/RTMEventHandler.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/item/ItemPaintTool.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/ModelPackManager.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/cfg/ResourceConfig.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackConstructThread.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackLoadThread.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetNPC.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetSignal.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetTrain.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetVehicleBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ResourceSet.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/modelpack/state/ResourceState.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/rail/BlockLargeRailBase.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/rail/BlockMarker.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/rail/RenderMarkerBlock.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/rail/util/RailMaker.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/rail/util/SwitchType.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/render/ModelObject.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/render/PartsRenderer.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/render/RTMRenderers.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/sound/MovingSoundMaker.java.pm.patch create mode 100644 src/main/rtm-patches/jp/ngt/rtm/world/RTMChunkManager.java.pm.patch diff --git a/.editorconfig b/.editorconfig index dc3ce7f7..decf12d9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,6 @@ insert_final_newline = true [*.patch] trim_trailing_whitespace = false insert_final_newline = false + +[*.java] +indent_size = 3 diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index 8f1a3b79..a55e7a17 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/.patching-mods/ngtlib.patching-mod/modified-classes.txt b/.patching-mods/ngtlib.patching-mod/modified-classes.txt index e69de29b..2b185b69 100644 --- a/.patching-mods/ngtlib.patching-mod/modified-classes.txt +++ b/.patching-mods/ngtlib.patching-mod/modified-classes.txt @@ -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 diff --git a/.patching-mods/ngtlib.patching-mod/on-vcs.txt b/.patching-mods/ngtlib.patching-mod/on-vcs.txt index c77e2a4e..6b0579e3 100644 --- a/.patching-mods/ngtlib.patching-mod/on-vcs.txt +++ b/.patching-mods/ngtlib.patching-mod/on-vcs.txt @@ -1 +1 @@ -PATCHES \ No newline at end of file +PATCHES diff --git a/.patching-mods/rtm.patching-mod/modified-classes.txt b/.patching-mods/rtm.patching-mod/modified-classes.txt index e69de29b..33df16ab 100644 --- a/.patching-mods/rtm.patching-mod/modified-classes.txt +++ b/.patching-mods/rtm.patching-mod/modified-classes.txt @@ -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 diff --git a/.patching-mods/rtm.patching-mod/on-vcs.txt b/.patching-mods/rtm.patching-mod/on-vcs.txt index c77e2a4e..6b0579e3 100644 --- a/.patching-mods/rtm.patching-mod/on-vcs.txt +++ b/.patching-mods/rtm.patching-mod/on-vcs.txt @@ -1 +1 @@ -PATCHES \ No newline at end of file +PATCHES diff --git a/build.gradle.kts b/build.gradle.kts index 84a74552..9c427ac1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -119,8 +119,8 @@ val reprocessResources by tasks.getting(Copy::class) { val runClient by tasks.getting(JavaExec::class) { environment("fml.coreMods.load", "com.anatawa12.fixRtm.asm.FixRtmCorePlugin") - /* systemProperties["legacy.debugClassLoading"] = "true" + /* systemProperties["legacy.debugClassLoadingSave"] = "true" // */ //* @@ -160,6 +160,7 @@ val generateJavaStab by tasks.creating(GenerateJavaStab::class) { } tasks.compileKotlin { + dependsOn(tasks.generateUnmodifieds.get()) dependsOn(generateJavaStab) source(generateJavaStab.generatedDir!!) include("**/*.java") diff --git a/settings.gradle.kts b/settings.gradle.kts index 05901c33..be47300d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,4 +22,6 @@ buildscript { isChanging = true } } + configurations.classpath.get().resolutionStrategy.cacheDynamicVersionsFor(10, "minutes") + configurations.classpath.get().resolutionStrategy.cacheChangingModulesFor(10, "minutes") } diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/NGTCore.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/NGTCore.java.pm.patch new file mode 100644 index 00000000..848cada4 --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/NGTCore.java.pm.patch @@ -0,0 +1,20 @@ +--- a/jp/ngt/ngtlib/NGTCore.java ++++ b/jp/ngt/ngtlib/NGTCore.java +@@ -94,16 +94,16 @@ + NETWORK_WRAPPER.registerMessage(PacketNoticeHandlerClient.class, PacketNotice.class, 0, Side.CLIENT); + NETWORK_WRAPPER.registerMessage(PacketNoticeHandlerServer.class, PacketNotice.class, 1, Side.SERVER); + NETWORK_WRAPPER.registerMessage(PacketNBTHandlerClient.class, PacketNBT.class, 2, Side.CLIENT); + NETWORK_WRAPPER.registerMessage(PacketNBTHandlerServer.class, PacketNBT.class, 3, Side.SERVER); + NETWORK_WRAPPER.registerMessage(PacketProtection.class, PacketProtection.class, 4, Side.CLIENT); ++ MinecraftForge.EVENT_BUS.register(RecipeManager.INSTANCE); + } + + @EventHandler + public void init(FMLInitializationEvent event) { + proxy.init(); +- MinecraftForge.EVENT_BUS.register(RecipeManager.INSTANCE); + MinecraftForge.EVENT_BUS.register(new NGTEventHandler()); + Usage.INSTANCE.add(protection_key, -1, "usage.item.protection_key"); + + try { + PermissionManager.INSTANCE.load(); diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/io/NGTLog.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/io/NGTLog.java.pm.patch new file mode 100644 index 00000000..0df2e3b9 --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/io/NGTLog.java.pm.patch @@ -0,0 +1,39 @@ +--- a/jp/ngt/ngtlib/io/NGTLog.java ++++ b/jp/ngt/ngtlib/io/NGTLog.java +@@ -13,25 +13,33 @@ + import org.apache.logging.log4j.Level; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + + public final class NGTLog { +- private static final Logger logger = LogManager.getLogger("NGT"); ++ public static final Logger logger = LogManager.getLogger("NGT"); + private static final List startTimes = new ArrayList(); + + public static void debug(String par1) { +- debug(par1); ++ debug(par1, new Object[0]); + } + + public static void debug(String par1, Object... par2) { ++ _log_(par1, par2, Level.INFO); ++ } ++ ++ public static void trace(String par1, Object... par2) { ++ _log_(par1, par2, Level.TRACE); ++ } ++ ++ public static void _log_(String par1, Object[] par2, Level par3) { + try { + String s = par1; + if (par2 != null && par2.length > 0) { + s = String.format(par1, par2); + } + +- logger.log(Level.INFO, s); ++ logger.log(par3, s); + } catch (Exception var3) { + ; + } + + } diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/RecipeManager.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/RecipeManager.java.pm.patch new file mode 100644 index 00000000..0ae82d6c --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/RecipeManager.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/ngtlib/item/craft/RecipeManager.java ++++ b/jp/ngt/ngtlib/item/craft/RecipeManager.java +@@ -72,11 +72,11 @@ + for(int i1 = 0; i1 < j * k; ++i1) { + char c0 = s.charAt(i1); + if (map.containsKey(Character.valueOf(c0))) { + aitemstack[i1] = ((ItemStack)map.get(Character.valueOf(c0))).copy(); + } else { +- aitemstack[i1] = null; ++ aitemstack[i1] = ItemStack.EMPTY; + } + } + + ShapedRecipes55 shapedrecipes55 = new ShapedRecipes55(j, k, aitemstack, output); + INSTANCE.addRecipeToManager(shapedrecipes55); diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/ShapedRecipes55.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/ShapedRecipes55.java.pm.patch new file mode 100644 index 00000000..9cdb0269 --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/item/craft/ShapedRecipes55.java.pm.patch @@ -0,0 +1,31 @@ +--- a/jp/ngt/ngtlib/item/craft/ShapedRecipes55.java ++++ b/jp/ngt/ngtlib/item/craft/ShapedRecipes55.java +@@ -99,12 +99,12 @@ + private boolean itemMatches(ItemStack target, ItemStack inInventory) { + if ((inInventory != null || target == null) && (inInventory == null || target != null)) { + if (target.getItem() == Items.DYE) { + return ItemUtil.isItemEqual(target, inInventory); + } else { +- int[] aint = OreDictionary.getOreIDs(target); +- int[] aint1 = OreDictionary.getOreIDs(inInventory); ++ int[] aint = com.anatawa12.fixRtm.ngtlib.item.craft.OreDictionaryUtil.getOreIDs(target); ++ int[] aint1 = com.anatawa12.fixRtm.ngtlib.item.craft.OreDictionaryUtil.getOreIDs(inInventory); + if (aint.length > 0 && aint1.length > 0) { + for(int i = 0; i < aint.length; ++i) { + for(int j = 0; j < aint1.length; ++j) { + if (aint[i] == aint1[j]) { + return true; +@@ -112,12 +112,12 @@ + } + } + + return false; + } else { +- return ItemUtil.isItemEqual(target, inInventory); + } ++ return ItemUtil.isItemEqual(target, inInventory); + } + } else { + return false; + } + } diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ModelLoader.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ModelLoader.java.pm.patch new file mode 100644 index 00000000..5cc1a44c --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ModelLoader.java.pm.patch @@ -0,0 +1,17 @@ +--- a/jp/ngt/ngtlib/renderer/model/ModelLoader.java ++++ b/jp/ngt/ngtlib/renderer/model/ModelLoader.java +@@ -17,10 +17,14 @@ + public static PolygonModel loadModel(String path, VecAccuracy par1, Object... args) { + return loadModel(new ResourceLocationCustom("minecraft", path), par1, args); + } + + public static PolygonModel loadModel(ResourceLocation resource, VecAccuracy par1, Object... args) { ++ return com.anatawa12.fixRtm.ngtlib.renderer.model.ModelLoaderKt.loadModel(resource, par1, args); ++ } ++ ++ public static PolygonModel loadModel__NGTLIB(ResourceLocation resource, VecAccuracy par1, Object... args) { + String s = resource.toString(); + + try { + InputStream inputstream = NGTFileLoader.getInputStream(resource); + if (FileType.OBJ.match(resource.getPath())) { diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ObjModel.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ObjModel.java.pm.patch new file mode 100644 index 00000000..223132b6 --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/ObjModel.java.pm.patch @@ -0,0 +1,16 @@ +--- a/jp/ngt/ngtlib/renderer/model/ObjModel.java ++++ b/jp/ngt/ngtlib/renderer/model/ObjModel.java +@@ -256,13 +256,9 @@ + + public FileType getType() { + return FileType.OBJ; + } + +- public int getDrawMode() { +- return 4; +- } +- + public Map getMaterials() { + return this.materials; + } + } diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/PolygonModel.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/PolygonModel.java.pm.patch new file mode 100644 index 00000000..141b83f7 --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/renderer/model/PolygonModel.java.pm.patch @@ -0,0 +1,80 @@ +--- a/jp/ngt/ngtlib/renderer/model/PolygonModel.java ++++ b/jp/ngt/ngtlib/renderer/model/PolygonModel.java +@@ -15,11 +15,11 @@ + + @SideOnly(Side.CLIENT) + public abstract class PolygonModel implements IModelNGT { + protected String fileName; + protected int drawMode; +- protected VecAccuracy accuracy; ++ public VecAccuracy accuracy; + protected float[] sizeBox = new float[6]; + public final List vertices = new ArrayList(1024); + public final List groupObjects = new ArrayList(16); + protected GroupObject currentGroupObject; + int lineCount; +@@ -93,11 +93,11 @@ + + public final float[] getSize() { + return this.sizeBox; + } + +- public void renderAll(boolean smoothing) { ++ public final void renderAll(boolean smoothing) { + if (smoothing) { + GL11.glShadeModel(7425); + } + + NGTTessellator ngttessellator = NGTTessellator.instance; +@@ -108,18 +108,18 @@ + GL11.glShadeModel(7424); + } + + } + +- public void tessellateAll(NGTTessellator tessellator, boolean smoothing) { ++ public final void tessellateAll(NGTTessellator tessellator, boolean smoothing) { + for(GroupObject groupobject : this.groupObjects) { + groupobject.render(tessellator, smoothing); + } + + } + +- public void renderOnly(boolean smoothing, String... groupNames) { ++ public final void renderOnly(boolean smoothing, String... groupNames) { + if (smoothing) { + GL11.glShadeModel(7425); + } + + for(GroupObject groupobject : this.groupObjects) { +@@ -134,11 +134,11 @@ + GL11.glShadeModel(7424); + } + + } + +- public void renderPart(boolean smoothing, String partName) { ++ public final void renderPart(boolean smoothing, String partName) { + if (smoothing) { + GL11.glShadeModel(7425); + } + + for(GroupObject groupobject : this.groupObjects) { +@@ -152,15 +152,15 @@ + GL11.glShadeModel(7424); + } + + } + +- public int getDrawMode() { ++ public final int getDrawMode() { + return this.drawMode; + } + +- public List getGroupObjects() { ++ public final List getGroupObjects() { + return this.groupObjects; + } + + protected final float getFloat(String s) { + try { diff --git a/src/main/ngtlib-patches/jp/ngt/ngtlib/util/PermissionManager.java.pm.patch b/src/main/ngtlib-patches/jp/ngt/ngtlib/util/PermissionManager.java.pm.patch new file mode 100644 index 00000000..6eaacf1a --- /dev/null +++ b/src/main/ngtlib-patches/jp/ngt/ngtlib/util/PermissionManager.java.pm.patch @@ -0,0 +1,32 @@ +--- a/jp/ngt/ngtlib/util/PermissionManager.java ++++ b/jp/ngt/ngtlib/util/PermissionManager.java +@@ -126,10 +126,16 @@ + } + + } + + public boolean hasPermission(ICommandSender player, String category) { ++ if (com.anatawa12.fixRtm.asm.config.MainConfig.addNegativePermissionEnabled) { ++ if (this.getPlayerList("negative.".concat(category)).contains(player.getName())) { ++ NGTLog.sendChatMessageToAll("%s need permission (%s).", player.getName(), category); ++ return false; ++ } ++ } + if (this.isOp(player)) { + return true; + } else { + List list = this.getPlayerList(category); + if (!list.contains(player.getName()) && !list.contains(ALL)) { +@@ -142,10 +148,12 @@ + } + + public boolean isOp(ICommandSender player) { + if (!DEBUG_MODE && !NGTUtil.isSMP()) { + return true; ++ } else if (player == null) { ++ return true; + } else { + if (player instanceof EntityPlayerMP) { + String[] astring = ((EntityPlayerMP)player).server.getPlayerList().getOppedPlayerNames(); + + for(String s : astring) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/RTMItem.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/RTMItem.java.pm.patch new file mode 100644 index 00000000..13072c08 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/RTMItem.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/RTMItem.java ++++ b/jp/ngt/rtm/RTMItem.java +@@ -135,11 +135,11 @@ + registerItemModels(installedObject, "istl_obj_", ItemInstalledObject.IstlObjType.values()); + registerItemModel(itemtrain, 0, "item_train_0"); + registerItemModel(itemtrain, 1, "item_train_1"); + registerItemModel(itemtrain, 2, "item_train_2"); + registerItemModel(itemtrain, 3, "item_train_3"); +- registerItemModel(itemtrain, 127, "item_train_127"); ++ registerItemModel(itemtrain, 127, "item_train_fixrtm_test"); + registerItemModel(itemMotorman, 0, "item_npc_0"); + registerItemModel(itemMotorman, 1, "item_npc_1"); + registerItemModel(itemCargo, 0, "cargo_0"); + registerItemModel(itemCargo, 1, "cargo_1"); + registerItemModel(itemCargo, 2, "cargo_2"); diff --git a/src/main/rtm-patches/jp/ngt/rtm/RTMRecipe.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/RTMRecipe.java.pm.patch new file mode 100644 index 00000000..cce5f246 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/RTMRecipe.java.pm.patch @@ -0,0 +1,24 @@ +--- a/jp/ngt/rtm/RTMRecipe.java ++++ b/jp/ngt/rtm/RTMRecipe.java +@@ -125,15 +125,15 @@ + RecipeManager.addRecipe(new ItemStack(RTMItem.rifle, 1, 0), new Object[]{"SSSM ", " WW", " ", " ", " ", 'S', itemstack6, 'W', Blocks.PLANKS, 'M', new ItemStack(RTMItem.magazine_rifle, 1, 0)}).setRegistryName(new ResourceLocation("rtm", "rifle")); + RecipeManager.addRecipe(new ItemStack(RTMItem.autoloading_rifle, 1, 0), new Object[]{"SSSS ", " M II", " ", " ", " ", 'S', itemstack6, 'I', itemstack, 'M', new ItemStack(RTMItem.magazine_alr, 1, 0)}).setRegistryName(new ResourceLocation("rtm", "autoloading_rifle")); + RecipeManager.addRecipe(new ItemStack(RTMItem.sniper_rifle, 1, 0), new Object[]{" SS ", "SSSS ", " M II", " ", " ", 'S', itemstack6, 'I', itemstack, 'M', new ItemStack(RTMItem.magazine_sr, 1, 0)}).setRegistryName(new ResourceLocation("rtm", "sniper_rifle")); + RecipeManager.addRecipe(new ItemStack(RTMItem.smg, 1, 0), new Object[]{"SSSS ", " M II", " ", " ", " ", 'S', itemstack6, 'I', itemstack, 'M', new ItemStack(RTMItem.magazine_smg, 1, 0)}).setRegistryName(new ResourceLocation("rtm", "smg")); + RecipeManager.addRecipe(new ItemStack(RTMItem.amr, 1, 0), new Object[]{" SS ", "SSSS ", " M II", " ", " ", 'S', itemstack6, 'I', itemstack, 'M', new ItemStack(RTMItem.magazine_amr, 1, 0)}).setRegistryName(new ResourceLocation("rtm", "amr")); +- RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_handgun, new ItemStack(RTMItem.bullet, 1, 4))); +- RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_rifle, new ItemStack(RTMItem.bullet, 1, 12))); +- RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_alr, new ItemStack(RTMItem.bullet, 1, 12))); +- RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_sr, new ItemStack(RTMItem.bullet, 1, 12))); +- RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_smg, new ItemStack(RTMItem.bullet, 1, 4))); +- RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_amr, new ItemStack(RTMItem.bullet, 1, 16))); ++ RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_handgun, new ItemStack(RTMItem.bullet, 1, 4)).setRegistryName(new ResourceLocation("rtm:magazine_handgun"))); ++ RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_rifle, new ItemStack(RTMItem.bullet, 1, 12)).setRegistryName(new ResourceLocation("rtm:magazine_rifle"))); ++ RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_alr, new ItemStack(RTMItem.bullet, 1, 12)).setRegistryName(new ResourceLocation("rtm:magazine_alr"))); ++ RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_sr, new ItemStack(RTMItem.bullet, 1, 12)).setRegistryName(new ResourceLocation("rtm:magazine_sr"))); ++ RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_smg, new ItemStack(RTMItem.bullet, 1, 4)).setRegistryName(new ResourceLocation("rtm:magazine_smg"))); ++ RecipeManager.INSTANCE.addRecipeToManager(new RepairRecipe(RTMItem.magazine_amr, new ItemStack(RTMItem.bullet, 1, 16)).setRegistryName(new ResourceLocation("rtm:magazine_amr"))); + RecipeManager.addRecipe(new ItemStack(RTMItem.material, 64, 4), new Object[]{"RG ", "GG ", " ", " ", " ", 'R', new ItemStack(Items.REDSTONE), 'G', new ItemStack(Items.GUNPOWDER)}).setRegistryName(new ResourceLocation("rtm", "gun_powder")); + GameRegistry.addSmelting(new ItemStack(Items.COAL, 1, 0), new ItemStack(RTMItem.coke), 0.25F); + } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMachineBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMachineBase.java.pm.patch new file mode 100644 index 00000000..dd6ec946 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMachineBase.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/block/tileentity/TileEntityMachineBase.java ++++ b/jp/ngt/rtm/block/tileentity/TileEntityMachineBase.java +@@ -112,6 +112,12 @@ + public boolean closeGui(ResourceState par1) { + return true; + } + + protected abstract ResourceType getSubType(); ++ ++ @Override ++ public void addInfoToCrashReport(net.minecraft.crash.CrashReportCategory reportCategory) { ++ super.addInfoToCrashReport(reportCategory); ++ com.anatawa12.fixRtm.rtm.block.tileentity.TileEntityMachineBaseKt.addInfoToCrashReport(this, reportCategory); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMechanism.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMechanism.java.pm.patch new file mode 100644 index 00000000..653e8edf --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityMechanism.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/block/tileentity/TileEntityMechanism.java ++++ b/jp/ngt/rtm/block/tileentity/TileEntityMechanism.java +@@ -535,6 +535,12 @@ + } + + public boolean closeGui(ResourceState par1) { + return true; + } ++ ++ @Override ++ public void addInfoToCrashReport(net.minecraft.crash.CrashReportCategory reportCategory) { ++ super.addInfoToCrashReport(reportCategory); ++ com.anatawa12.fixRtm.rtm.block.tileentity.TileEntityMechanismKt.addInfoToCrashReport(this, reportCategory); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityOrnament.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityOrnament.java.pm.patch new file mode 100644 index 00000000..a710998f --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityOrnament.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/block/tileentity/TileEntityOrnament.java ++++ b/jp/ngt/rtm/block/tileentity/TileEntityOrnament.java +@@ -85,6 +85,12 @@ + public boolean closeGui(ResourceState par1) { + return true; + } + + protected abstract ResourceType getSubType(); ++ ++ @Override ++ public void addInfoToCrashReport(net.minecraft.crash.CrashReportCategory reportCategory) { ++ super.addInfoToCrashReport(reportCategory); ++ com.anatawa12.fixRtm.rtm.block.tileentity.TileEntityOrnamentKt.addInfoToCrashReport(this, reportCategory); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/electric/TileEntityConnectorBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/electric/TileEntityConnectorBase.java.pm.patch new file mode 100644 index 00000000..bc7630cb --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/electric/TileEntityConnectorBase.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/electric/TileEntityConnectorBase.java ++++ b/jp/ngt/rtm/electric/TileEntityConnectorBase.java +@@ -108,6 +108,12 @@ + public ResourceState getResourceState() { + return this.state; + } + + protected abstract ResourceType getSubType(); ++ ++ @Override ++ public void addInfoToCrashReport(net.minecraft.crash.CrashReportCategory reportCategory) { ++ super.addInfoToCrashReport(reportCategory); ++ com.anatawa12.fixRtm.rtm.electric.TileEntityConnectorBaseKt.addInfoToCrashReport(this, reportCategory); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/electric/TileEntitySignal.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/electric/TileEntitySignal.java.pm.patch new file mode 100644 index 00000000..c02d4d2c --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/electric/TileEntitySignal.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/electric/TileEntitySignal.java ++++ b/jp/ngt/rtm/electric/TileEntitySignal.java +@@ -167,6 +167,12 @@ + } + + public ResourceStateWithBlock getResourceState() { + return this.state; + } ++ ++ @Override ++ public void addInfoToCrashReport(net.minecraft.crash.CrashReportCategory reportCategory) { ++ super.addInfoToCrashReport(reportCategory); ++ com.anatawa12.fixRtm.rtm.electric.TileEntitySignalKt.addInfoToCrashReport(this, reportCategory); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/ai/EntityAITravelByTrain.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/ai/EntityAITravelByTrain.java.pm.patch new file mode 100644 index 00000000..28f2d761 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/ai/EntityAITravelByTrain.java.pm.patch @@ -0,0 +1,19 @@ +--- a/jp/ngt/rtm/entity/ai/EntityAITravelByTrain.java ++++ b/jp/ngt/rtm/entity/ai/EntityAITravelByTrain.java +@@ -51,12 +51,14 @@ + return this.activeTask.shouldExecute(); + } + } + + private void dismount() { +- this.npc.startRiding((Entity)null); +- ((EntityFloor)this.npc.getRidingEntity()).onDismount(this.npc); ++ EntityFloor floor = ((EntityFloor)this.npc.getRidingEntity()); ++ assert floor != null; ++ this.npc.dismountRidingEntity(); ++ floor.onDismount(this.npc); + } + + public boolean shouldContinueExecuting() { + boolean flag = this.activeTask.shouldContinueExecuting(); + if (!flag) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/npc/EntityNPC.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/npc/EntityNPC.java.pm.patch new file mode 100644 index 00000000..e8e9353e --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/npc/EntityNPC.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/entity/npc/EntityNPC.java ++++ b/jp/ngt/rtm/entity/npc/EntityNPC.java +@@ -402,6 +402,12 @@ + return this.state; + } + + public void setSwingingArms(boolean swingingArms) { + } ++ ++ @Override ++ public void addEntityCrashInfo(net.minecraft.crash.CrashReportCategory category) { ++ super.addEntityCrashInfo(category); ++ com.anatawa12.fixRtm.rtm.entity.npc.EntityNPCKt.addEntityCrashInfo(this, category); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityBogie.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityBogie.java.pm.patch new file mode 100644 index 00000000..d06e63c8 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityBogie.java.pm.patch @@ -0,0 +1,35 @@ +--- a/jp/ngt/rtm/entity/train/EntityBogie.java ++++ b/jp/ngt/rtm/entity/train/EntityBogie.java +@@ -297,11 +297,13 @@ + } else { + boolean flag = false; + } + + if (this.getTrain() == null) { ++ if (!this.world.isRemote) { + this.setDead(); ++ } + } + + } + + public void onBogieUpdate() { +@@ -584,6 +586,18 @@ + } + + public int getProhibitedAction() { + return 1; + } ++ ++ @Override ++ public void onRemovedFromWorld() { ++ super.onRemovedFromWorld(); ++ com.anatawa12.fixRtm.rtm.entity.train.EntityBogieKt.onRemovedFromWorld(this); ++ } ++ ++ @Override ++ public void addEntityCrashInfo(net.minecraft.crash.CrashReportCategory category) { ++ super.addEntityCrashInfo(category); ++ com.anatawa12.fixRtm.rtm.entity.train.EntityBogieKt.addEntityCrashInfo(this, category); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityTrainBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityTrainBase.java.pm.patch new file mode 100644 index 00000000..d87598e7 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/train/EntityTrainBase.java.pm.patch @@ -0,0 +1,75 @@ +--- a/jp/ngt/rtm/entity/train/EntityTrainBase.java ++++ b/jp/ngt/rtm/entity/train/EntityTrainBase.java +@@ -72,18 +72,19 @@ + private static final int[] PANTO_POS_ZERO = new int[]{0, 0}; + private Ticket ticket; + private final Set loadedChunks; + private int prevChunkCoordX; + private int prevChunkCoordZ; ++ private int prevChunkLoaderRadius; + + public EntityTrainBase(World world) { + super(world); + this.bogieController = new BogieController(); + this.brakeCount = 72; + this.onRail = true; + this.brakeAirCount = 2880; +- this.loadedChunks = new HashSet(); ++ this.loadedChunks = new java.util.LinkedHashSet(); + this.setSize(2.75F, 1.1875F); + this.noClip = true; + } + + public EntityTrainBase(World world, String s) { +@@ -890,10 +891,11 @@ + this.releaseTicket(); + } + + this.prevChunkCoordX = this.chunkCoordX; + this.prevChunkCoordZ = this.chunkCoordZ; ++ this.prevChunkLoaderRadius = this.getVehicleState(TrainState.TrainStateType.ChunkLoader); + } + + public boolean isChunkLoaderEnable() { + return this.getVehicleState(TrainState.TrainStateType.ChunkLoader) > 0; + } +@@ -910,11 +912,10 @@ + private boolean requestTicket() { + Ticket ticket = RTMChunkManager.INSTANCE.getNewTicket(this.world, Type.ENTITY); + if (ticket != null) { + int i = this.getVehicleState(TrainState.TrainStateType.ChunkLoader); + ticket.getModData(); +- ticket.setChunkListDepth(i); + ticket.bindEntity(this); + this.setChunkTicket(ticket); + return true; + } else { + NGTLog.debug("[RTM] Failed to get ticket (Chunk Loader)"); +@@ -938,20 +939,26 @@ + if (!this.world.isRemote) { + if (this.ticket == null && !this.requestTicket()) { + return; + } + +- if (x != this.prevChunkCoordX || z != this.prevChunkCoordZ) { ++ if (this.getVehicleState(TrainState.TrainStateType.ChunkLoader) != this.prevChunkLoaderRadius ++ || x != this.prevChunkCoordX || z != this.prevChunkCoordZ) { + this.setupChunks(x, z); + } + ++ int chunkLoadSquareRadius = this.getVehicleState(TrainState.TrainStateType.ChunkLoader) * 2 + 1; ++ this.ticket.setChunkListDepth(Math.min(chunkLoadSquareRadius * chunkLoadSquareRadius, ForgeChunkManager.getMaxChunkDepthFor("rtm"))); ++ + for(ChunkPos chunkpos : this.loadedChunks) { + ForgeChunkManager.forceChunk(this.ticket, chunkpos); ++ ForgeChunkManager.reorderChunk(this.ticket, chunkpos); + } + + ChunkPos chunkpos1 = new ChunkPos(x, z); + ForgeChunkManager.forceChunk(this.ticket, chunkpos1); ++ ForgeChunkManager.reorderChunk(this.ticket, chunkpos1); + } + + } + + private void setupChunks(int xChunk, int zChunk) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/train/parts/EntityCargoWithModel.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/train/parts/EntityCargoWithModel.java.pm.patch new file mode 100644 index 00000000..b3c1e877 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/train/parts/EntityCargoWithModel.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/entity/train/parts/EntityCargoWithModel.java ++++ b/jp/ngt/rtm/entity/train/parts/EntityCargoWithModel.java +@@ -79,6 +79,12 @@ + this.updateResourceState(); + return true; + } + + protected abstract ResourceType getSubType(); ++ ++ @Override ++ public void addEntityCrashInfo(net.minecraft.crash.CrashReportCategory category) { ++ super.addEntityCrashInfo(category); ++ com.anatawa12.fixRtm.rtm.entity.train.parts.EntityCargoWithModelKt.addEntityCrashInfo(this, category); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityTrolley.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityTrolley.java.pm.patch new file mode 100644 index 00000000..f6611b5e --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityTrolley.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/entity/vehicle/EntityTrolley.java ++++ b/jp/ngt/rtm/entity/vehicle/EntityTrolley.java +@@ -161,6 +161,12 @@ + } + } + + return true; + } ++ ++ @Override ++ public void addEntityCrashInfo(net.minecraft.crash.CrashReportCategory category) { ++ super.addEntityCrashInfo(category); ++ com.anatawa12.fixRtm.rtm.entity.vehicle.EntityTrolleyKt.addEntityCrashInfo(this, category); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.java.pm.patch new file mode 100644 index 00000000..ebf35ee8 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.java.pm.patch @@ -0,0 +1,36 @@ +--- a/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.java ++++ b/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.java +@@ -269,12 +269,13 @@ + try { + ModelSetBase modelsetbase = (ModelSetBase)this.getResourceState().getResourceSet(); + axisalignedbb = modelsetbase.getCollisionObj().getSizeBox(); + } catch (NullPointerException nullpointerexception) { + nullpointerexception.printStackTrace(); +- axisalignedbb = new AxisAlignedBB(-1.5D, 0.0D, -2.0D, 1.5D, 3.0D, 2.0D); + } ++ if (axisalignedbb == null) ++ axisalignedbb = new AxisAlignedBB(-1.5D, 0.0D, -2.0D, 1.5D, 3.0D, 2.0D); + + Vec3 vec3 = PooledVec3.create(ridingEntity.posX - this.posX, ridingEntity.posY - this.posY, ridingEntity.posZ - this.posZ); + vec3 = vec3.rotateAroundY(-this.rotationYaw); + float f = NGTMath.wrapAngle(-passenger.rotationYaw - this.rotationYaw); + double d0 = (double)f >= 0.0D ? axisalignedbb.maxX + 0.5D : axisalignedbb.minX - 0.5D; +@@ -544,6 +545,18 @@ + } + + public VehicleNGTO getNGTO() { + return null; + } ++ ++ @Override ++ public void onRemovedFromWorld() { ++ super.onRemovedFromWorld(); ++ com.anatawa12.fixRtm.rtm.entity.vehicle.EntityVehicleBaseKt.onRemovedFromWorld(this); ++ } ++ ++ @Override ++ public void addEntityCrashInfo(net.minecraft.crash.CrashReportCategory category) { ++ super.addEntityCrashInfo(category); ++ com.anatawa12.fixRtm.rtm.entity.vehicle.EntityVehicleBaseKt.addEntityCrashInfo(this, category); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/RenderVehicleBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/RenderVehicleBase.java.pm.patch new file mode 100644 index 00000000..bde1d9a5 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/RenderVehicleBase.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/entity/vehicle/RenderVehicleBase.java ++++ b/jp/ngt/rtm/entity/vehicle/RenderVehicleBase.java +@@ -51,11 +51,11 @@ + GL11.glRotatef(f, 0.0F, 1.0F, 0.0F); + float f1 = vehicle.prevRotationPitch + (vehicle.rotationPitch - vehicle.prevRotationPitch) * par9; + GL11.glRotatef(-f1, 1.0F, 0.0F, 0.0F); + float f2 = vehicle.prevRotationRoll + (vehicle.rotationRoll - vehicle.prevRotationRoll) * par9; + GL11.glRotatef(f2, 0.0F, 0.0F, 1.0F); +- if (Minecraft.getMinecraft().gameSettings.showDebugInfo) { ++ if (Minecraft.getMinecraft().getRenderManager().isDebugBoundingBox()) { + this.debugCollision(vehicle); + } + + VehicleNGTO vehiclengto = vehicle.getNGTO(); + if (vehiclengto != null) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.java.pm.patch new file mode 100644 index 00000000..967ae8d1 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.java.pm.patch @@ -0,0 +1,45 @@ +--- a/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.java ++++ b/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.java +@@ -161,41 +161,11 @@ + } + + } + + public static boolean trackingVehicle(Entity par1) { +- if (!(par1 instanceof EntityVehicleBase) && !(par1 instanceof EntityBogie)) { +- throw new IllegalArgumentException("This entity is not Vehicle"); +- } else { +- if (par1.world instanceof WorldServer) { +- EntityTracker entitytracker = ((WorldServer)par1.world).getEntityTracker(); +- Set set = getTrackedEntities(entitytracker); +- if (set != null) { +- VehicleTrackerEntry vehicletrackerentry = new VehicleTrackerEntry(par1); +- EntityTrackerEntry entitytrackerentry = null; +- +- for(EntityTrackerEntry entitytrackerentry1 : set) { +- if (entitytrackerentry1 != null && entitytrackerentry1.equals(vehicletrackerentry)) { +- if (!(entitytrackerentry1 instanceof VehicleTrackerEntry)) { +- entitytrackerentry = entitytrackerentry1; +- } +- break; +- } +- } +- +- if (entitytrackerentry != null) { +- set.remove(entitytrackerentry); +- vehicletrackerentry.setPlayers(entitytrackerentry.trackingPlayers); +- set.add(vehicletrackerentry); +- return true; +- } +- } +- } +- +- NGTLog.debug("Failed to change tracking entry (VTE)"); +- return false; +- } ++ return true; // not used. + } + + protected static Set getTrackedEntities(EntityTracker tracker) { + return (Set)NGTUtil.getField(EntityTracker.class, tracker, new String[]{"entries", "field_72793_b"}); + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.java.pm.patch new file mode 100644 index 00000000..f2efdfd2 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.java ++++ b/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.java +@@ -57,6 +57,11 @@ + protected void readEntityFromNBT(NBTTagCompound compound) { + } + + protected void writeEntityToNBT(NBTTagCompound compound) { + } ++ ++ @Override ++ public net.minecraft.util.math.AxisAlignedBB getEntityBoundingBox() { ++ return this.parent.getEntityBoundingBox(); ++ } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/event/RTMEventHandler.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/event/RTMEventHandler.java.pm.patch new file mode 100644 index 00000000..ffa0bad0 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/event/RTMEventHandler.java.pm.patch @@ -0,0 +1,23 @@ +--- a/jp/ngt/rtm/event/RTMEventHandler.java ++++ b/jp/ngt/rtm/event/RTMEventHandler.java +@@ -15,15 +15,18 @@ + import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; + + public final class RTMEventHandler { + @SubscribeEvent +- public void onPlayerLoggedIn(PlayerLoggedInEvent event) { ++ public void onServerConnectionFromClient(net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent event) { + if (NGTUtil.isSMP() || NGTUtil.openedLANWorld()) { +- ModelPackManager.INSTANCE.sendModelSetsToClient((EntityPlayerMP)event.player); ++ ModelPackManager.INSTANCE.sendModelSetsToClient(((net.minecraft.network.NetHandlerPlayServer)event.getHandler()).player); + } ++ } + ++ @SubscribeEvent ++ public void onPlayerLoggedIn(PlayerLoggedInEvent event) { + DecorationStore.INSTANCE.loadModels(event.player.getEntityWorld()); + SpeakerSounds.getInstance(true).syncSoundList(); + } + + @SubscribeEvent diff --git a/src/main/rtm-patches/jp/ngt/rtm/item/ItemPaintTool.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/item/ItemPaintTool.java.pm.patch new file mode 100644 index 00000000..db5af08b --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/item/ItemPaintTool.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/item/ItemPaintTool.java ++++ b/jp/ngt/rtm/item/ItemPaintTool.java +@@ -72,11 +72,11 @@ + + public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) { + if (living instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer)living; + float f = entityplayer.capabilities.isCreativeMode ? 5.0F : 4.5F; +- RayTraceResult raytraceresult = entityplayer.rayTrace((double)f, 0.0F); ++ RayTraceResult raytraceresult = com.anatawa12.fixRtm.UtilsKt.rayTraceBothSide(entityplayer, (double)f, 0.0F); + if (raytraceresult != null) { + int i = raytraceresult.getBlockPos().getX(); + int j = raytraceresult.getBlockPos().getY(); + int k = raytraceresult.getBlockPos().getZ(); + float f1 = (float)raytraceresult.hitVec.x - (float)i; diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/ModelPackManager.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/ModelPackManager.java.pm.patch new file mode 100644 index 00000000..b1e35158 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/ModelPackManager.java.pm.patch @@ -0,0 +1,131 @@ +--- a/jp/ngt/rtm/modelpack/ModelPackManager.java ++++ b/jp/ngt/rtm/modelpack/ModelPackManager.java +@@ -48,32 +48,33 @@ + public final class ModelPackManager { + public static final ModelPackManager INSTANCE = new ModelPackManager(); + private static final Pattern SC_INCLUDE = Pattern.compile("//include <(.+)>"); + private static final String[] ENCODING = new String[]{"UTF-8", "SJIS"}; + private final Map typeMap = new HashMap(32); +- private final Map> allModelSetMap = new HashMap>(256); +- private final Map> smpModelSetMap = new HashMap>(256); +- private final Map dummyMap = new HashMap(32); ++ public final Map> allModelSetMap = new HashMap>(256); ++ public final Map> smpModelSetMap = new HashMap>(256); ++ public final Map dummyMap = new HashMap(32); ++ public final java.util.concurrent.locks.ReadWriteLock modelSetMapLock = new java.util.concurrent.locks.ReentrantReadWriteLock(); + public final List unconstructSets = new ArrayList(256); + private final Map modelCache = new HashMap(128); + private final Map> resourceCache = new HashMap>(256); + private final Map scriptCache = new HashMap(64); + public final List fileCache = new ArrayList(1024); + public boolean modelLoaded; + private static final String DEFAULT_DOMAIN = "minecraft"; + + public void load(ModelPackLoadThread par1) { +- List list = NGTFileLoader.findFile((filex) -> { ++ List list = NGTFileLoader.findFile((file) -> { + String s2 = file.getAbsolutePath(); + String s3 = file.getName(); + return !s2.contains("block") && !s2.contains("item") && !s3.endsWith(".json"); + }); + this.fileCache.addAll(list); + NGTLog.debug("[ModelPack] Start searching json"); + par1.setBarValue(0, ProgressStateHolder.ProgressState.SEARCHING_MODEL); + par1.setBarMaxValue(1, 0, "Searching..."); +- List list1 = NGTFileLoader.findFile((filex) -> { ++ List list1 = NGTFileLoader.findFile((file) -> { + String s2 = file.getAbsolutePath(); + String s3 = file.getName(); + return !s2.contains("block") && !s2.contains("item") && s3.endsWith(".json"); + }); + NGTLog.debug("[ModelPack] Find %d json", new Object[]{list1.size()}); +@@ -103,11 +104,11 @@ + } + + NGTLog.debug("[ModelPack] Register %d json", new Object[]{i}); + par1.setBarValue(0, ProgressStateHolder.ProgressState.SEARCHING_RRS); + par1.setBarMaxValue(1, 0, "Loading..."); +- List list2 = NGTFileLoader.findFile((filex) -> { ++ List list2 = NGTFileLoader.findFile((file) -> { + return file.getName().startsWith("rrs_") && file.getName().endsWith(".png"); + }); + par1.setBarValue(0, ProgressStateHolder.ProgressState.LOADING_RRS); + par1.setBarMaxValue(1, list2.size(), ""); + i = 0; +@@ -115,10 +116,11 @@ + for(File file2 : list2) { + ++i; + String s1 = file2.getName(); + par1.setBarValue(1, i, s1); + RRSConfig rrsconfig = new RRSConfig(s1); ++ rrsconfig.file = file2; + this.registerResourceSet(RTMResource.RRS, rrsconfig, "dummy_str"); + } + + TimeTableManager.INSTANCE.load(); + par1.loadFinished = true; +@@ -148,10 +150,11 @@ + public String registerResourceSet(ResourceType type, File file) throws IOException { + for(String s2 : ENCODING) { + try { + String s3 = NGTText.readText(file, false, s2); + ResourceConfig resourceconfig = (ResourceConfig)NGTJson.getObjectFromJson(s3, type.cfgClass); ++ resourceconfig.file = file; + return this.registerResourceSet(type, resourceconfig, s3); + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } +@@ -161,12 +164,21 @@ + + public String registerResourceSet(ResourceType type, ResourceConfig cfg, String origJson) { + cfg.init(); + ResourceSet resourceset = this.getNewModelSet(type, new Class[]{type.cfgClass}, cfg); + if (resourceset != null) { ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("reduceConstructModelLog"); + NGTLog.debug("Registr resource : %s (%s)", new Object[]{cfg.getName(), type.name}); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("reduceConstructModelLog"); ++ NGTLog.trace("Registr resource : %s (%s)", new Object[]{cfg.getName(), type.name}); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("reduceConstructModelLog"); ++ modelSetMapLock.writeLock().lock(); ++ try { + (this.allModelSetMap.get(type)).put(cfg.getName(), resourceset); ++ } finally { ++ modelSetMapLock.writeLock().unlock(); ++ } + this.unconstructSets.add(resourceset); + resourceset.md5 = EncryptedModel.getMD5(EncryptedModel.formatJson(origJson)); + return cfg.getName(); + } else { + throw new ModelPackException("Failed to create ResourceSet", cfg.getName()); +@@ -183,10 +195,11 @@ + NGTLog.debug("[RTM] Send model to client : " + resourceconfig.getName()); + ++j; + } + } + ++ com.anatawa12.fixRtm.network.NetworkHandler.sendPacketEPM(new com.anatawa12.fixRtm.network.SentAllModels(), player); + } + + public void addModelSetName(int count, String typeName, String name) { + assert NGTUtil.isSMP() && !NGTUtil.isServer(); + +@@ -228,16 +241,13 @@ + resourcetype1 = type.parent; + } + + boolean flag = NGTUtil.isSMP() && !NGTUtil.isServer(); + Map> map = flag ? this.smpModelSetMap : this.allModelSetMap; +- T t = ((Map)map.get(resourcetype1)).get(name); ++ T t = (T)(map.get(resourcetype1)).get(name); + if (t == null) { +- t = this.dummyMap.get(type.hasSubType ? type.subType : type.name); +- if (t == null) { +- throw new ModelPackException("Default model is not registered.", name); +- } ++ return (T)com.anatawa12.fixRtm.DummyModelPackManager.getSet(type, name); + } + + return t; + } + diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/cfg/ResourceConfig.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/cfg/ResourceConfig.java.pm.patch new file mode 100644 index 00000000..75aba359 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/cfg/ResourceConfig.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/modelpack/cfg/ResourceConfig.java ++++ b/jp/ngt/rtm/modelpack/cfg/ResourceConfig.java +@@ -5,10 +5,11 @@ + public abstract class ResourceConfig { + public short version; + public boolean useCustomColor; + public String tags; + public ResourceConfig.DMInitValue[] defaultValues; ++ public java.io.File file; + /** @deprecated */ + @Deprecated + public String defaultData; + + public abstract String getName(); diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackConstructThread.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackConstructThread.java.pm.patch new file mode 100644 index 00000000..6256f636 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackConstructThread.java.pm.patch @@ -0,0 +1,27 @@ +--- a/jp/ngt/rtm/modelpack/init/ModelPackConstructThread.java ++++ b/jp/ngt/rtm/modelpack/init/ModelPackConstructThread.java +@@ -5,11 +5,11 @@ + import jp.ngt.rtm.modelpack.ModelPackManager; + import jp.ngt.rtm.modelpack.modelset.ResourceSet; + import net.minecraft.crash.CrashReport; + import net.minecraftforge.fml.relauncher.Side; + +-public final class ModelPackConstructThread extends Thread { ++public class ModelPackConstructThread extends Thread { + private final Side threadSide; + private final ModelPackLoadThread parent; + private boolean loading; + private int index; + private boolean barStateChanged; +@@ -45,10 +45,11 @@ + resourceset.constructOnServer(); + } else { + resourceset.constructOnClient(); + resourceset.finishConstruct(); + } ++ resourceset.state = com.anatawa12.fixRtm.rtm.modelpack.ModelState.CONSTRUCTED; + + NGTLog.debug("Construct Model : %s (%d / %d)", new Object[]{resourceset.getConfig().getName(), this.index + 1, ModelPackManager.INSTANCE.unconstructSets.size()}); + ++this.index; + if (this.parent.loadFinished) { + if (!this.barStateChanged) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackLoadThread.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackLoadThread.java.pm.patch new file mode 100644 index 00000000..5cf65a0d --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/init/ModelPackLoadThread.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/modelpack/init/ModelPackLoadThread.java ++++ b/jp/ngt/rtm/modelpack/init/ModelPackLoadThread.java +@@ -131,11 +131,11 @@ + } + } + + this.setBarMaxValue(0, ProgressStateHolder.ProgressState.values().length, ""); + NGTLog.startTimer(); +- ModelPackConstructThread modelpackconstructthread = new ModelPackConstructThread(this.threadSide, this); ++ com.anatawa12.fixRtm.rtm.modelpack.init.ExModelPackConstructThread modelpackconstructthread = new com.anatawa12.fixRtm.rtm.modelpack.init.ExModelPackConstructThread(this.threadSide, this); + modelpackconstructthread.start(); + ModelPackManager.INSTANCE.load(this); + + while(!modelpackconstructthread.setFinish()) { + sleep(500L); diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetBase.java.pm.patch new file mode 100644 index 00000000..4c2a81ce --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetBase.java.pm.patch @@ -0,0 +1,51 @@ +--- a/jp/ngt/rtm/modelpack/modelset/ModelSetBase.java ++++ b/jp/ngt/rtm/modelpack/modelset/ModelSetBase.java +@@ -32,24 +32,36 @@ + super(par1); + } + + public void constructOnServer() { + if (((ModelConfig)this.cfg).serverScriptPath != null) { ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("useOurScripting"); + this.serverSE = ScriptUtil.doScript(ModelPackManager.INSTANCE.getScript(((ModelConfig)this.cfg).serverScriptPath)); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("useOurScripting"); ++ this.serverSE = com.anatawa12.fixRtm.scripting.FIXScriptUtil.getScriptAndDoScript(((ModelConfig)this.cfg).serverScriptPath); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("useOurScripting"); + } + + } + + @SideOnly(Side.CLIENT) + public void constructOnClient() { + if (!this.isDummy()) { + if (((ModelConfig)this.cfg).serverScriptPath != null) { ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("useOurScripting"); + this.serverSE = ScriptUtil.doScript(ModelPackManager.INSTANCE.getScript(((ModelConfig)this.cfg).serverScriptPath)); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("useOurScripting"); ++ this.serverSE = com.anatawa12.fixRtm.scripting.FIXScriptUtil.getScriptAndDoScript(((ModelConfig)this.cfg).serverScriptPath); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("useOurScripting"); + } + + if (((ModelConfig)this.cfg).guiScriptPath != null) { ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("useOurScripting"); + this.guiSE = ScriptUtil.doScript(ModelPackManager.INSTANCE.getScript(((ModelConfig)this.cfg).guiScriptPath)); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("useOurScripting"); ++ this.guiSE = com.anatawa12.fixRtm.scripting.FIXScriptUtil.getScriptAndDoScript(((ModelConfig)this.cfg).guiScriptPath); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("useOurScripting"); + this.guiTexture = ModelPackManager.INSTANCE.getResource(((ModelConfig)this.cfg).guiTexture); + } + } + + } +@@ -64,10 +76,11 @@ + + public T getConfig() { + return (T)(this.cfg); + } + ++ // TODO: CrashReport when use java + @SideOnly(Side.CLIENT) + public void renderModelInGui(Minecraft mc) { + this.modelObj.render((Object)null, this.getConfig(), 0, 0.0F); + } + diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetNPC.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetNPC.java.pm.patch new file mode 100644 index 00000000..050c57c4 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetNPC.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/modelpack/modelset/ModelSetNPC.java ++++ b/jp/ngt/rtm/modelpack/modelset/ModelSetNPC.java +@@ -44,10 +44,11 @@ + + public NPCConfig getDummyConfig() { + return NPCConfig.getDummy(); + } + ++ // TODO: CrashReport when use java + @SideOnly(Side.CLIENT) + public void renderModelInGui(Minecraft par1) { + if (this.modelObj != null) { + this.modelObj.render((Object)null, this.getConfig(), 0, 0.0F); + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetSignal.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetSignal.java.pm.patch new file mode 100644 index 00000000..71dd7831 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetSignal.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/modelpack/modelset/ModelSetSignal.java ++++ b/jp/ngt/rtm/modelpack/modelset/ModelSetSignal.java +@@ -43,10 +43,11 @@ + + public SignalConfig getDummyConfig() { + return SignalConfig.getDummyConfig(); + } + ++ // TODO: CrashReport when use java + @SideOnly(Side.CLIENT) + public void renderModelInGui(Minecraft par1) { + SignalConfig signalconfig = (SignalConfig)this.getConfig(); + this.modelObj.render((Object)null, signalconfig, 0, 0.0F); + this.modelObj.render((Object)null, signalconfig, 1, 0.0F); diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetTrain.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetTrain.java.pm.patch new file mode 100644 index 00000000..9d25fd87 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetTrain.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/modelpack/modelset/ModelSetTrain.java ++++ b/jp/ngt/rtm/modelpack/modelset/ModelSetTrain.java +@@ -48,10 +48,11 @@ + + public TrainConfig getDummyConfig() { + return TrainConfig.getDummyConfig(); + } + ++ // TODO: CrashReport when use java + @SideOnly(Side.CLIENT) + protected void renderPartsInGui(Minecraft par1) { + TrainConfig trainconfig = (TrainConfig)this.cfg; + + for(int i = 0; i < 2; ++i) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetVehicleBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetVehicleBase.java.pm.patch new file mode 100644 index 00000000..a5cb8909 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ModelSetVehicleBase.java.pm.patch @@ -0,0 +1,41 @@ +--- a/jp/ngt/rtm/modelpack/modelset/ModelSetVehicleBase.java ++++ b/jp/ngt/rtm/modelpack/modelset/ModelSetVehicleBase.java +@@ -19,11 +19,11 @@ + public ScriptEngine soundSE; + + public ModelSetVehicleBase() { + } + +- public ModelSetVehicleBase(VehicleBaseConfig par1) { ++ public ModelSetVehicleBase(T par1) { + super(par1); + } + + public void constructOnServer() { + super.constructOnServer(); +@@ -40,20 +40,25 @@ + PartsRenderer partsrenderer = !PartsRenderer.validPath(((VehicleBaseConfig)this.cfg).getModel().rendererPath) ? new BasicVehiclePartsRenderer(new String[]{String.valueOf(true)}) : null; + this.modelObj = new ModelObject(((VehicleBaseConfig)this.cfg).getModel(), this, partsrenderer, new Object[]{"vehicle"}); + this.buttonTexture = ModelPackManager.INSTANCE.getResource(((VehicleBaseConfig)this.cfg).buttonTexture); + this.rollsignTexture = ((VehicleBaseConfig)this.cfg).rollsignTexture == null ? null : ModelPackManager.INSTANCE.getResource(((VehicleBaseConfig)this.cfg).rollsignTexture); + if (((VehicleBaseConfig)this.cfg).soundScriptPath != null) { ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("useOurScripting"); + this.soundSE = ScriptUtil.doScript(ModelPackManager.INSTANCE.getScript(this.getConfig().soundScriptPath)); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("useOurScripting"); ++ this.soundSE = com.anatawa12.fixRtm.scripting.FIXScriptUtil.getScriptAndDoScript(ModelPackManager.INSTANCE.getScript(this.getConfig().soundScriptPath)); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("useOurScripting"); + } + } + + } + + public T getConfig() { + return (T)(this.cfg); + } + ++ // TODO: CrashReport when use java + @SideOnly(Side.CLIENT) + public void renderModelInGui(Minecraft par1) { + VehicleBaseConfig vehiclebaseconfig = (VehicleBaseConfig)this.cfg; + this.modelObj.render((Object)null, vehiclebaseconfig, 0, 0.0F); + this.modelObj.render((Object)null, vehiclebaseconfig, 1, 0.0F); diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ResourceSet.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ResourceSet.java.pm.patch new file mode 100644 index 00000000..525eeb57 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/modelset/ResourceSet.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/modelpack/modelset/ResourceSet.java ++++ b/jp/ngt/rtm/modelpack/modelset/ResourceSet.java +@@ -8,10 +8,11 @@ + public abstract class ResourceSet { + protected final T cfg; + public final DataFormatter dataFormatter; + private boolean isDummySet; + public byte[] md5; ++ public com.anatawa12.fixRtm.rtm.modelpack.ModelState state = com.anatawa12.fixRtm.rtm.modelpack.ModelState.INITIALIZED; + + public ResourceSet() { + this.cfg = this.getDummyConfig(); + this.dataFormatter = new DataFormatter(this.cfg); + this.isDummySet = true; diff --git a/src/main/rtm-patches/jp/ngt/rtm/modelpack/state/ResourceState.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/modelpack/state/ResourceState.java.pm.patch new file mode 100644 index 00000000..112ad934 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/modelpack/state/ResourceState.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/modelpack/state/ResourceState.java ++++ b/jp/ngt/rtm/modelpack/state/ResourceState.java +@@ -84,11 +84,11 @@ + this.setResourceName(this.type.defaultName); + } + + public T getResourceSet() { + if (this.modelSet == null || this.modelSet.isDummy()) { +- this.modelSet = ModelPackManager.INSTANCE.getResourceSet(this.type, this.modelName); ++ this.modelSet = (T)com.anatawa12.fixRtm.rtm.HooksKt.eraseNullForModelSet(ModelPackManager.INSTANCE.getResourceSet(this.type, this.modelName), this.type); + if (!this.modelSet.isDummy()) { + this.modelSet.dataFormatter.initDataMap(this.dataMap); + } + } + diff --git a/src/main/rtm-patches/jp/ngt/rtm/rail/BlockLargeRailBase.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/rail/BlockLargeRailBase.java.pm.patch new file mode 100644 index 00000000..33ef8e40 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/rail/BlockLargeRailBase.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/rail/BlockLargeRailBase.java ++++ b/jp/ngt/rtm/rail/BlockLargeRailBase.java +@@ -212,11 +212,11 @@ + return tileentity instanceof TileEntityLargeRailBase ? ((TileEntityLargeRailBase)tileentity).getRailCore() : null; + } + + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { + TileEntityLargeRailCore tileentitylargerailcore = getCore(world, pos); +- return tileentitylargerailcore != null ? ItemRail.copyItemFromRail(tileentitylargerailcore) : null; ++ return tileentitylargerailcore != null ? ItemRail.copyItemFromRail(tileentitylargerailcore) : ItemStack.EMPTY; + } + + public PathNodeType getAiPathNodeType(IBlockState state, IBlockAccess world, BlockPos pos) { + return this.preventMobMovement(world, pos) ? PathNodeType.BLOCKED : PathNodeType.RAIL; + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/rail/BlockMarker.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/rail/BlockMarker.java.pm.patch new file mode 100644 index 00000000..982bb87b --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/rail/BlockMarker.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/rail/BlockMarker.java ++++ b/jp/ngt/rtm/rail/BlockMarker.java +@@ -124,10 +124,11 @@ + public void makeRailMap(TileEntityMarker marker, int x, int y, int z) { + this.onMarkerActivated(marker.getWorld(), x, y, z, (EntityPlayer)null, false); + } + + public boolean onMarkerActivated(World world, int x, int y, int z, EntityPlayer player, boolean makeRail) { ++ com.anatawa12.fixRtm.rtm.HooksKt.BlockMarker_onMarkerActivated(player); + ResourceStateRail resourcestaterail = this.hasRail(player, makeRail); + if (resourcestaterail == null) { + return false; + } else { + boolean flag = player == null || player.capabilities.isCreativeMode; diff --git a/src/main/rtm-patches/jp/ngt/rtm/rail/RenderMarkerBlock.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/rail/RenderMarkerBlock.java.pm.patch new file mode 100644 index 00000000..ef2dcc30 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/rail/RenderMarkerBlock.java.pm.patch @@ -0,0 +1,44 @@ +--- a/jp/ngt/rtm/rail/RenderMarkerBlock.java ++++ b/jp/ngt/rtm/rail/RenderMarkerBlock.java +@@ -176,14 +176,25 @@ + for(int i1 = 1; i1 < this.displayStrings.length; ++i1) { + float f8 = (float)i1 * 10.0F; + + for(int j1 = -1; j1 <= 1; ++j1) { + float f9 = f8 * (float)j1; ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("markerDistanceMoreRealPosition"); + ngttessellator.addVertex(-0.4F + f9, 0.0F, 0.4F + f8); + ngttessellator.addVertex(-0.4F + f9, 0.0F, -0.4F + f8); + ngttessellator.addVertex(0.4F + f9, 0.0F, -0.4F + f8); + ngttessellator.addVertex(0.4F + f9, 0.0F, 0.4F + f8); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("markerDistanceMoreRealPosition"); ++ ngttessellator.addVertex(-0.4F + f9, 0.0F, -0.4F + f8); ++ ngttessellator.addVertex(-0.4F + f9, 0.0F, -0.6F + f8); ++ ngttessellator.addVertex(0.4F + f9, 0.0F, -0.6F + f8); ++ ngttessellator.addVertex(0.4F + f9, 0.0F, -0.4F + f8); ++ ngttessellator.addVertex(-0.1F + f9, 0.0F, -0.1F + f8); ++ ngttessellator.addVertex(-0.1F + f9, 0.0F, -0.9F + f8); ++ ngttessellator.addVertex(0.1F + f9, 0.0F, -0.9F + f8); ++ ngttessellator.addVertex(0.1F + f9, 0.0F, -0.1F + f8); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("markerDistanceMoreRealPosition"); + } + } + + ngttessellator.draw(); + GL11.glEnable(3553); +@@ -193,11 +204,15 @@ + float f11 = (float)(l1 + 1) * 10.0F; + + for(int i2 = -1; i2 <= 1; ++i2) { + float f10 = f11 * (float)i2; + GL11.glPushMatrix(); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("markerDistanceMoreRealPosition"); + GL11.glTranslatef(f10, 0.0F, f11); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("markerDistanceMoreRealPosition"); ++ GL11.glTranslatef(f10, 0.0F, f11 - 0.5F); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("markerDistanceMoreRealPosition"); + GL11.glRotatef(-NGTUtilClient.getMinecraft().getRenderManager().playerViewY - f6, 0.0F, 1.0F, 0.0F); + GL11.glScalef(-0.25F, -0.25F, 0.25F); + String s = this.displayStrings[l1]; + int k1 = fontrenderer.getStringWidth(s) / 2; + fontrenderer.drawString(s, -k1 / 2, -10, l); diff --git a/src/main/rtm-patches/jp/ngt/rtm/rail/util/RailMaker.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/rail/util/RailMaker.java.pm.patch new file mode 100644 index 00000000..cc4b3e92 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/rail/util/RailMaker.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/rail/util/RailMaker.java ++++ b/jp/ngt/rtm/rail/util/RailMaker.java +@@ -81,11 +81,11 @@ + } + } + + if (this.worldObj != null && !this.worldObj.isRemote) { + RailPosition railposition1 = this.rpList.get(0); +- NGTLog.sendChatMessageToAll("message.rail.switch_type", new Object[]{railposition1.blockX, railposition1.blockY, railposition1.blockZ}); ++ com.anatawa12.fixRtm.rtm.HooksKt.sendSwitchTypeError("message.rail.switch_type", new Object[]{railposition1.blockX, railposition1.blockY, railposition1.blockZ}); + } + + return null; + } + } diff --git a/src/main/rtm-patches/jp/ngt/rtm/rail/util/SwitchType.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/rail/util/SwitchType.java.pm.patch new file mode 100644 index 00000000..e3660f5c --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/rail/util/SwitchType.java.pm.patch @@ -0,0 +1,17 @@ +--- a/jp/ngt/rtm/rail/util/SwitchType.java ++++ b/jp/ngt/rtm/rail/util/SwitchType.java +@@ -310,10 +310,14 @@ + + ++i; + } + + arailmapswitch[2] = new RailMapSwitch(railposition, railposition1, raildir, raildir1); ++ ++ if (!com.anatawa12.fixRtm.UtilsKt.isAllNotNull(arailmapswitch)) ++ return false; ++ + this.railMaps = arailmapswitch; + this.points = new Point[4]; + this.points[0] = new Point(railposition, arailmapswitch[0], arailmapswitch[2]); + this.points[1] = new Point(railposition1, arailmapswitch[1], arailmapswitch[2]); + this.points[2] = new Point(railposition == arailmapswitch[0].startRP ? arailmapswitch[0].endRP : arailmapswitch[0].startRP, arailmapswitch[0]); diff --git a/src/main/rtm-patches/jp/ngt/rtm/render/ModelObject.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/render/ModelObject.java.pm.patch new file mode 100644 index 00000000..a97edb82 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/render/ModelObject.java.pm.patch @@ -0,0 +1,44 @@ +--- a/jp/ngt/rtm/render/ModelObject.java ++++ b/jp/ngt/rtm/render/ModelObject.java +@@ -92,10 +92,19 @@ + this.alphaBlend = false; + this.useTexture = true; + this.renderer = this.getPartsRenderer((String)null, par1); + } + ++ public ModelObject(IModelNGT par1, TextureSet[] par2, PartsRenderer par3) { ++ this.model = par1; ++ this.textures = par2; ++ this.light = false; ++ this.alphaBlend = false; ++ this.useTexture = true; ++ this.renderer = par3; ++ } ++ + public static ModelObject getDummy() { + if (DUMMY == null) { + DUMMY = new ModelObject(ModelLoader.loadModel(new ResourceLocationCustom("models/ModelContainer_19g.obj"), VecAccuracy.LOW, new Object[0]), new TextureSet[]{new TextureSet(new Material((byte)0, ModelPackManager.INSTANCE.getResource("textures/container/19g_JRF_0.png")), 0, false, false, new String[0])}); + } + +@@ -241,17 +250,17 @@ + } + + } + + public Material[] getMaterials(Map map) { +- Map map = this.model.getMaterials(); ++ Map map1 = this.model.getMaterials(); + Material[] amaterial; +- if (map.isEmpty()) { ++ if (map1.isEmpty()) { + amaterial = new Material[]{new Material((byte)0, ModelPackManager.INSTANCE.getResource(map.get("default")))}; + } else { +- amaterial = new Material[map.size()]; +- Iterator> iterator = map.entrySet().iterator(); ++ amaterial = new Material[map1.size()]; ++ Iterator> iterator = map1.entrySet().iterator(); + + for(int i = 0; iterator.hasNext(); ++i) { + Entry entry = (Entry)iterator.next(); + String s = map.get(entry.getKey()); + if (s == null) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/render/PartsRenderer.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/render/PartsRenderer.java.pm.patch new file mode 100644 index 00000000..1eec6bb8 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/render/PartsRenderer.java.pm.patch @@ -0,0 +1,15 @@ +--- a/jp/ngt/rtm/render/PartsRenderer.java ++++ b/jp/ngt/rtm/render/PartsRenderer.java +@@ -66,11 +66,11 @@ + + private void execScriptFunc(String func, Object... args) { + try { + ScriptUtil.doScriptFunction(this.script, func, args); + } catch (Exception exception) { +- throw new RuntimeException("On init script : " + this.modelSet.getConfig().getName(), exception); ++ throw new RuntimeException("On " + func + " script : " + this.modelSet.getConfig().getName(), exception); + } + } + + public Parts registerParts(Parts par1) { + this.partsList.add(par1); diff --git a/src/main/rtm-patches/jp/ngt/rtm/render/RTMRenderers.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/render/RTMRenderers.java.pm.patch new file mode 100644 index 00000000..9ba9f7e5 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/render/RTMRenderers.java.pm.patch @@ -0,0 +1,23 @@ +--- a/jp/ngt/rtm/render/RTMRenderers.java ++++ b/jp/ngt/rtm/render/RTMRenderers.java +@@ -9,14 +9,19 @@ + import net.minecraftforge.fml.relauncher.SideOnly; + + @SideOnly(Side.CLIENT) + public final class RTMRenderers { + public static R getRendererWithScript(ResourceLocation par1, String... args) { ++ com.anatawa12.fixRtm.asm.Preprocessor.ifDisabled("useOurScripting"); + String s = ModelPackManager.INSTANCE.getScript(par1.getPath()); + ScriptEngine scriptengine = ScriptUtil.doScript(s); ++ com.anatawa12.fixRtm.asm.Preprocessor.ifEnabled("useOurScripting"); ++ s = null; ++ scriptengine = com.anatawa12.fixRtm.scripting.FIXScriptUtil.getScriptAndDoScript(par1.toString()); ++ com.anatawa12.fixRtm.asm.Preprocessor.whatever("useOurScripting"); + String s1 = (String)ScriptUtil.getScriptField(scriptengine, "renderClass"); +- R r = getRenderer(s1, args); ++ R r = (R)getRenderer(s1, args); + r.setScript(scriptengine, par1); + scriptengine.put("renderer", r); + return r; + } + diff --git a/src/main/rtm-patches/jp/ngt/rtm/sound/MovingSoundMaker.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/sound/MovingSoundMaker.java.pm.patch new file mode 100644 index 00000000..dbce9cbd --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/sound/MovingSoundMaker.java.pm.patch @@ -0,0 +1,14 @@ +--- a/jp/ngt/rtm/sound/MovingSoundMaker.java ++++ b/jp/ngt/rtm/sound/MovingSoundMaker.java +@@ -93,10 +93,11 @@ + + try { + String s = NGTText.getText(new ResourceLocation(domain, "sounds.json"), true); + Map map1 = (Map)NGTJson.getGson().fromJson(s, TYPE); + ++ com.anatawa12.fixRtm.rtm.HooksKt.MovingSoundMaker_loadSoundJson_nullCheck(map, domain); + for(Entry entry : map1.entrySet()) { + if (!(entry.getValue()).sounds.isEmpty()) { + Object object = (entry.getValue()).sounds.get(0); + String s1; + if (object instanceof Map) { diff --git a/src/main/rtm-patches/jp/ngt/rtm/world/RTMChunkManager.java.pm.patch b/src/main/rtm-patches/jp/ngt/rtm/world/RTMChunkManager.java.pm.patch new file mode 100644 index 00000000..d68a3c84 --- /dev/null +++ b/src/main/rtm-patches/jp/ngt/rtm/world/RTMChunkManager.java.pm.patch @@ -0,0 +1,22 @@ +--- a/jp/ngt/rtm/world/RTMChunkManager.java ++++ b/jp/ngt/rtm/world/RTMChunkManager.java +@@ -36,18 +36,11 @@ + } + + } + + public void getChunksAround(Set set, int xChunk, int zChunk, int radius) { +- set.clear(); +- +- for(int i = xChunk - radius; i <= xChunk + radius; ++i) { +- for(int j = zChunk - radius; j <= zChunk + radius; ++j) { +- set.add(new ChunkPos(i, j)); +- } +- } +- ++ com.anatawa12.fixRtm.rtm.world.RTMChunkManagerKt.getChunksAround(set, xChunk, zChunk, radius); + } + + public Ticket getNewTicket(World world, Type type) { + return ForgeChunkManager.requestTicket(RTMCore.instance, world, type); + } From 0f64046b3dc33f19a6b24a79f597ff27624e7e14 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 3 Mar 2021 22:07:28 +0900 Subject: [PATCH 7/8] make PatchApplier#transform param basicClass nullable --- .../java/com/anatawa12/fixRtm/asm/patching/PatchApplier.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/anatawa12/fixRtm/asm/patching/PatchApplier.kt b/src/main/java/com/anatawa12/fixRtm/asm/patching/PatchApplier.kt index fb5c9228..eeb4bb4f 100644 --- a/src/main/java/com/anatawa12/fixRtm/asm/patching/PatchApplier.kt +++ b/src/main/java/com/anatawa12/fixRtm/asm/patching/PatchApplier.kt @@ -7,7 +7,8 @@ import java.io.ByteArrayOutputStream import java.security.MessageDigest class PatchApplier : IClassTransformer { - override fun transform(name: String, transformedName: String, basicClass: ByteArray): ByteArray { + override fun transform(name: String, transformedName: String, basicClass: ByteArray?): ByteArray? { + if (basicClass == null) return null val patch = getPatchAndSha1(name) if (patch == null) { logger.trace("no patch found for $name") From 37c2076f88f71400058a57f005d8b9cb687d882a Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 3 Mar 2021 22:25:41 +0900 Subject: [PATCH 8/8] update build script --- .github/workflows/build.yml | 13 ++++++++----- .github/workflows/release.yml | 8 ++++---- scripts/update_for_release.sh | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0521e2f9..50d31b3c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b81db7ed..ae07b475 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -55,7 +55,7 @@ jobs: - name: Build uses: eskatos/gradle-command-action@v1 with: - arguments: makeFixrtmJar + arguments: build - name: push releases id: publish_releases diff --git a/scripts/update_for_release.sh b/scripts/update_for_release.sh index f066e2eb..83d101e1 100755 --- a/scripts/update_for_release.sh +++ b/scripts/update_for_release.sh @@ -105,7 +105,7 @@ awk "$(sed "s/{MATCH}/[$version_name]/" scripts/extract-changelog.awk)" CHANGELO # 出力設定 -asset_path="./build/fixrtm/libs/fixRtm-$version_name.jar" +asset_path="./build/libs/fixRtm-$version_name.jar" asset_name="fixRtm-$version_name.jar" echo "::set-output name=release_note_path::$release_note_path"