Skip to content

Commit 1fab9f4

Browse files
authored
Merge pull request #23 from FabricCompatibilityLayers/feature/api-v2
Api V2
2 parents 3e821fa + 508b645 commit 1fab9f4

File tree

57 files changed

+2097
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2097
-630
lines changed

build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ dependencies {
5858

5959
implementation(include("io.github.llamalad7:mixinextras-fabric:${project.mixin_extras_version}"))
6060
implementation(include("com.github.thecatcore.CursedMixinExtensions:fabric:1.0.0"))
61-
implementation(include("com.github.thecatcore:WFVAIO:1.1.0"))
61+
implementation(include("com.github.thecatcore:WFVAIO:1.2.0"))
6262

6363
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
6464
}
@@ -163,3 +163,11 @@ Now allow ModRemappers to disable mixin remapping which is enabled by default fo
163163
embedded.version "spasm", project.spasm_version
164164
}
165165
}
166+
167+
task testmodJar(type: Jar) {
168+
from sourceSets.test.output
169+
destinationDirectory = project.layout.buildDirectory.dir("libs")
170+
archiveClassifier.set("testmod")
171+
}
172+
173+
build.dependsOn testmodJar

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.jvmargs=-Xmx1G
66
# Fabric Properties
77
minecraft_version = 1.6.4
88
yarn_build = 458
9-
loader_version = 0.15.10
9+
loader_version = 0.16.11
1010
fabric_version = 1.9.1+1.12.2
1111
mixin_extras_version=0.2.1
1212
spasm_version=0.2

src/main/java/fr/catcore/modremapperapi/utils/Constants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
import java.io.File;
77

88
public class Constants {
9+
@Deprecated
910
public static final File MAIN_FOLDER = CacheUtils.BASE_FOLDER.toFile();
11+
@Deprecated
1012
public static final File VERSIONED_FOLDER = CacheUtils.MAIN_FOLDER.toFile();
13+
@Deprecated
1114
public static final File LIB_FOLDER = CacheUtils.LIBRARY_FOLDER.toFile();
1215

16+
@Deprecated
1317
public static final File EXTRA_MAPPINGS_FILE = CacheUtils.getCachePath("extra_mappings.tiny").toFile();
18+
@Deprecated
1419
public static final File REMAPPED_MAPPINGS_FILE = CacheUtils.getCachePath("remapped_mappings.tiny").toFile();
20+
@Deprecated
1521
public static final File MC_MAPPINGS_FILE = CacheUtils.getCachePath("mc_mappings.tiny").toFile();
22+
@Deprecated
1623
public static final File FULL_MAPPINGS_FILE = CacheUtils.getCachePath("full_mappings.tiny").toFile();
1724

1825
public static final Logger MAIN_LOGGER = Logger.get("ModRemappingAPI");
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.github.fabriccompatibilitylayers.modremappingapi.api.v2;
2+
3+
import io.github.fabriccompatibiltylayers.modremappingapi.impl.context.BaseModRemapperContext;
4+
5+
import java.nio.file.Path;
6+
7+
public interface CacheHandler {
8+
Path resolveTemp(String name);
9+
Path resolveCache(String name);
10+
Path resolveLibrary(String name);
11+
12+
static CacheHandler getCacheHandler(String contextId) {
13+
return BaseModRemapperContext.get(contextId).getCacheHandler();
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.github.fabriccompatibilitylayers.modremappingapi.api.v2;
2+
3+
public interface MappingBuilder {
4+
5+
ClassMapping addMapping(String sourceName, String targetName);
6+
ClassMapping addMapping(String name);
7+
8+
public interface ClassMapping {
9+
ClassMapping field(String sourceName, String targetName, String sourceDescriptor);
10+
ClassMapping field(String name, String descriptor);
11+
ClassMapping method(String sourceName, String targetName, String sourceDescriptor);
12+
ClassMapping method(String name, String descriptor);
13+
}
14+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package io.github.fabriccompatibilitylayers.modremappingapi.api.v2;
2+
3+
import io.github.fabriccompatibiltylayers.modremappingapi.impl.MappingsUtilsImpl;
4+
import org.jetbrains.annotations.Nullable;
5+
6+
public interface MappingUtils {
7+
/**
8+
*
9+
* @param className original class name
10+
* @return remapped class name
11+
*/
12+
static String mapClass(String contextId, String className) {
13+
return MappingsUtilsImpl.mapClass(MappingsUtilsImpl.getMappingsRegistry(contextId), className);
14+
}
15+
16+
/**
17+
*
18+
* @param className remapped class name
19+
* @return original class name
20+
*/
21+
static String unmapClass(String contextId, String className) {
22+
return MappingsUtilsImpl.unmapClass(MappingsUtilsImpl.getMappingsRegistry(contextId), className);
23+
}
24+
25+
/**
26+
*
27+
* @param className original class name
28+
* @param fieldName
29+
* @param fieldDesc
30+
* @return
31+
*/
32+
static ClassMember mapField(String contextId, String className, String fieldName, @Nullable String fieldDesc) {
33+
return MappingsUtilsImpl.mapField(MappingsUtilsImpl.getMappingsRegistry(contextId), className, fieldName, fieldDesc);
34+
}
35+
36+
/**
37+
*
38+
* @param className remapped class name
39+
* @param fieldName
40+
* @param fieldDesc
41+
* @return
42+
*/
43+
static ClassMember mapFieldFromRemappedClass(String contextId, String className, String fieldName, @Nullable String fieldDesc) {
44+
return MappingsUtilsImpl.mapFieldFromRemappedClass(MappingsUtilsImpl.getMappingsRegistry(contextId), className, fieldName, fieldDesc);
45+
}
46+
47+
/**
48+
*
49+
* @param className original class name
50+
* @param methodName
51+
* @param methodDesc
52+
* @return
53+
*/
54+
static ClassMember mapMethod(String contextId, String className, String methodName, String methodDesc) {
55+
return MappingsUtilsImpl.mapMethod(MappingsUtilsImpl.getMappingsRegistry(contextId), className, methodName, methodDesc);
56+
}
57+
58+
/**
59+
*
60+
* @param className remapped class name
61+
* @param methodName
62+
* @param methodDesc
63+
* @return
64+
*/
65+
static ClassMember mapMethodFromRemappedClass(String contextId, String className, String methodName, String methodDesc) {
66+
return MappingsUtilsImpl.mapMethodFromRemappedClass(MappingsUtilsImpl.getMappingsRegistry(contextId), className, methodName, methodDesc);
67+
}
68+
69+
static ClassMember mapField(String contextId, Class<?> owner, String fieldName) {
70+
return MappingsUtilsImpl.mapField(MappingsUtilsImpl.getMappingsRegistry(contextId), owner, fieldName);
71+
}
72+
73+
static ClassMember mapMethod(String contextId, Class<?> owner, String methodName, Class<?>[] parameterTypes) {
74+
return MappingsUtilsImpl.mapMethod(MappingsUtilsImpl.getMappingsRegistry(contextId), owner, methodName, parameterTypes);
75+
}
76+
77+
/**
78+
*
79+
* @param desc original descriptor
80+
* @return remapped descriptor
81+
*/
82+
static String mapDescriptor(String contextId, String desc) {
83+
return MappingsUtilsImpl.mapDescriptor(MappingsUtilsImpl.getMappingsRegistry(contextId), desc);
84+
}
85+
86+
interface ClassMember {
87+
String getName();
88+
@Nullable String getDesc();
89+
}
90+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.github.fabriccompatibilitylayers.modremappingapi.api.v2;
2+
3+
import io.github.fabriccompatibilitylayers.modremappingapi.impl.DefaultMappingsConfig;
4+
import org.jetbrains.annotations.Nullable;
5+
6+
import java.util.Map;
7+
import java.util.function.Supplier;
8+
9+
public interface MappingsConfig {
10+
@Nullable String getSourceNamespace();
11+
@Nullable Supplier<String> getExtraMappings();
12+
Map<String, String> getRenamingMap();
13+
@Nullable String getDefaultPackage();
14+
15+
static MappingsConfig defaultConfig() {
16+
return new DefaultMappingsConfig();
17+
}
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.github.fabriccompatibilitylayers.modremappingapi.api.v2;
2+
3+
import org.jetbrains.annotations.Nullable;
4+
5+
import java.nio.file.Path;
6+
7+
public interface ModCandidate {
8+
String getId();
9+
Path getPath();
10+
String getType();
11+
@Nullable String getAccessWidenerPath();
12+
@Nullable ModCandidate getParent();
13+
@Nullable String getVersion();
14+
@Nullable String getParentSubPath();
15+
String getDestinationName();
16+
ModDiscovererConfig getDiscovererConfig();
17+
void setAccessWidener(byte[] data);
18+
byte @Nullable [] getAccessWidener();
19+
void setDestination(Path destination);
20+
@Nullable Path getDestination();
21+
void setPath(Path path);
22+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.github.fabriccompatibilitylayers.modremappingapi.api.v2;
2+
3+
import io.github.fabriccompatibilitylayers.modremappingapi.impl.ModDiscovererConfigImpl;
4+
5+
import java.nio.file.Path;
6+
import java.util.List;
7+
import java.util.function.BiFunction;
8+
import java.util.function.Predicate;
9+
import java.util.regex.Pattern;
10+
11+
public interface ModDiscovererConfig {
12+
static Builder builder(String folderName) {
13+
return new ModDiscovererConfigImpl.BuilderImpl(folderName);
14+
}
15+
16+
String getFolderName();
17+
Pattern getFileNameMatcher();
18+
boolean searchRecursively();
19+
Predicate<String> getDirectoryFilter();
20+
Collector getCandidateCollector();
21+
boolean getExportToOriginalFolder();
22+
boolean allowDirectoryMods();
23+
24+
interface Builder {
25+
Builder fileNameMatcher(String pattern);
26+
Builder searchRecursively(boolean searchRecursively);
27+
Builder directoryFilter(Predicate<String> filter);
28+
Builder candidateCollector(Collector collector);
29+
Builder exportToOriginalFolder(boolean exportToOriginalFolder);
30+
Builder allowDirectoryMods(boolean allowDirectoryMods);
31+
32+
ModDiscovererConfig build();
33+
}
34+
35+
@FunctionalInterface
36+
interface Collector {
37+
List<ModCandidate> collect(ModDiscovererConfig config, Path modPath, List<String> entries);
38+
}
39+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.github.fabriccompatibilitylayers.modremappingapi.api.v2;
2+
3+
import net.fabricmc.api.EnvType;
4+
5+
import java.util.List;
6+
7+
public interface ModRemapper {
8+
String getContextId();
9+
10+
void init(CacheHandler cacheHandler);
11+
12+
List<ModDiscovererConfig> getModDiscoverers();
13+
List<ModRemapper> collectSubRemappers(List<ModCandidate> discoveredMods);
14+
MappingsConfig getMappingsConfig();
15+
List<RemappingFlags> getRemappingFlags();
16+
void afterRemapping();
17+
void afterAllRemappings();
18+
19+
void addRemappingLibraries(List<RemapLibrary> libraries, EnvType environment);
20+
void registerAdditionalMappings(MappingBuilder mappingBuilder);
21+
void registerPreVisitors(VisitorInfos visitorInfos);
22+
void registerPostVisitors(VisitorInfos visitorInfos);
23+
}

0 commit comments

Comments
 (0)