Skip to content

Commit

Permalink
Remove MappingOption.forPlatform
Browse files Browse the repository at this point in the history
This fixes dep AT remapping on Forge 1.20.6+ - the filter
was choosing the wrong mapping option as it's only designed
for one extra namespace.

The optimisation isn't strictly needed. If it's added back
in the future, we need to make sure that ModProcessor gets
the full mapping tree.
  • Loading branch information
Juuxel committed Jul 3, 2024
1 parent 3f1d69b commit 1033f25
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 75 deletions.
27 changes: 3 additions & 24 deletions src/main/java/dev/architectury/loom/util/MappingOption.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
package dev.architectury.loom.util;

import org.jetbrains.annotations.Nullable;

import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;

public enum MappingOption {
DEFAULT(null),
WITH_SRG(MappingsNamespace.SRG.toString()),
WITH_MOJANG(MappingsNamespace.MOJANG.toString());

private final String extraNamespace;

MappingOption(@Nullable String extraNamespace) {
this.extraNamespace = extraNamespace;
}

public MappingOption forNamespaces(String... namespaces) {
if (extraNamespace == null) return this;

for (String namespace : namespaces) {
if (extraNamespace.equals(namespace)) {
return this;
}
}

return DEFAULT;
}
DEFAULT,
WITH_SRG,
WITH_MOJANG;

public static MappingOption forPlatform(LoomGradleExtensionAPI extension) {
return switch (extension.getPlatform().get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private void remapJars(List<ModDependency> remapList) throws IOException {
knownIndyBsms.addAll(modDependency.getMetadata().knownIdyBsms());
}

MappingOption mappingOption = MappingOption.forPlatform(extension).forNamespaces(fromM, toM);
MappingOption mappingOption = MappingOption.forPlatform(extension);
MemoryMappingTree mappings = mappingConfiguration.getMappingsService(serviceManager, mappingOption).getMappingTree();
LoggerFilter.replaceSystemOut();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static TinyRemapper getTinyRemapper(Project project, SharedServiceManager

public static TinyRemapper getTinyRemapper(Project project, SharedServiceManager serviceManager, String fromM, String toM, boolean fixRecords, Consumer<TinyRemapper.Builder> builderConsumer, Set<String> fromClassNames) throws IOException {
LoomGradleExtension extension = LoomGradleExtension.get(project);
final MappingOption mappingOption = MappingOption.forPlatform(extension).forNamespaces(fromM, toM);
final MappingOption mappingOption = MappingOption.forPlatform(extension);
MemoryMappingTree mappingTree = extension.getMappingConfiguration().getMappingsService(serviceManager, mappingOption).getMappingTree();

if (fixRecords && !mappingTree.getSrcNamespace().equals(fromM)) {
Expand Down

This file was deleted.

0 comments on commit 1033f25

Please sign in to comment.