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

[WIP] Add Forge 1.21 and 1.20.6 #19

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
19 changes: 17 additions & 2 deletions src/app/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use miette::{IntoDiagnostic, Result};
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use version_resolver::minecraft::{JavaVersion, MinecraftVersion};
use version_resolver::maven::{resolve_latest_version, resolve_matching_version, MavenLibrary};

pub async fn generate(app: &super::GeneratorApp) -> Result<()> {
Expand Down Expand Up @@ -66,6 +67,10 @@ pub async fn generate(app: &super::GeneratorApp) -> Result<()> {
context.put("FORGE_DATA_PACK_FORMAT", data_pack_format);
}

if game_version >= MinecraftVersion::Minecraft1_20_6 {
context.define("forge_jopt_hack");
}

// Constants
context.put("LOOM_VERSION", crate::versions::LOOM_VERSION);
context.put("PLUGIN_VERSION", crate::versions::PLUGIN_VERSION);
Expand Down Expand Up @@ -128,6 +133,11 @@ pub async fn generate(app: &super::GeneratorApp) -> Result<()> {
)));
}
platforms.push("forge");

// As of 1.21, Forge uses Mixin 0.8.5 which doesn't have CompatibilityLevel.JAVA_21.
if game_version.java_version() == JavaVersion::Java9OrNewer(21) {
context.put("MIXIN_COMPAT_LEVEL", JavaVersion::Java9OrNewer(17).mixin_compat_level());
}
}

if app.subprojects.neoforge {
Expand All @@ -139,7 +149,7 @@ pub async fn generate(app: &super::GeneratorApp) -> Result<()> {
std::future::ready(Ok(version)),
)));
}
if game_version == version_resolver::minecraft::MinecraftVersion::Minecraft1_20_4 {
if game_version == MinecraftVersion::Minecraft1_20_4 {
context.put("NEOFORGE_METADATA_FILE_NAME", "mods.toml");
files.push(Box::pin(neoforge::mods_toml_files(client.clone())));
} else {
Expand Down Expand Up @@ -190,7 +200,7 @@ pub async fn generate(app: &super::GeneratorApp) -> Result<()> {
std::future::ready(Ok(version)),
)));
}
if game_version == version_resolver::minecraft::MinecraftVersion::Minecraft1_20_4 {
if game_version == MinecraftVersion::Minecraft1_20_4 {
context.put("NEOFORGE_METADATA_FILE_NAME", "mods.toml");
files.push(Box::pin(neoforge_only::mods_toml_files(client.clone())));
} else {
Expand All @@ -209,6 +219,11 @@ pub async fn generate(app: &super::GeneratorApp) -> Result<()> {
)));
}
file_name_parts.push("forge-only".to_owned());

// As of 1.21, Forge uses Mixin 0.8.5 which doesn't have CompatibilityLevel.JAVA_21.
if game_version.java_version() == JavaVersion::Java9OrNewer(21) {
context.put("MIXIN_COMPAT_LEVEL", JavaVersion::Java9OrNewer(17).mixin_compat_level());
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/templates/forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ configurations {
canBeResolved = true
canBeConsumed = false
}
//% if forge_jopt_hack

// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
configureEach {
resolutionStrategy {
force 'net.sf.jopt-simple:jopt-simple:5.0.4'
}
}
//% end
}

dependencies {
Expand Down
11 changes: 11 additions & 0 deletions src/templates/forge_only/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ loom {
mixinConfig '%MOD_ID%.mixins.json'
}
}
//% if forge_jopt_hack

// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
configurations {
configureEach {
resolutionStrategy {
force 'net.sf.jopt-simple:jopt-simple:5.0.4'
}
}
}
//% end

repositories {
// Add repositories to retrieve artifacts from in here.
Expand Down
8 changes: 4 additions & 4 deletions version_resolver/src/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ impl MinecraftVersion {
Self::Minecraft1_20_2 => Some("48"),
Self::Minecraft1_20_4 => Some("49"),
Self::Minecraft1_20_5 => None,
Self::Minecraft1_20_6 => None,
Self::Minecraft1_21 => None,
Self::Minecraft1_20_6 => Some("50"),
Self::Minecraft1_21 => Some("51"),
}
}

Expand Down Expand Up @@ -194,8 +194,8 @@ impl MinecraftVersion {
Self::Minecraft1_20_2 => Some("18"),
Self::Minecraft1_20_4 => Some("22"),
Self::Minecraft1_20_5 => None,
Self::Minecraft1_20_6 => None,
Self::Minecraft1_21 => None,
Self::Minecraft1_20_6 => Some("32"),
Self::Minecraft1_21 => Some("34"),
}
}

Expand Down