Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set both resources and classes directory to the same directory #179

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ public void run() {
}
}
}

if (extension.isForge() && extension.getForgeProvider().getVersion().getForgeMajorVersion() >= 49) {
// Merge all source set resources and classes into the same directory
// This is required for Forge 1.20.3+ to work properly
// This is really a hack in itself, thank you Forge
getProject().getExtensions().getByType(JavaPluginExtension.class).getSourceSets().forEach(sourceSet -> {
var dir = getProject().getLayout().getBuildDirectory().dir("sourcesSets/%s".formatted(sourceSet.getName()));
sourceSet.getOutput().setResourcesDir(dir);
sourceSet.getJava().getDestinationDirectory().set(dir);
});
}
});

finalizedBy("idea", "genIdeaWorkspace");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ public static final class ForgeVersion {
private final String combined;
private final String minecraftVersion;
private final String forgeVersion;
private final int forgeMajorVersion;

public ForgeVersion(String combined) {
this.combined = combined;

if (combined == null) {
this.minecraftVersion = "NO_VERSION";
this.forgeVersion = "NO_VERSION";
this.forgeMajorVersion = -1;
return;
}

Expand All @@ -105,6 +107,20 @@ public ForgeVersion(String combined) {
this.minecraftVersion = "NO_VERSION";
this.forgeVersion = combined;
}

int major;

try {
if (this.forgeVersion.contains(".")) {
major = Integer.parseInt(this.forgeVersion.substring(0, this.forgeVersion.indexOf('.')));
} else {
major = Integer.parseInt(this.forgeVersion);
}
} catch (NumberFormatException e) {
major = -1;
}

this.forgeMajorVersion = major;
}

public String getCombined() {
Expand All @@ -118,5 +134,9 @@ public String getMinecraftVersion() {
public String getForgeVersion() {
return forgeVersion;
}

public int getForgeMajorVersion() {
return forgeMajorVersion;
}
}
}
Loading