mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-26 17:46:25 -05:00
3fec4ad922
* First look at datagen * First pass on item/block models * Tags * Advancements + BlockFamilies * Loot tables * Cleanup * Start on javadocs, and cleanup * Update for new mappings. * Added client-side entrypoint and more logging. * Complete javadoc, add modid filter and misc fixes/cleanup. * Minor fixes. * Renames and misc changes. * Strict validation fixes. * Apply suggestions from code review Co-authored-by: Shnupbups <shnupbups@gmail.com> * Update fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricDataGenerator.java Co-authored-by: Shnupbups <shnupbups@gmail.com> * Update fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricDataGenerator.java Co-authored-by: Shnupbups <shnupbups@gmail.com> * Review fixes. * Set generated dir as resources not sources. Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com> Co-authored-by: Shnupbups <shnupbups@gmail.com>
110 lines
2.9 KiB
Groovy
110 lines
2.9 KiB
Groovy
archivesBaseName = "fabric-data-generation-api-v1"
|
|
version = getSubprojectVersion(project)
|
|
|
|
moduleDependencies(project, [
|
|
'fabric-api-base',
|
|
'fabric-registry-sync-v0',
|
|
'fabric-networking-api-v1'
|
|
])
|
|
|
|
sourceSets {
|
|
testmod {
|
|
resources {
|
|
srcDirs += [
|
|
'src/testmod/generated'
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
loom {
|
|
accessWidenerPath = file("src/main/resources/fabric-data-generation-api-v1.accesswidener")
|
|
|
|
runs {
|
|
datagen {
|
|
inherit testmodServer
|
|
name "Data Generation"
|
|
vmArg "-Dfabric-api.datagen"
|
|
vmArg "-Dfabric-api.datagen.output-dir=${file("src/testmod/generated")}"
|
|
vmArg "-Dfabric-api.datagen.strict-validation"
|
|
|
|
ideConfigGenerated = true
|
|
runDir "build/datagen"
|
|
}
|
|
datagenClient {
|
|
client()
|
|
name "Data Generation"
|
|
vmArg "-Dfabric-api.datagen"
|
|
vmArg "-Dfabric-api.datagen.output-dir=${file("src/testmod/generated")}"
|
|
vmArg "-Dfabric-api.datagen.strict-validation"
|
|
|
|
ideConfigGenerated = true
|
|
runDir "build/datagen"
|
|
source sourceSets.testmod
|
|
}
|
|
}
|
|
}
|
|
|
|
assemble.dependsOn runDatagen
|
|
|
|
import org.objectweb.asm.ClassReader
|
|
import org.objectweb.asm.Opcodes
|
|
import org.objectweb.asm.tree.ClassNode
|
|
|
|
import java.util.zip.ZipFile
|
|
|
|
task generateAccessWidener() {
|
|
doLast {
|
|
// This is using loom internals, dont copy from this.
|
|
File inputJar = loom.mappingsProvider.mappedProvider.baseMappedJar
|
|
String accessWidener = file("template.accesswidener").text + "\n"
|
|
|
|
visitMethods(inputJar, "net/minecraft/data/server/RecipesProvider.class") { name, desc, owner ->
|
|
if (it.name == "generate")
|
|
return
|
|
|
|
accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n"
|
|
}
|
|
|
|
visitMethods(inputJar, "net/minecraft/data/client/model/BlockStateModelGenerator.class") { name, desc, owner ->
|
|
if (desc == "()V")
|
|
// Skip over methods that dont take any arguments, as they are specific to minecraft.
|
|
return
|
|
|
|
accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n"
|
|
}
|
|
|
|
visitMethods(inputJar, "net/minecraft/data/server/BlockLootTableGenerator.class") { name, desc, owner ->
|
|
accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n"
|
|
}
|
|
|
|
file("src/main/resources/fabric-data-generation-api-v1.accesswidener").text = accessWidener
|
|
}
|
|
}
|
|
|
|
def visitMethods(File input, String className, closure) {
|
|
def clazz = getClassNode(input, className)
|
|
clazz.methods.forEach {
|
|
if ((it.access & Opcodes.ACC_SYNTHETIC) != 0 || (it.access & Opcodes.ACC_PUBLIC) != 0)
|
|
return
|
|
|
|
if (it.name.startsWith("<"))
|
|
return
|
|
|
|
closure(it.name, it.desc, clazz.name)
|
|
}
|
|
}
|
|
|
|
ClassNode getClassNode(File input, String className) {
|
|
File inputJar = loom.mappingsProvider.mappedProvider.baseMappedJar
|
|
|
|
new ZipFile(inputJar).withCloseable { ZipFile zip ->
|
|
zip.getInputStream(zip.getEntry(className)).withCloseable { is ->
|
|
ClassReader reader = new ClassReader(is)
|
|
ClassNode classNode = new ClassNode()
|
|
reader.accept(classNode, 0)
|
|
|
|
return classNode
|
|
}
|
|
}
|
|
}
|