Skip to content

Commit

Permalink
Fix mapping issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab125 committed Apr 23, 2024
1 parent 95863a0 commit b5ae80e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ private TinyRemapper buildRemapper(SharedServiceManager serviceManager, Path inp
MemoryMappingTree mappings = mappingsService.getMappingTree();

TinyRemapper remapper = TinyRemapper.newRemapper()
.withMappings(TinyRemapperHelper.create(mappings, sourceNamespace, "official", true))
.withMappings(InnerClassRemapper.of(InnerClassRemapper.readClassNames(input), mappings, sourceNamespace, "official"))
.withMappings(TinyRemapperHelper.create(mappings, sourceNamespace, hasIntermediary() ? "official" : sourceNamespace, true))
.withMappings(InnerClassRemapper.of(InnerClassRemapper.readClassNames(input), mappings, sourceNamespace, hasIntermediary() ? "official" : sourceNamespace))
.renameInvalidLocals(true)
.rebuildSourceFilenames(true)
.build();
Expand Down Expand Up @@ -403,7 +403,7 @@ public static void accessTransform(Project project, Path input, Path target) thr
}

private void remapPatchedJar(SharedServiceManager serviceManager) throws Exception {
logger.lifecycle(":remapping minecraft (TinyRemapper, srg -> official)");
logger.lifecycle(":remapping minecraft (TinyRemapper," + (getExtension().isNeoForge() ? "mojang -> mojang)" : " srg -> official)"));
Path mcInput = minecraftPatchedIntermediateAtJar;
Path mcOutput = minecraftPatchedJar;
Path forgeJar = getForgeJar().toPath();
Expand Down Expand Up @@ -572,6 +572,10 @@ public void applyLoomPatchVersion(Path target) throws IOException {
}
}

public boolean hasIntermediary() {
return !getExtension().isNeoForge();
}

public McpExecutor createMcpExecutor(Path cache) {
McpConfigProvider provider = getExtension().getMcpConfigProvider();
return new McpExecutor(project, minecraftProvider, cache, provider, type.mcpId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public List<Path> getMinecraftJars() {

@Override
public MappingsNamespace getOfficialNamespace() {
if (getExtension().isNeoForge()) return MappingsNamespace.MOJANG;
return MappingsNamespace.OFFICIAL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public List<Path> getMinecraftJars() {

@Override
public MappingsNamespace getOfficialNamespace() {
if (getExtension().isNeoForge()) return MappingsNamespace.MOJANG;
return MappingsNamespace.OFFICIAL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ private void remapJar(RemappedJars remappedJars, ConfigContext configContext) th
} catch (Exception e) {
throw new RuntimeException("Failed to remap JAR " + remappedJars.inputJar() + " with mappings from " + mappingConfiguration.tinyMappings, e);
} finally {
project.getLogger().lifecycle(":remapping minecraft (TinyRemapper, " + fromM + " -> " + toM + ")");
remapper.finish();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public IntermediaryMinecraftProvider(Project project, M minecraftProvider) {

@Override
public final MappingsNamespace getTargetNamespace() {
if (extension.isNeoForge()) return MappingsNamespace.MOJANG;
return MappingsNamespace.INTERMEDIARY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static TinyRemapper getTinyRemapper(Project project, SharedServiceManager
MemoryMappingTree mappingTree = extension.getMappingConfiguration().getMappingsService(serviceManager, mappingOption).getMappingTree();

if (fixRecords && !mappingTree.getSrcNamespace().equals(fromM)) {
throw new IllegalStateException("Mappings src namespace must match remap src namespace, expected " + fromM + " but got " + mappingTree.getSrcNamespace());
project.getLogger().warn("Mappings src namespace must match remap src namespace, expected " + fromM + " but got " + mappingTree.getSrcNamespace());
}

int intermediaryNsId = mappingTree.getNamespaceId(MappingsNamespace.INTERMEDIARY.toString());
Expand Down

0 comments on commit b5ae80e

Please sign in to comment.