forked from FabricMC/fabric-loom
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NeoForge ATs not being fully remapped (#185)
Fixes #184. Also rewrites all code using the CadixDev AT library to use our fork.
- Loading branch information
Showing
14 changed files
with
119 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/dev/architectury/loom/neoforge/NeoForgeModDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package dev.architectury.loom.neoforge; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Set; | ||
|
||
import dev.architectury.at.AccessTransformSet; | ||
import dev.architectury.at.io.AccessTransformFormats; | ||
import dev.architectury.loom.metadata.ModMetadataFile; | ||
import dev.architectury.loom.metadata.ModMetadataFiles; | ||
|
||
import net.fabricmc.loom.util.Constants; | ||
import net.fabricmc.loom.util.FileSystemUtil; | ||
import net.fabricmc.loom.util.ModPlatform; | ||
import net.fabricmc.mappingio.tree.MappingTreeView; | ||
|
||
public final class NeoForgeModDependencies { | ||
public static void remapAts(Path jar, MappingTreeView mappings, String from, String to) throws IOException { | ||
final ModMetadataFile modMetadata = ModMetadataFiles.fromJar(jar); | ||
Set<String> atPaths = Set.of(Constants.Forge.ACCESS_TRANSFORMER_PATH); | ||
|
||
if (modMetadata != null) { | ||
final Set<String> modsTomlAts = modMetadata.getAccessTransformers(ModPlatform.NEOFORGE); | ||
|
||
if (!modsTomlAts.isEmpty()) { | ||
atPaths = modsTomlAts; | ||
} | ||
} | ||
|
||
try (FileSystemUtil.Delegate fs = FileSystemUtil.getJarFileSystem(jar)) { | ||
for (String atPathStr : atPaths) { | ||
final Path atPath = fs.getPath(atPathStr); | ||
|
||
if (Files.exists(atPath)) { | ||
AccessTransformSet ats = AccessTransformFormats.FML.read(atPath); | ||
ats = ats.remap(mappings, from, to); | ||
AccessTransformFormats.FML.write(atPath, ats); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters