Skip to content

Commit

Permalink
Default to neoform where needed.
Browse files Browse the repository at this point in the history
Tag as 6.2
  • Loading branch information
marchermans committed Sep 5, 2023
1 parent 8059394 commit af99dca
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public File findFile(ArtifactIdentifier artifact) throws IOException {
return null;
}

private File findMcp(String version) throws IOException {
Artifact mcp = Artifact.from("de.oceanlabs.mcp:mcp_config:" + version + "@zip");
File zip = cache("versions", version, "mcp.zip");
private File findNeoForm(String version) throws IOException {
Artifact mcp = Artifact.from("net.neoforged:neoform:" + version + "@zip");
File zip = cache("versions", version, "neoform.zip");
if (!zip.exists()) {
FileUtils.copyFile(MavenArtifactDownloader.manual(project, mcp.getDescriptor(), false), zip);
Utils.updateHash(zip);
Expand All @@ -154,17 +154,17 @@ private File findMcp(String version) throws IOException {
}

@Nullable
private File findMcpMappings(String version) throws IOException {
File mcp = findMcp(version);
private File findNeoFormMappings(String version) throws IOException {
File mcp = findNeoForm(version);
if (mcp == null)
return null;

File mappings = cache("versions", version, "mcp_mappings.tsrg");
HashStore cache = commonCache(cache("versions", version, "mcp_mappings.tsrg"));
File mappings = cache("versions", version, "neoform_mappings.tsrg");
HashStore cache = commonCache(cache("versions", version, "neoform_mappings.tsrg"));
cache.add(mcp);

if (!cache.isSame() || !mappings.exists()) {
MCPWrapperSlim wrapper = new MCPWrapperSlim(mcp);
NeoFormWrapperSlim wrapper = new NeoFormWrapperSlim(mcp);
wrapper.extractData(mappings, "mappings");
cache.save();
Utils.updateHash(mappings);
Expand Down Expand Up @@ -286,7 +286,7 @@ private File findDownloadEntry(String key, File target, String version, File jso
private File findExtra(String side, String version, boolean forceStable, File json) throws IOException {
boolean stable = v1_14_4.compareTo(MinecraftVersion.from(getMCVersion(version))) < 0;
File raw = findRaw(side, version, json);
File mappings = findMcpMappings(version);
File mappings = findNeoFormMappings(version);
File extra = cache("versions", version, side + "-extra" + (forceStable && !stable ? "-stable" : "") + ".jar");
HashStore cache = commonCache(cache("versions", version, side + "-extra" + (forceStable && !stable ? "-stable" : "") + ".jar"))
.add("raw", raw)
Expand All @@ -304,7 +304,7 @@ private File findExtra(String side, String version, boolean forceStable, File js
private File findSlim(String side, String version, boolean forceStable, File json) throws IOException {
boolean stable = v1_14_4.compareTo(MinecraftVersion.from(getMCVersion(version))) < 0;
File raw = findRaw(side, version, json);
File mappings = findMcpMappings(version);
File mappings = findNeoFormMappings(version);
File extra = cache("versions", version, side + "-slim" + (forceStable && !stable ? "-stable" : "") + ".jar");
HashStore cache = commonCache(cache("versions", version, side + "-slim" + (forceStable && !stable ? "-stable" : "") + ".jar"))
.add("raw", raw)
Expand Down Expand Up @@ -397,18 +397,18 @@ private File findData(String side, String version, boolean forceStable, File jso
}


private static class MCPWrapperSlim {
private static class NeoFormWrapperSlim {
private final File data;
private final MCPConfigV1 config;
public MCPWrapperSlim(File data) throws IOException {
public NeoFormWrapperSlim(File data) throws IOException {
this.data = data;
this.config = MCPConfigV2.getFromArchive(data);
}

public void extractData(File target, String... path) throws IOException {
String name = config.getData(path);
if (name == null)
throw new IOException("Unknown MCP Entry: " + Joiner.on("/").join(path));
throw new IOException("Unknown NeoForm Entry: " + Joiner.on("/").join(path));

try (ZipFile zip = new ZipFile(data)) {
Utils.extractFile(zip, name, target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.File;
import java.util.Set;

@Deprecated()
class MCPChannelProvider implements ChannelProvider {
@Nonnull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void setConfig(Provider<String> value) {
if (s.indexOf(':') != -1) { // Full artifact
return Artifact.from(s);
} else {
return Artifact.from("de.oceanlabs.mcp:mcp_config:" + s + "@zip");
return Artifact.from("net.neoforged:neoform:" + s + "@zip");
}
}));
}
Expand Down
2 changes: 1 addition & 1 deletion src/mcp/java/net/minecraftforge/gradle/mcp/MCPPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void apply(@Nonnull Project project) {

downloadConfig.configure(task -> {
task.getConfig().set(extension.getConfig().map(Artifact::getDescriptor));
task.getOutput().set(project.getLayout().getBuildDirectory().file("mcp_config.zip"));
task.getOutput().set(project.getLayout().getBuildDirectory().file("neoform.zip"));
});
setupMCP.configure(task -> {
task.getPipeline().set(extension.getPipeline());
Expand Down
24 changes: 12 additions & 12 deletions src/mcp/java/net/minecraftforge/gradle/mcp/MCPRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public class MCPRepo extends BaseRepo {
private static MCPRepo INSTANCE = null;
private static final String GROUP_MINECRAFT = "net.minecraft";
private static final String NAMES_MINECRAFT = "^(client|server|joined|mappings_[a-z_]+)$";
private static final String GROUP_MCP = "de.oceanlabs.mcp";
private static final String NAMES_MCP = "^(mcp_config)$";
private static final String GROUP_NEOFORM = "net.neoforged";
private static final String NAMES_NEOFORM = "^(neoform)$";
private static final String STEP_MERGE = "merge"; //TODO: Design better way to get steps output, for now hardcode
private static final String STEP_RENAME = "rename";

Expand All @@ -105,7 +105,7 @@ private MCPRepo(Project project, File cache, Logger log) {

private static MCPRepo getInstance(Project project) {
if (INSTANCE == null)
INSTANCE = new MCPRepo(project, Utils.getCache(project, "mcp_repo"), project.getLogger());
INSTANCE = new MCPRepo(project, Utils.getCache(project, "neoform_repo"), project.getLogger());
return INSTANCE;
}
public static void attach(Project project) {
Expand All @@ -130,17 +130,17 @@ File cacheMC(String side, String version, @Nullable String classifier, String ex

private File cacheMCP(String version, @Nullable String classifier, String ext) {
if (classifier != null)
return cache("de", "oceanlabs", "mcp", "mcp_config", version, "mcp_config-" + version + '-' + classifier + '.' + ext);
return cache("de", "oceanlabs", "mcp", "mcp_config", version, "mcp_config-" + version + '.' + ext);
return cache("net", "neoforged", "neoform", version, "neoform-" + version + '-' + classifier + '.' + ext);
return cache("net", "neoforged", "neoform", version, "neoform-" + version + '.' + ext);
}
private File cacheMCP(String version) {
return cache("de", "oceanlabs", "mcp", "mcp_config", version);
return cache("net", "neoforged", "neoform", version);
}

@Override
protected void configureFilter(RepositoryContentDescriptor filter) {
// Escape the dots in the group because byRegex versions are completely regex, not just the module
filter.includeModuleByRegex(GROUP_MCP.replace(".", "\\."), NAMES_MCP);
filter.includeModuleByRegex(GROUP_NEOFORM.replace(".", "\\."), NAMES_NEOFORM);
filter.includeModuleByRegex(GROUP_MINECRAFT.replace(".", "\\."), NAMES_MINECRAFT);
}

Expand All @@ -149,8 +149,8 @@ public File findFile(ArtifactIdentifier artifact) throws IOException {
String name = artifact.getName();
String group = artifact.getGroup();

if (group.equals(GROUP_MCP)) {
if (!name.matches(NAMES_MCP))
if (group.equals(GROUP_NEOFORM)) {
if (!name.matches(NAMES_NEOFORM))
return null;
} else if (group.equals(GROUP_MINECRAFT)) {
if (!name.matches(NAMES_MINECRAFT))
Expand Down Expand Up @@ -180,7 +180,7 @@ public File findFile(ArtifactIdentifier artifact) throws IOException {
case "extra": return findExtra(name, version);
}
}
} else if (group.equals(GROUP_MCP)) {
} else if (group.equals(GROUP_NEOFORM)) {
/* Gradle fucks up caching for anything that isnt a zip or a jar, this is fucking annoying we can't do this.
MappingFile.Format format = MappingFile.Format.get(ext);
if (format != null) {
Expand All @@ -201,12 +201,12 @@ public File findFile(ArtifactIdentifier artifact) throws IOException {

HashStore commonHash(File mcp) {
return new HashStore(this.getCacheRoot())
.add("mcp", mcp);
.add("neoform", mcp);
}

@Nullable
File getMCP(String version) {
return MavenArtifactDownloader.manual(project, "de.oceanlabs.mcp:mcp_config:" + version + "@zip", false);
return MavenArtifactDownloader.manual(project, "net.neoforged:neoform:" + version + "@zip", false);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private Patcher getParents() {
}

String artifact = isPatcher ? (GROUP + ":" + NAME +":" + VERSION + ':' + classifier) :
("de.oceanlabs.mcp:mcp_config:" + VERSION + "@zip");
("net.neoforged:neoform:" + VERSION + "@zip");
boolean patcher = isPatcher;
Patcher last = null;
while (artifact != null) {
Expand Down Expand Up @@ -1544,7 +1544,7 @@ private class MCP {
private MCP(File data, String artifact) {
this.artifact = Artifact.from(artifact);
try {
File mcp_dir = MinecraftUserRepo.this.cache("mcp", this.artifact.getVersion());
File mcp_dir = MinecraftUserRepo.this.cache("neoform", this.artifact.getVersion());
this.wrapper = new MCPWrapper(data, mcp_dir) {
public MCPRuntime getRuntime(Project project, String side) {
MCPRuntime ret = runtimes.get(side);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void apply(@Nonnull Project project) {
String mcVer = (String) project.getExtensions().getExtraProperties().get("MC_VERSION");
String mcpVer = (String) project.getExtensions().getExtraProperties().get("MCP_VERSION");
// TODO: convert to constant and use String.format
downloadMcpConfig.configure(t -> t.setArtifact("de.oceanlabs.mcp:mcp_config:" + mcpVer + "@zip"));
downloadMcpConfig.configure(t -> t.setArtifact("net.neoforged:neoform:" + mcpVer + "@zip"));
downloadMCMeta.configure(t -> t.getMCVersion().convention(mcVer));

// Register reobfJar for the 'jar' task
Expand Down

0 comments on commit af99dca

Please sign in to comment.