Skip to content

Commit

Permalink
fix: wrong manifest used for gen1 projects
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceWalkerRS committed Jan 28, 2025
1 parent c28efa3 commit 8d7eb46
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
14 changes: 12 additions & 2 deletions src/main/java/net/ornithemc/ploceus/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ public class Constants {
public static final String CLIENT_NESTS_CONFIGURATION = "clientNests";
public static final String SERVER_NESTS_CONFIGURATION = "serverNests";

public static final String VERSIONS_MANIFEST_NAME = "ornithe";
public static final String VERSIONS_MANIFEST_URL = "https://ornithemc.net/mc-versions/version_manifest.json";
public static final String VERSIONS_MANIFEST_NAME_GEN1 = "skyrising";
public static final String VERSIONS_MANIFEST_URL_GEN1 = "https://skyrising.github.io/mc-versions/version_manifest.json";
public static final String VERSIONS_MANIFEST_NAME_GEN2 = "ornithe";
public static final String VERSIONS_MANIFEST_URL_GEN2 = "https://ornithemc.net/mc-versions/version_manifest.json";

public static String versionsManifestName(int generation) {
return generation == 1 ? VERSIONS_MANIFEST_NAME_GEN1 : VERSIONS_MANIFEST_NAME_GEN2;
}

public static String versionsManifestUrl(int generation) {
return generation == 1 ? VERSIONS_MANIFEST_URL_GEN1 : VERSIONS_MANIFEST_URL_GEN2;
}

public static final String CALAMUS_INTERMEDIARY_MAVEN_GROUP = MAVEN_GROUP;
public static String calamusGen1Mappings(GameSide side) {
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/net/ornithemc/ploceus/PloceusGradleExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public static PloceusGradleExtension get(Project project) {
private final Property<GameSide> side; // gen 1
private final Property<Integer> generation; // gen 2+

private int nextManifestPriority = -10;

public PloceusGradleExtension(Project project) {
this.project = project;
this.loom = LoomGradleExtension.get(this.project);
Expand Down Expand Up @@ -162,7 +164,6 @@ private void apply() {
project.getConfigurations().register(Constants.CLIENT_NESTS_CONFIGURATION);
project.getConfigurations().register(Constants.SERVER_NESTS_CONFIGURATION);

loom.getVersionsManifests().add(Constants.VERSIONS_MANIFEST_NAME, Constants.VERSIONS_MANIFEST_URL, -10);
loom.getLibraryProcessors().add((platform, context) -> new LibraryUpgrader(this, platform, context));
loom.addMinecraftJarProcessor(ExceptionPatcherProcessor.class, this);
loom.addMinecraftJarProcessor(SignaturePatcherProcessor.class, this);
Expand Down Expand Up @@ -190,7 +191,7 @@ private void apply() {
}
});

calamusGen1Provider();
switchToGen1();
}

public ExceptionsProvider getExceptionsProvider() {
Expand Down Expand Up @@ -401,7 +402,7 @@ public void serverOnlyMappings() {
side.set(GameSide.SERVER);
}

private void calamusGen1Provider() {
private void switchToGen1() {
loom.setIntermediateMappingsProvider(CalamusGen1Provider.class, provider -> {
provider.getSide()
.convention(side)
Expand All @@ -411,9 +412,11 @@ private void calamusGen1Provider() {
.finalizeValueOnRead();
provider.getRefreshDeps().set(project.provider(() -> LoomGradleExtension.get(project).refreshDeps()));
});

loom.getVersionsManifests().add(Constants.VERSIONS_MANIFEST_NAME_GEN1, Constants.VERSIONS_MANIFEST_URL_GEN1, nextManifestPriority--);
}

private void calamusGen2Provider() {
private void switchToGen2() {
loom.setIntermediateMappingsProvider(CalamusGen2Provider.class, provider -> {
provider.getGeneration()
.convention(generation)
Expand All @@ -423,6 +426,8 @@ private void calamusGen2Provider() {
.finalizeValueOnRead();
provider.getRefreshDeps().set(project.provider(() -> LoomGradleExtension.get(project).refreshDeps()));
});

loom.getVersionsManifests().add(Constants.VERSIONS_MANIFEST_NAME_GEN2, Constants.VERSIONS_MANIFEST_URL_GEN2, nextManifestPriority--);
}

public Property<GameSide> getSide() {
Expand All @@ -438,9 +443,9 @@ public void setGeneration(int generation) {
this.generation.set(generation);

if (generation == 1) {
calamusGen1Provider();
switchToGen1();
} else {
calamusGen2Provider();
switchToGen2();
}
}

Expand All @@ -455,9 +460,9 @@ public String normalizedMinecraftVersion() {
public VersionDetails minecraftVersionDetails() {
String versionId = minecraftVersion();

String manifestUrl = Constants.VERSIONS_MANIFEST_URL;
String manifestUrl = Constants.versionsManifestUrl(generation.get());
Path userCache = loom.getFiles().getUserCache().toPath();
Path manifestCache = userCache.resolve(Constants.VERSIONS_MANIFEST_NAME + "_versions_manifest.json");
Path manifestCache = userCache.resolve(Constants.versionsManifestName(generation.get()) + "_versions_manifest.json");

try {
if (!Files.exists(manifestCache)) {
Expand Down

0 comments on commit 8d7eb46

Please sign in to comment.