Compare commits

..

No commits in common. "3883c9cafd0c3b588536bc4cdb5197bc029792aa" and "dc570b9331f29884df6cd9172eb46abaed1b03d4" have entirely different histories.

4 changed files with 12 additions and 115 deletions

View file

@ -12,4 +12,5 @@ object Constants {
const val GEN_RUN_CONFIGS_TASK = "genRunConfigs"
const val RUN_CLIENT_TASK = "runClient"
const val RUNT_SERVER_TASK = "runServer"
const val DEV_NAMESPACE = "named"
}

View file

@ -1,9 +1,7 @@
package dev.frogmc.phytotelma.ext
import dev.frogmc.phytotelma.PhytotelmaPlugin
import dev.frogmc.phytotelma.mappings.filterClasses
import dev.frogmc.phytotelma.mappings.renameDstNamespace
import dev.frogmc.phytotelma.mappings.renameNamespaces
import dev.frogmc.thyroxine.api.data.MappingBundle
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser
import dev.frogmc.thyroxine.provider.MojmapProvider
@ -25,7 +23,7 @@ abstract class MinecraftConfiguration @Inject constructor(
) {
var version: String? = null
var mappings: Provider<MappingBundle> = mojmapParchment()
internal var mappings: Provider<MappingBundle> = mojmapParchment()
internal lateinit var mappingsName: String
internal lateinit var targetNamespace: String
@ -59,27 +57,6 @@ abstract class MinecraftConfiguration @Inject constructor(
}
}
fun parchment(action: Action<ParchmentConfiguration>): Provider<MappingBundle> {
return project.provider {
val conf = objects.newInstance(ParchmentConfiguration::class.java)
conf.gameVersion = version
action.execute(conf)
val cacheDir = PhytotelmaPlugin.globalCacheDir
if (conf.version == null) {
conf.version = ParchmentProvider.findForMinecraftVersion(conf.gameVersion)
}
mappingsName = "parchment(${conf.gameVersion}, ${conf.version})"
targetNamespace = "parchment"
return@provider ParchmentProvider.getParchment(
version,
cacheDir.resolve("org/parchmentmc/parchment/${conf.gameVersion}/${conf.version}")
).renameNamespaces("mojmap", "parchment")
}
}
fun mojmap(): Provider<MappingBundle> {
return project.provider {
val cacheDir = PhytotelmaPlugin.globalCacheDir
@ -99,32 +76,13 @@ abstract class MinecraftConfiguration @Inject constructor(
if (conf.version == null) {
error("No version provided for quilt mappings!")
}
mappingsName = "quilt-mappings(${conf.version})"
targetNamespace = "quilt-mappings"
mappingsName = "quilt(${conf.version})"
targetNamespace = "quilt"
// Use qm via intermediary because hashed publications are broken
return@provider twoStepMappings(
"net.fabricmc:intermediary:$version:v2",
"org.quiltmc:quilt-mappings:${conf.version}:intermediary-v2"
).filterClasses { !it.startsWith("net/minecraft/unmapped") }
.flatten(true).renameDstNamespace(targetNamespace)
}
}
fun yarn(action: Action<VersionConfiguration>): Provider<MappingBundle> {
return project.provider {
val conf = objects.newInstance(VersionConfiguration::class.java)
action.execute(conf)
if (conf.version == null) {
error("No version provided for yarn!")
}
mappingsName = "yarn(${conf.version})"
targetNamespace = "yarn"
// Use qm via intermediary because hashed publications are broken
return@provider twoStepMappings(
"net.fabricmc:intermediary:$version:v2",
"net.fabricmc:yarn:${conf.version}:v2"
).filterClasses { !it.startsWith("net/minecraft/class_") }
.flatten(true).renameDstNamespace(targetNamespace)
).renameDstNamespace(targetNamespace)
}
}
@ -169,41 +127,6 @@ abstract class MinecraftConfiguration @Inject constructor(
}
}
fun layer(action: Action<LayerConfiguration>): Provider<MappingBundle> {
return project.provider {
val conf = objects.newInstance(LayerConfiguration::class.java)
action.execute(conf)
var back = MappingBundle()
var name = "layer["
val layers = conf.layers.mapIndexed {index, provider ->
val bundle = provider.get().flatten(true)
if (index == 0) {
name+=mappingsName
back.insert(bundle)
return@mapIndexed bundle
}
name+=", $mappingsName"
back = back.flatten(false)
val prevDst = back.data[0].dstNamespace
val dst = bundle.data[0].dstNamespace
val remapped = MappingBundle.merge(bundle.reverse(), back)
.flatten(prevDst, dst)
.insert(back.docsForNamespace(dst))
back.insert(remapped)
return@mapIndexed remapped
}
mappingsName = "$name]"
val result = MappingBundle.merge(*layers.toTypedArray())
.flatten("official", layers.last().dstNamespaces()[0])
targetNamespace = result.data[0].dstNamespace
return@provider result
}
}
private fun twoStepMappings(intermediary: String, mappings: String): MappingBundle {
return MappingBundle.merge(tinyMappings(intermediary), tinyMappings(mappings))
}
@ -240,7 +163,7 @@ abstract class MinecraftConfiguration @Inject constructor(
}
abstract class LayerConfiguration {
/*internal*/ val layers = mutableListOf<Provider<MappingBundle>>()
internal val layers = mutableListOf<Provider<MappingBundle>>()
fun add(mappings: Provider<MappingBundle>): LayerConfiguration {
layers.add(mappings)
return this

View file

@ -62,7 +62,7 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
println("Preparing Parchment...")
val javadocs = ProjectStorage.get(project).mappings!!
options[IFabricJavadocProvider.PROPERTY_NAME] =
FrogJavadocProvider(javadocs.get(ProjectStorage.get(project).targetNamespace))
FrogJavadocProvider(javadocs.docsForNamespace(Constants.DEV_NAMESPACE))
println("Decompiling...")
val logger = PrintStreamLogger(PrintStream(System.out))

View file

@ -4,9 +4,10 @@ import dev.frogmc.thyroxine.api.data.DocumentationData
import dev.frogmc.thyroxine.api.data.MappingBundle
import dev.frogmc.thyroxine.api.data.MappingData
fun MappingBundle.renameNamespaces(newSrc: String?, newDst: String): MappingBundle {
val oldData = if (srcNamespaces().size > 1 || dstNamespaces().size > 1) flattenData() else data[0]
val newData = MappingData(newSrc ?: oldData.srcNamespace, newDst)
fun MappingBundle.renameDstNamespace(newDst: String): MappingBundle {
val renamed = MappingBundle()
val oldData = flattenData()
val newData = MappingData(oldData.srcNamespace, newDst)
val newDocs = DocumentationData(newDst)
oldData.apply {
@ -16,33 +17,5 @@ fun MappingBundle.renameNamespaces(newSrc: String?, newDst: String): MappingBund
newData.parameters.putAll(parameters)
}
return MappingBundle(newData, get(oldData.dstNamespace)?.let { newDocs.insert(it) })
}
fun MappingBundle.renameDstNamespace(newDst: String): MappingBundle {
return renameNamespaces(null, newDst)
}
fun MappingBundle.filterClasses(filter: (String) -> Boolean): MappingBundle {
val oldData = data.last()
val newData = MappingData(oldData.srcNamespace, oldData.dstNamespace)
val oldDocs = if (documentation.isNotEmpty()) documentation.last() else null
oldData.apply {
newData.classes.putAll(classes.filter { filter.invoke(it.value) })
newData.fields.putAll(fields.filter { newData.classes.containsKey(it.key.owner) })
newData.methods.putAll(methods.filter { newData.classes.containsKey(it.key.owner) })
newData.parameters.putAll(parameters.filter { newData.classes.containsKey(it.key.owner) })
}
val bundle = MappingBundle(data.subList(0, data.size-1).plus(newData), mutableListOf())
if (oldDocs != null) {
val newDocs = DocumentationData(newData.dstNamespace)
newDocs.classes.addAll(oldDocs.classes.filter { filter.invoke(it.name) })
bundle.insert(newDocs)
}
return bundle
return renamed.insert(newData, newDocs.insert(get(oldData.dstNamespace)))
}