Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.fabriccompatibiltylayers.modremappingapi.api.v1.MappingUtils;
import io.github.fabriccompatibiltylayers.modremappingapi.impl.MappingsUtilsImpl;
import io.github.fabriccompatibiltylayers.modremappingapi.impl.mappings.MappingsRegistry;
import io.github.fabriccompatibiltylayers.modremappingapi.impl.context.v1.ModRemapperV1Context;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.mappingio.MappingVisitor;
Expand All @@ -14,7 +14,7 @@
@Deprecated
public class RemapUtil {
@Deprecated
public static final List<String> MC_CLASS_NAMES = MappingsRegistry.VANILLA_CLASS_LIST;
public static final List<String> MC_CLASS_NAMES = ModRemapperV1Context.INSTANCE.getMappingsRegistry().getVanillaClassNames();

@Deprecated
public static class MappingList extends ArrayList<MappingBuilder> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static String unmapClass(String className) {
*/
@Deprecated
static MappingUtils.ClassMember mapField(String className, String fieldName, @Nullable String fieldDesc) {
return MappingsUtilsImpl.mapField(className, fieldName, fieldDesc);
return MappingsUtilsImpl.mapField(MappingsUtilsImpl.getV1Registry(), className, fieldName, fieldDesc);
}

/**
Expand All @@ -50,7 +50,7 @@ static MappingUtils.ClassMember mapField(String className, String fieldName, @Nu
*/
@Deprecated
static MappingUtils.ClassMember mapFieldFromRemappedClass(String className, String fieldName, @Nullable String fieldDesc) {
return MappingsUtilsImpl.mapFieldFromRemappedClass(className, fieldName, fieldDesc);
return MappingsUtilsImpl.mapFieldFromRemappedClass(MappingsUtilsImpl.getV1Registry(), className, fieldName, fieldDesc);
}

/**
Expand All @@ -62,7 +62,7 @@ static MappingUtils.ClassMember mapFieldFromRemappedClass(String className, Stri
*/
@Deprecated
static MappingUtils.ClassMember mapMethod(String className, String methodName, String methodDesc) {
return MappingsUtilsImpl.mapMethod(className, methodName, methodDesc);
return MappingsUtilsImpl.mapMethod(MappingsUtilsImpl.getV1Registry(), className, methodName, methodDesc);
}

/**
Expand All @@ -74,7 +74,7 @@ static MappingUtils.ClassMember mapMethod(String className, String methodName, S
*/
@Deprecated
static MappingUtils.ClassMember mapMethodFromRemappedClass(String className, String methodName, String methodDesc) {
return MappingsUtilsImpl.mapMethodFromRemappedClass(className, methodName, methodDesc);
return MappingsUtilsImpl.mapMethodFromRemappedClass(MappingsUtilsImpl.getV1Registry(), className, methodName, methodDesc);
}

/**
Expand All @@ -85,7 +85,7 @@ static MappingUtils.ClassMember mapMethodFromRemappedClass(String className, Str
*/
@Deprecated
static MappingUtils.ClassMember mapField(Class<?> owner, String fieldName) {
return MappingsUtilsImpl.mapField(owner, fieldName);
return MappingsUtilsImpl.mapField(MappingsUtilsImpl.getV1Registry(), owner, fieldName);
}

/**
Expand All @@ -97,7 +97,7 @@ static MappingUtils.ClassMember mapField(Class<?> owner, String fieldName) {
*/
@Deprecated
static MappingUtils.ClassMember mapMethod(Class<?> owner, String methodName, Class<?>[] parameterTypes) {
return MappingsUtilsImpl.mapMethod(owner, methodName, parameterTypes);
return MappingsUtilsImpl.mapMethod(MappingsUtilsImpl.getV1Registry(), owner, methodName, parameterTypes);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface MappingUtils {
* @return remapped class name
*/
static String mapClass(String className) {
return MappingsUtilsImpl.mapClass(className);
return MappingsUtilsImpl.mapClass(MappingsUtilsImpl.getV1Registry(), className);
}

/**
Expand All @@ -20,7 +20,7 @@ static String mapClass(String className) {
* @return original class name
*/
static String unmapClass(String className) {
return MappingsUtilsImpl.unmapClass(className);
return MappingsUtilsImpl.unmapClass(MappingsUtilsImpl.getV1Registry(), className);
}

/**
Expand All @@ -31,7 +31,7 @@ static String unmapClass(String className) {
* @return
*/
static ClassMember mapField(String className, String fieldName, @Nullable String fieldDesc) {
return MappingsUtilsImpl.mapField(className, fieldName, fieldDesc);
return MappingsUtilsImpl.mapField(MappingsUtilsImpl.getV1Registry(), className, fieldName, fieldDesc);
}

/**
Expand All @@ -42,7 +42,7 @@ static ClassMember mapField(String className, String fieldName, @Nullable String
* @return
*/
static ClassMember mapFieldFromRemappedClass(String className, String fieldName, @Nullable String fieldDesc) {
return MappingsUtilsImpl.mapFieldFromRemappedClass(className, fieldName, fieldDesc);
return MappingsUtilsImpl.mapFieldFromRemappedClass(MappingsUtilsImpl.getV1Registry(), className, fieldName, fieldDesc);
}

/**
Expand All @@ -53,7 +53,7 @@ static ClassMember mapFieldFromRemappedClass(String className, String fieldName,
* @return
*/
static ClassMember mapMethod(String className, String methodName, String methodDesc) {
return MappingsUtilsImpl.mapMethod(className, methodName, methodDesc);
return MappingsUtilsImpl.mapMethod(MappingsUtilsImpl.getV1Registry(), className, methodName, methodDesc);
}

/**
Expand All @@ -64,15 +64,15 @@ static ClassMember mapMethod(String className, String methodName, String methodD
* @return
*/
static ClassMember mapMethodFromRemappedClass(String className, String methodName, String methodDesc) {
return MappingsUtilsImpl.mapMethodFromRemappedClass(className, methodName, methodDesc);
return MappingsUtilsImpl.mapMethodFromRemappedClass(MappingsUtilsImpl.getV1Registry(), className, methodName, methodDesc);
}

static ClassMember mapField(Class<?> owner, String fieldName) {
return MappingsUtilsImpl.mapField(owner, fieldName);
return MappingsUtilsImpl.mapField(MappingsUtilsImpl.getV1Registry(), owner, fieldName);
}

static ClassMember mapMethod(Class<?> owner, String methodName, Class<?>[] parameterTypes) {
return MappingsUtilsImpl.mapMethod(owner, methodName, parameterTypes);
return MappingsUtilsImpl.mapMethod(MappingsUtilsImpl.getV1Registry(), owner, methodName, parameterTypes);
}

/**
Expand All @@ -81,7 +81,7 @@ static ClassMember mapMethod(Class<?> owner, String methodName, Class<?>[] param
* @return remapped descriptor
*/
static String mapDescriptor(String desc) {
return MappingsUtilsImpl.mapDescriptor(desc);
return MappingsUtilsImpl.mapDescriptor(MappingsUtilsImpl.getV1Registry(), desc);
}

class ClassMember {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ default Optional<String> getSourceNamespace() {
default Optional<Supplier<InputStream>> getExtraMapping() {
return Optional.empty();
}

/**
* Whether to enable mixin remapping. Enabled by default for compatibility purposes.
* @return true - enabled <br> false - disabled
*/
default boolean remapMixins() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.fabriccompatibiltylayers.modremappingapi.impl;

import java.nio.file.Path;

public class DefaultModCandidate extends ModCandidate {
public DefaultModCandidate(String modName, Path file, Path original) {
super(modName, modName, file, original);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public void registerPreVisitors(VisitorInfos infos) {
public void registerPostVisitors(VisitorInfos infos) {

}

@Override
public boolean remapMixins() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,34 @@
import java.util.Map;

public class LibraryHandler {
private static final Map<RemapLibrary, Path> remapLibraries = new HashMap<>();
private final Map<RemapLibrary, Path> remapLibraries = new HashMap<>();

public static void gatherRemapLibraries(List<ModRemapper> remappers) {
private String sourceNamespace;

public LibraryHandler() {}

public void init(String sourceNamespace) {
this.sourceNamespace = sourceNamespace;

Path sourceLibraryPath = CacheUtils.getLibraryPath(this.sourceNamespace);

if (!Files.exists(sourceLibraryPath)) {
try {
Files.createDirectories(sourceLibraryPath);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

public void gatherRemapLibraries(List<ModRemapper> remappers) {
try {
for (ModRemapper remapper : remappers) {
List<RemapLibrary> libraries = new ArrayList<>();

remapper.addRemapLibraries(libraries, FabricLoader.getInstance().getEnvironmentType());

Map<RemapLibrary, Path> temp = CacheUtils.computeExtraLibraryPaths(libraries, MappingsUtilsImpl.getSourceNamespace());
Map<RemapLibrary, Path> temp = CacheUtils.computeExtraLibraryPaths(libraries, sourceNamespace);

for (Map.Entry<RemapLibrary, Path> entry : temp.entrySet()) {
RemapLibrary library = entry.getKey();
Expand All @@ -54,7 +72,7 @@ public static void gatherRemapLibraries(List<ModRemapper> remappers) {
}
}

public static void addLibrariesToRemapClasspath(TinyRemapper remapper) {
public void addLibrariesToRemapClasspath(TinyRemapper remapper) {
for (Path libPath : remapLibraries.values()) {
if (Files.exists(libPath)) {
remapper.readClassPathAsync(libPath);
Expand Down
Loading
Loading