Skip to content

Commit

Permalink
behold, horrors beyond human imagination
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Jun 8, 2024
1 parent 0698c98 commit 1ba6028
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
18 changes: 13 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ import groovy.json.JsonSlurper
import net.fabricmc.loom.api.LoomGradleExtensionAPI
import net.fabricmc.loom.task.RemapJarTask
import org.gradle.configurationcache.extensions.capitalized
import org.objectweb.asm.*
import org.objectweb.asm.tree.AnnotationNode
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassWriter
import org.objectweb.asm.Label
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.MethodNode
import org.objectweb.asm.util.CheckClassAdapter
import java.io.ByteArrayOutputStream
import java.util.Locale
import java.util.jar.JarEntry
import java.util.jar.JarFile
import java.util.jar.JarOutputStream
Expand Down Expand Up @@ -237,7 +240,7 @@ fun transformJar(projectPath: String, jar: File) {
JarOutputStream(jar.outputStream()).use { out ->
out.setLevel(Deflater.BEST_COMPRESSION)
contents.forEach { var (name, data) = it
if(name.startsWith("architectury_inject_${project.name}_common"))
if (name.startsWith("architectury_inject_${"archives_base_name"().lowercase(Locale.ROOT)}_common"))
return@forEach

if (name.endsWith(".json") || name.endsWith(".mcmeta")) {
Expand Down Expand Up @@ -379,7 +382,12 @@ fun transformClass(projectPath: String, bytes: ByteArray): ByteArray {
}
}

return ClassWriter(0).also { node.accept(it) }.toByteArray()
val byteArray = ClassWriter(0).also { node.accept(it) }.toByteArray()

// Verify the bytecode is valid
ClassReader(byteArray).accept(CheckClassAdapter(null), 0)

return byteArray
}

fun calculateGitHash(): String {
Expand Down
20 changes: 19 additions & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Numismatics
* Copyright (c) 2024 The Railways Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

architectury {
common {
for(p in rootProject.subprojects) {
Expand Down Expand Up @@ -63,7 +81,7 @@ tasks.processResources {
sourceSets.main {
resources { // include generated resources in resources
srcDir("src/generated/resources")
exclude("src/generated/resources/.cache")
exclude(".cache")
}
}

Expand Down
6 changes: 2 additions & 4 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ repositories {
maven("https://raw.githubusercontent.com/Fuzss/modresources/main/maven/") // Forge config api port
maven("https://maven.cafeteria.dev/releases") // Fake Player API
maven("https://maven.jamieswhiteshirt.com/libs-release") // Reach Entity Attributes
maven("https://jitpack.io/") // Mixin Extras, Fabric ASM
maven("https://maven.siphalor.de/") { // Amecs API (required by Carry On)
name = "Siphalor's Maven"
}
maven("https://jitpack.io/") // Fabric ASM
maven("https://maven.siphalor.de/") // Amecs API (required by Carry On)
maven("https://squiddev.cc/maven/") {// CC Tweaked
content {
includeGroup("cc.tweaked")
Expand Down

0 comments on commit 1ba6028

Please sign in to comment.