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