Skip to content

Commit

Permalink
Use srgutils, update groovybundler
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Mar 9, 2024
1 parent 16e4654 commit 7f1d88a
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 172 deletions.
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ plugins {
alias libs.plugins.nexuspublish
}

project.buildDir.mkdirs()

tasks.changelog {
gitDir = project.file('./')
start = '2.1.13'
Expand Down Expand Up @@ -80,7 +78,7 @@ repositories {
}

modsDotGroovy {
dslVersion = libs.versions.mdg.dsl.get()
dslVersion = libs.mdg.dsl.get().version
platform 'fabric'
}

Expand All @@ -97,7 +95,7 @@ dependencies {
compileOnly libs.autoextension
compileOnly libs.autoservice

includeBundle libs.mappingio
includeBundle libs.srgutils

includeCompileOnlyApi libs.groovybundler
}
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
systemProp.net.fabricmc.tinyremapper.knownindybsm=org/codehaus/groovy/vmplugin/v8/IndyInterface

# Mod Properties
group = org.groovymc.groovyduvet
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
minecraft = "1.19.4"
fabric_loader = "0.14.21"
parchment_minecraft = "1.19.3"
parchment_mappings = "2023.03.12"
mappingio = "0.4.2"
minecraft = "1.20.2"
fabric_loader = "0.14.22"
parchment_minecraft = "1.20.2"
parchment_mappings = "2023.10.22"
srgutils = "1.0.0"
fabric_loom = "1.4.1"
quilt_licenser = "2.0.1"
autoservice = "1.1.1"
Expand All @@ -12,13 +12,13 @@ mdg_plugin = "1.4.1"
mdg_dsl = "1.5.1"
simpleci = "0.2.5"
nexuspublish = "1.3.0"
groovybundler = "1.0.1"
groovybundler = "2.1.2"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" }

mappingio = { module = "net.fabricmc:mapping-io", version.ref = "mappingio" }
srgutils = { module = "net.neoforged:srgutils", version.ref = "srgutils" }

autoservice = { module = "com.google.auto.service:auto-service", version.ref = "autoservice" }
autoextension = { module = "dev.lukebemish.autoextension:autoextension", version.ref = "autoextension" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,33 @@
import org.groovymc.groovyduvet.core.impl.compile.ClassMappings;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Map;

@AutoService(RuntimeRemapper.class)
public class RuntimeRemapperImpl implements RuntimeRemapper {
@Override
public @Nullable String remapMethodName(Class<?> parent, String name, Class<?>[] args) {
String className = parent.getName();
public @Nullable String remapMethodName(String className, String name, String methodDesc) {
var methods = ClassMappings.getMethods().get(className);
if (methods != null) {
List<String> methodNames = methods.get(name);
Map<String, String> methodNames = methods.get(name);
if (methodNames != null) {
for (String methodName : methodNames) {
try {
parent.getDeclaredMethod(methodName, args);
return methodName;
} catch (NoSuchMethodException ignored) {}
}
return methodNames.get(methodDesc);
}
}
return null;
}

@Override
public @Nullable String remapFieldName(Class<?> parent, String name) {
String className = parent.getName();
public @Nullable String remapFieldName(String className, String name, String type) {
var fields = ClassMappings.getFields().get(className);
if (fields != null) {
return fields.get(name);
}
return null;
}

@Override
public @Nullable String remapClassName(String className) {
return ClassMappings.getMojToRuntime().get(className);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ final class ClassMappings {

static final Map<String, String> mojToRuntime = [:]
static final Map<String, Map<String, String>> mojToRuntimePackages = [:]
static final Map<String, Map<String, List<String>>> methods = [:]
static final Map<String, Map<String, Map<String, String>>> methods = [:]
static final Map<String, Map<String, String>> fields = [:]

static synchronized addMappings(Map<String, String> mappings, Map<String, Map<String, List<String>>> methods, Map<String, Map<String, String>> fields) {
static synchronized addMappings(Map<String, String> mappings, Map<String, Map<String, Map<String, String>>> methods, Map<String, Map<String, String>> fields) {
mojToRuntime.clear()
mojToRuntimePackages.clear()
ClassMappings.methods.clear()
ClassMappings.fields.clear()

println methods
println fields

ClassMappings.methods.putAll(methods)
ClassMappings.fields.putAll(fields)
ClassMappings.mojToRuntime.putAll(mappings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ class LoadedMappings {
final Map<String, Map<String, String>> fields
final Set<String> mappable

LoadedMappings(Map<String, Map<String, List<String>>> methods, Map<String, Map<String, String>> fields) {
this.methods = methods
LoadedMappings(Map<String, Map<String, Map<String, String>>> methods, Map<String, Map<String, String>> fields) {
this.methods = methods.collectEntries {k, v ->
[(k): v.collectEntries {k2, v2 -> [(k2): v2.values().collect()]}]
}
this.fields = fields

List<String> emptyRemovalQueue = []
methods.each (className,methodMap) -> {
this.methods.each (className,methodMap) -> {
List<String> noKnownMappingsRemovalQueue = []
methodMap.forEach(official,srg) -> {
List<String> unnecessaryRemovalQueue = []
Expand All @@ -37,10 +39,10 @@ class LoadedMappings {
emptyRemovalQueue.add(className)
}
}
emptyRemovalQueue.each {methods.remove it}
emptyRemovalQueue.each {this.methods.remove it}

emptyRemovalQueue.clear()
fields.forEach (className,fieldMap) -> {
this.fields.forEach (className,fieldMap) -> {
List<String> unnecessaryRemovalQueue = []
fieldMap.forEach (official,srg) -> {
if (official==srg) unnecessaryRemovalQueue.add(official)
Expand All @@ -52,7 +54,7 @@ class LoadedMappings {
emptyRemovalQueue.add(className)
}
}
emptyRemovalQueue.each {fields.remove it}
emptyRemovalQueue.each {this.fields.remove it}

this.mappable = methods.keySet() + fields.keySet()
}
Expand Down
Loading

0 comments on commit 7f1d88a

Please sign in to comment.