This commit is contained in:
parent
7add673c73
commit
247e5f06a1
|
@ -7,7 +7,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.16"
|
||||
version = "0.0.1-alpha.17"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
@ -24,7 +24,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("dev.frogmc:thyroxine:0.0.1-alpha.10")
|
||||
implementation("dev.frogmc:thyroxine:0.0.1-alpha.12")
|
||||
implementation("org.ow2.asm:asm:9.7")
|
||||
implementation("org.ow2.asm:asm-commons:9.7")
|
||||
implementation("org.ow2.asm:asm-tree:9.7")
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package dev.frogmc.phytotelma
|
||||
|
||||
import com.google.gson.FieldNamingPolicy
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import com.google.gson.*
|
||||
import dev.frogmc.thyroxine.api.data.MappingBundle
|
||||
import org.gradle.api.Project
|
||||
import java.lang.reflect.Type
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
import kotlin.io.path.absolutePathString
|
||||
|
@ -74,52 +70,28 @@ class ProjectData(
|
|||
internal constructor() : this(null, null, null, null, null, null, null, null)
|
||||
}
|
||||
|
||||
class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
|
||||
override fun write(out: JsonWriter, value: ProjectData) {
|
||||
out.beginObject()
|
||||
out.serializeNulls = true
|
||||
out.name("local_cache_dir").value(value.localCacheDir?.absolutePathString())
|
||||
out.name("minecraft_version").value(value.minecraftVersion)
|
||||
out.name("remapped_game_jar_path").value(value.remappedGameJarPath?.absolutePathString())
|
||||
out.name("mappings_name").value(value.mappingsName)
|
||||
out.name("target_namespace").value(value.targetNamespace)
|
||||
out.endObject()
|
||||
}
|
||||
|
||||
override fun read(r: JsonReader): ProjectData {
|
||||
r.beginObject()
|
||||
val data = ProjectData()
|
||||
while (r.peek() != JsonToken.END_OBJECT) {
|
||||
val name = r.nextName()
|
||||
if (r.peek() == JsonToken.STRING) {
|
||||
val value = r.nextString()
|
||||
when (name) {
|
||||
"local_cache_dir" -> {
|
||||
data.localCacheDir = Path.of(value)
|
||||
}
|
||||
|
||||
"minecraft_version" -> {
|
||||
data.minecraftVersion = value
|
||||
}
|
||||
|
||||
"remapped_game_jar_path" -> {
|
||||
data.remappedGameJarPath = Path.of(value)
|
||||
}
|
||||
|
||||
"mappings_name" -> {
|
||||
data.mappingsName = value
|
||||
}
|
||||
|
||||
"target_namespace" -> {
|
||||
data.targetNamespace = value
|
||||
}
|
||||
}
|
||||
} else {
|
||||
r.skipValue()
|
||||
}
|
||||
class ProjectDataTypeAdapter : JsonSerializer<ProjectData>, JsonDeserializer<ProjectData> {
|
||||
override fun serialize(value: ProjectData?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement {
|
||||
val out = JsonObject()
|
||||
if (value != null) {
|
||||
out.addProperty("local_cache_dir", value.localCacheDir?.absolutePathString())
|
||||
out.addProperty("minecraft_version", value.minecraftVersion)
|
||||
out.addProperty("remapped_game_jar_path", value.remappedGameJarPath?.absolutePathString())
|
||||
out.addProperty("mappings_name", value.mappingsName)
|
||||
out.addProperty("target_namespace", value.targetNamespace)
|
||||
}
|
||||
r.endObject()
|
||||
return data
|
||||
return out
|
||||
}
|
||||
|
||||
override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): ProjectData {
|
||||
val out = ProjectData()
|
||||
if (json != null && json.isJsonObject) {
|
||||
out.localCacheDir = Path.of(json.asJsonObject.get("local_cache_dir").asString)
|
||||
out.minecraftVersion = json.asJsonObject.get("minecraft_version").asString
|
||||
out.remappedGameJarPath = Path.of(json.asJsonObject.get("remapped_game_jar_path").asString)
|
||||
out.mappingsName = json.asJsonObject.get("mappings_name").asString
|
||||
out.targetNamespace = json.asJsonObject.get("target_namespace").asString
|
||||
}
|
||||
return out
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,14 +130,29 @@ abstract class MinecraftConfiguration @Inject constructor(
|
|||
val conf = objects.newInstance(VersionConfiguration::class.java)
|
||||
action.execute(conf)
|
||||
if (!conf.version.isPresent) {
|
||||
error("No version provided for yarn!")
|
||||
error("No version provided for feather!")
|
||||
}
|
||||
mappingsName = "yarn(${conf.version.get()})"
|
||||
targetNamespace = "yarn"
|
||||
// Use qm via intermediary because hashed publications are broken
|
||||
mappingsName = "feather(${conf.version.get()})"
|
||||
targetNamespace = "feather"
|
||||
return@provider twoStepMappings(
|
||||
"net.ornithemc:calamus-intermediary:${version.get()}:v2",
|
||||
"net.fabricmc:yarn:${conf.version.get()}:v2"
|
||||
"net.ornithemc:feather:${conf.version.get()}:v2"
|
||||
).flatten(true).renameDstNamespace(targetNamespace)
|
||||
}
|
||||
}
|
||||
|
||||
fun featherGen2(action: Action<VersionConfiguration>): Provider<MappingBundle> {
|
||||
return project.provider {
|
||||
val conf = objects.newInstance(VersionConfiguration::class.java)
|
||||
action.execute(conf)
|
||||
if (!conf.version.isPresent) {
|
||||
error("No version provided for feather-gen2!")
|
||||
}
|
||||
mappingsName = "feather(${conf.version.get()})"
|
||||
targetNamespace = "feather-gen2"
|
||||
return@provider twoStepMappings(
|
||||
"net.ornithemc:calamus-intermediary-gen2:${version.get()}:v2",
|
||||
"net.ornithemc:feather-gen2:${conf.version.get()}:v2"
|
||||
).flatten(true).renameDstNamespace(targetNamespace)
|
||||
}
|
||||
}
|
||||
|
@ -195,6 +210,12 @@ abstract class MinecraftConfiguration @Inject constructor(
|
|||
var back = MappingBundle()
|
||||
var name = "layer["
|
||||
|
||||
if (conf.layers.get().isEmpty()) {
|
||||
mappingsName = "$name]"
|
||||
targetNamespace = "official"
|
||||
return@provider MappingBundle()
|
||||
}
|
||||
|
||||
val layers = conf.layers.get().mapIndexed { index, provider ->
|
||||
if (index == 0) {
|
||||
val bundle = (provider.get() as MappingBundle).flatten()
|
||||
|
|
|
@ -34,10 +34,10 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
|
|||
error("No Minecraft version provided!")
|
||||
}
|
||||
val version = mcConf.version.get()
|
||||
val projectData = ProjectStorage.get(project)
|
||||
projectData.manifestUrl = mcConf.manifestUrl.get()
|
||||
|
||||
if (VersionChecker.validateVersion(project, version, offlineMode = project.gradle.startParameter.isOffline)) {
|
||||
|
||||
val projectData = ProjectStorage.get(project)
|
||||
projectData.minecraftVersion = version
|
||||
|
||||
val mappings = mcConf.mappings.get()
|
||||
|
@ -79,7 +79,10 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
|
|||
project.afterEvaluate {
|
||||
println("Applying AccessWideners...")
|
||||
AccessWidener.apply(project, remappedJar)
|
||||
if (mcConf.targetNamespace != Constants.MOJMAP_NAMESPACE) {
|
||||
}
|
||||
}
|
||||
project.afterEvaluate {
|
||||
if (mcConf.targetNamespace != Constants.MOJMAP_NAMESPACE) {
|
||||
Thyroxine.remap(
|
||||
MappingData("", ""),
|
||||
remappedJar,
|
||||
|
@ -92,7 +95,6 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
|
|||
} else {
|
||||
Files.deleteIfExists(remappedJar.resolveSibling(Constants.ALTERNATIVE_RUNTIME_JAR_NAME))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ object RunConfigGenerator {
|
|||
if (env == Env.CLIENT) {
|
||||
arrayOf(
|
||||
"--assetsDir", assetPath.toString(),
|
||||
"--version", "FrogMC",
|
||||
"--version", projectData.minecraftVersion!!,
|
||||
"--assetIndex", indexId,
|
||||
"--accessToken", "0"
|
||||
)
|
||||
|
|
|
@ -16,7 +16,7 @@ class EclipseAdapter : RunConfigAdapter {
|
|||
programArgs: Array<String>
|
||||
) {
|
||||
val projectName = project.extensions.findByType(EclipseModel::class.java)?.project?.name ?: project.name
|
||||
val file = project.rootDir.resolve("$name.launch")
|
||||
val file = project.rootDir.resolve("${name.replace(" ", "_")}.launch")
|
||||
|
||||
file.writer(StandardCharsets.UTF_8).use {
|
||||
// @formatter:off
|
||||
|
|
|
@ -23,7 +23,7 @@ class IdeaAdapter : RunConfigAdapter {
|
|||
if (!folder.isDirectory())
|
||||
folder.createDirectories()
|
||||
|
||||
val file = folder.resolve("$name.xml")
|
||||
val file = folder.resolve("${name.replace(" ", "_")}.xml")
|
||||
|
||||
var module =
|
||||
project.name + "." + project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.getByName(
|
||||
|
|
|
@ -24,6 +24,7 @@ abstract class RunGameTask @Inject constructor(env: Env) : JavaExec() {
|
|||
|
||||
init {
|
||||
group = Constants.TASK_GROUP
|
||||
val projectData = ProjectStorage.get(project)
|
||||
val assetPath = PhytotelmaPlugin.globalCacheDir.resolve("assets").absolute()
|
||||
val assetIndexPath = assetPath.resolve("indexes")
|
||||
if (assetIndexPath.notExists()) {
|
||||
|
@ -42,7 +43,7 @@ abstract class RunGameTask @Inject constructor(env: Env) : JavaExec() {
|
|||
if (env == Env.CLIENT) {
|
||||
listOf(
|
||||
"--assetsDir", assetPath.toString(),
|
||||
"--version", "FrogMC",
|
||||
"--version", projectData.minecraftVersion!!,
|
||||
"--assetIndex", indexId,
|
||||
"--accessToken", "0"
|
||||
)
|
||||
|
@ -54,9 +55,9 @@ abstract class RunGameTask @Inject constructor(env: Env) : JavaExec() {
|
|||
SourceSet.MAIN_SOURCE_SET_NAME
|
||||
).runtimeClasspath.filter { it.exists() })
|
||||
|
||||
val projectData = ProjectStorage.get(project)
|
||||
var runtimeGameJar = projectData.remappedGameJarPath!!
|
||||
if (projectData.targetNamespace != Constants.MOJMAP_NAMESPACE) {
|
||||
println("Using alternative runtime jar to make use package access fixing")
|
||||
runtimeGameJar = runtimeGameJar.resolveSibling(Constants.ALTERNATIVE_RUNTIME_JAR_NAME)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue