Skip to content

Commit

Permalink
Build: Update Fabric launcher to 0.15.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mattco98 committed Dec 20, 2023
1 parent 6b2fd9d commit 9797778
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
include(modImplementation("net.fabricmc.fabric-api:fabric-api:${property("fabric_version")}")!!)

include(modImplementation("net.fabricmc:fabric-language-kotlin:1.9.4+kotlin.1.8.21")!!)
include(modImplementation("net.fabricmc:mapping-io:0.5.1")!!)
include(modImplementation("com.github.ChatTriggers:rhino:96d0c07966")!!)
include(modImplementation("com.fasterxml.jackson.core:jackson-core:2.13.2")!!)
include(modImplementation("com.fifesoft:rsyntaxtextarea:3.2.0")!!)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ mod_group = com.chattriggers
archives_base_name = ctjs
supportedMcVersions=1.19.4-fabric,1.20.4-fabric

loader_version=0.14.23
loader_version=0.15.3

essential.defaults.loom=1
37 changes: 22 additions & 15 deletions src/main/kotlin/com/chattriggers/ctjs/api/Mappings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.chattriggers.ctjs.api
import com.chattriggers.ctjs.CTJS
import com.chattriggers.ctjs.internal.utils.urlEncode
import net.fabricmc.loader.api.FabricLoader
import net.fabricmc.mapping.tree.Descriptored
import net.fabricmc.mapping.tree.Mapped
import net.fabricmc.mapping.tree.TinyMappingFactory
import net.fabricmc.mappingio.MappingReader
import net.fabricmc.mappingio.tree.MappingTree.ElementMapping
import net.fabricmc.mappingio.tree.MappingTree.MethodArgMapping
import net.fabricmc.mappingio.tree.MappingTreeView
import net.fabricmc.mappingio.tree.MemoryMappingTree
import org.objectweb.asm.Type
import org.spongepowered.asm.mixin.transformer.ClassInfo
import java.io.ByteArrayInputStream
Expand Down Expand Up @@ -38,7 +40,8 @@ object Mappings {
file.getInputStream(file.getEntry("mappings/mappings.tiny")).readAllBytes()
}

val tree = TinyMappingFactory.load(ByteArrayInputStream(mappingBytes).bufferedReader())
val tree = MemoryMappingTree()
MappingReader.read(ByteArrayInputStream(mappingBytes).bufferedReader(), tree)

tree.classes.forEach { clazz ->
val fields = mutableMapOf<String, MappedField>()
Expand All @@ -59,14 +62,14 @@ object Mappings {
methods.getOrPut(method.unmappedName, ::mutableListOf).add(
MappedMethod(
name = Mapping.fromMapped(method),
parameters = method.parameters.sortedBy { it.localVariableIndex }.mapIndexed { index, param ->
parameters = method.args.sortedBy { it.lvIndex }.mapIndexed { index, param ->
MappedParameter(
Mapping(param.unmappedName, param.mappedName),
Mapping(
unmappedType.argumentTypes[index].descriptor,
mappedType.argumentTypes[index].descriptor,
),
param.localVariableIndex,
param.lvIndex,
)
},
returnType = Mapping(unmappedType.returnType.descriptor, mappedType.returnType.descriptor)
Expand Down Expand Up @@ -128,7 +131,7 @@ object Mappings {
get() = if (CTJS.isDevelopment) original else mapped

companion object {
fun fromMapped(mapped: Mapped) = Mapping(mapped.unmappedName, mapped.mappedName)
fun fromMapped(mapped: ElementMapping) = Mapping(mapped.unmappedName, mapped.mappedName)
}
}

Expand Down Expand Up @@ -183,15 +186,19 @@ object Mappings {
}
}

private val Mapped.unmappedName: String
get() = getName("named")
private val ElementMapping.unmappedName: String
get() = getName("named")!!

private val Mapped.mappedName: String
get() = getName("intermediary")
private val ElementMapping.mappedName: String
get() = getName("intermediary")!!

private val Descriptored.unmappedType: Type
get() = Type.getType(getDescriptor("named"))
// Parameters do not have "intermediary" mappings
private val MethodArgMapping.mappedName: String
get() = unmappedName

private val Descriptored.mappedType: Type
get() = Type.getType(getDescriptor("intermediary"))
private val MappingTreeView.MemberMappingView.unmappedType: Type
get() = Type.getType(getDesc("named"))

private val MappingTreeView.MemberMappingView.mappedType: Type
get() = Type.getType(getDesc("intermediary"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.chattriggers.ctjs.api.Mappings
import com.chattriggers.ctjs.internal.launch.*
import com.chattriggers.ctjs.internal.utils.descriptor
import com.chattriggers.ctjs.internal.utils.descriptorString
import net.fabricmc.accesswidener.AccessWidenerReader
import net.fabricmc.loader.impl.FabricLoaderImpl
import net.fabricmc.loader.impl.lib.accesswidener.AccessWidenerReader
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.AnnotationNode
Expand Down

0 comments on commit 9797778

Please sign in to comment.