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

Only validate loom version when mixins are to be remapped with TinyRemapper #1168

Merged
merged 6 commits into from
Sep 8, 2024
Merged
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 @@ -81,7 +81,7 @@ public static ArtifactMetadata create(ArtifactRef artifact, String currentLoomVe
}
}

if (loomVersion != null && refmapRemapType != MixinRemapType.STATIC) {
if (loomVersion != null && refmapRemapType == MixinRemapType.STATIC) {
validateLoomVersion(loomVersion, currentLoomVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,17 @@ class ArtifactMetadataTest extends Specification {
result == type
where:
type | entries
MIXIN | ["hello.json": "{}"] // None Mod jar
MIXIN | ["fabric.mod.json": "{}"] // Fabric mod without manfiest file
MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "mixin")] // Fabric mod without remap type entry
STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod opt-in
MIXIN | ["hello.json": "{}"] // None Mod jar
MIXIN | ["fabric.mod.json": "{}"] // Fabric mod without manfiest file
MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Remap", "true")] // Fabric mod without remap type entry
MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "mixin")] // Fabric mod with remap type entry "mixin"
STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod with remap type entry "static"
}

// Test that a mod with the same or older version of loom can be read
def "Valid loom version"() {
given:
def zip = createMod(modLoomVersion, "mixin")
def zip = createModWithRemapType(modLoomVersion, "static")
when:
def metadata = createMetadata(zip, loomVersion)
then:
Expand All @@ -137,14 +138,14 @@ class ArtifactMetadataTest extends Specification {
"1.4" | "1.4.1"
"1.4" | "1.4.99"
"1.4" | "1.4.local"
"1.5" | "1.4.99"
"2.0" | "1.4.99"
"1.5" | "1.4.99"
"2.0" | "1.4.99"
}

// Test that a mod with the same or older version of loom can be read
def "Invalid loom version"() {
given:
def zip = createMod(modLoomVersion, "mixin")
def zip = createModWithRemapType(modLoomVersion, "static")
when:
def metadata = createMetadata(zip, loomVersion)
then:
Expand All @@ -158,9 +159,9 @@ class ArtifactMetadataTest extends Specification {
"1.4" | "2.4"
}

def "Accepts all Loom versions"() {
def "Accepts all Loom versions for remap 'false'"() {
given:
def zip = createMod(modLoomVersion, "static")
def zip = createModWithRemap(modLoomVersion, false)
when:
def metadata = createMetadata(zip, loomVersion)
then:
Expand All @@ -175,8 +176,34 @@ class ArtifactMetadataTest extends Specification {
"1.4" | "1.4.1"
"1.4" | "1.4.99"
"1.4" | "1.4.local"
"1.5" | "1.4.99"
"2.0" | "1.4.99"
"1.5" | "1.4.99"
"2.0" | "1.4.99"
// Usually invalid
"1.4" | "1.5"
"1.4" | "1.5.00"
"1.4" | "2.0"
"1.4" | "2.4"
}

def "Accepts all Loom versions for remap 'true'"() {
given:
def zip = createModWithRemap(modLoomVersion, true)
when:
def metadata = createMetadata(zip, loomVersion)
then:
metadata != null
where:
loomVersion | modLoomVersion
// Valid
"1.4" | "1.0.1"
"1.4" | "1.0.99"
"1.4" | "1.4"
"1.4" | "1.4.0"
"1.4" | "1.4.1"
"1.4" | "1.4.99"
"1.4" | "1.4.local"
"1.5" | "1.4.99"
"2.0" | "1.4.99"
// Usually invalid
"1.4" | "1.5"
"1.4" | "1.5.00"
Expand All @@ -201,10 +228,14 @@ class ArtifactMetadataTest extends Specification {
] | ["META-INF/MANIFEST.MF": manifest("Fabric-Loom-Known-Indy-BSMS", "com/example/Class,com/example/Another")] // two bsms
}

private static Path createMod(String loomVersion, String remapType) {
private static Path createModWithRemapType(String loomVersion, String remapType) {
return createZip(["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest(["Fabric-Loom-Version": loomVersion, "Fabric-Loom-Mixin-Remap-Type": remapType])])
}

private static Path createModWithRemap(String loomVersion, boolean remap) {
return createZip(["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest(["Fabric-Loom-Version": loomVersion, "Fabric-Loom-Mixin-Remap": remap ? "true" : "false"])])
}

private static ArtifactMetadata createMetadata(Path zip, String loomVersion = "1.4") {
return ArtifactMetadata.create(createArtifact(zip), loomVersion)
}
Expand Down