-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Forge & NeoForge
- Loading branch information
Showing
33 changed files
with
777 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import com.vanniktech.maven.publish.JavaLibrary | ||
import com.vanniktech.maven.publish.JavadocJar | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
|
||
plugins { | ||
java | ||
idea | ||
id("com.vanniktech.maven.publish") version("0.28.0") // `maven-publish` doesn't support new maven central | ||
} | ||
|
||
version = "1.0.1" | ||
group = "com.moulberry.mixinconstraints" | ||
|
||
idea.module.isDownloadSources = true | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(21)) | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://maven.fabricmc.net/") | ||
maven("https://repo.spongepowered.org/maven") // provides lexforge | ||
maven("https://maven.neoforged.net/releases") | ||
} | ||
|
||
val fabric: SourceSet by sourceSets.creating { | ||
compileClasspath += sourceSets.main.get().output | ||
} | ||
|
||
val forge: SourceSet by sourceSets.creating { | ||
compileClasspath += sourceSets.main.get().output | ||
} | ||
|
||
val neoforge: SourceSet by sourceSets.creating { | ||
compileClasspath += sourceSets.main.get().output | ||
} | ||
|
||
dependencies { | ||
implementation("org.spongepowered:mixin:0.8.5") | ||
implementation("org.ow2.asm:asm-tree:9.7") | ||
implementation("org.slf4j:slf4j-api:2.0.12") | ||
implementation("org.jetbrains:annotations:24.1.0") | ||
|
||
"fabricImplementation"("net.fabricmc:fabric-loader:0.15.0") | ||
|
||
"forgeImplementation"("net.minecraftforge:fmlloader:1.20.6-50.1.0") | ||
"forgeImplementation"("net.minecraftforge:fmlcore:1.20.6-50.1.0") | ||
|
||
"neoforgeImplementation"("net.neoforged.fancymodloader:loader:3.0.45") | ||
} | ||
|
||
tasks.jar { | ||
from(fabric.output) | ||
from(forge.output) | ||
from(neoforge.output) | ||
} | ||
|
||
tasks.register<Jar>("sourcesJar") { | ||
group = "build" | ||
archiveClassifier.set("sources") | ||
sourceSets.map { it.allSource }.forEach { | ||
from(it) | ||
} | ||
} | ||
|
||
mavenPublishing { | ||
configure(JavaLibrary(JavadocJar.Javadoc(), true)) | ||
|
||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
|
||
signAllPublications() | ||
|
||
coordinates("com.moulberry", "mixinconstraints", version.toString()) | ||
|
||
pom { | ||
name = "MixinConstraints" | ||
description = "Library to enable/disable mixins using annotations" | ||
url = "https://github.com/Moulberry/MixinConstraints" | ||
inceptionYear = "2024" | ||
packaging = "jar" | ||
|
||
licenses { | ||
license { | ||
name = "MIT License" | ||
url = "https://opensource.org/license/mit" | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
name = "Moulberry" | ||
url = "https://github.com/Moulberry" | ||
} | ||
} | ||
|
||
contributors { | ||
contributor { | ||
name = "rdh" | ||
url = "https://github.com/rhysdh540" | ||
} | ||
contributor { | ||
name = "IThundxr" | ||
url = "https://ithundxr.dev" | ||
} | ||
} | ||
|
||
issueManagement { | ||
system = "GitHub" | ||
url = "https://github.com/Moulberry/MixinConstraints/issues" | ||
} | ||
|
||
scm { | ||
url = "https://github.com/Moulberry/MixinConstraints/" | ||
connection = "scm:git:git://github.com/Moulberry/MixinConstraints.git" | ||
developerConnection = "scm:git:ssh://[email protected]/Moulberry/MixinConstraints.git" | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pluginManagement { | ||
repositories { | ||
maven("https://maven.wagyourtail.xyz/releases") | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "MixinConstraints" | ||
|
||
include("testmod") |
42 changes: 42 additions & 0 deletions
42
src/fabric/java/com/moulberry/mixinconstraints/FabricAbstractionsImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.moulberry.mixinconstraints; | ||
|
||
import com.moulberry.mixinconstraints.util.Abstractions; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.fabricmc.loader.api.Version; | ||
import net.fabricmc.loader.api.VersionParsingException; | ||
|
||
import static com.moulberry.mixinconstraints.util.MixinHacks.unchecked; | ||
|
||
public class FabricAbstractionsImpl extends Abstractions { | ||
@Override | ||
protected boolean isDevEnvironment() { | ||
return FabricLoader.getInstance().isDevelopmentEnvironment(); | ||
} | ||
|
||
@Override | ||
protected String getModVersion(String modId) { | ||
return FabricLoader.getInstance().getModContainer(modId) | ||
.map(container -> container.getMetadata() | ||
.getVersion() | ||
.getFriendlyString()) | ||
.orElse(null); | ||
} | ||
|
||
@Override | ||
protected boolean isVersionInRange(String version, String minVersion, String maxVersion) { | ||
try { | ||
Version currentVersion = Version.parse(version); | ||
Version min = minVersion == null ? null : Version.parse(minVersion); | ||
Version max = maxVersion == null ? null : Version.parse(maxVersion); | ||
|
||
if(min != null && max != null && min.compareTo(max) > 0) { | ||
throw new IllegalArgumentException("minVersion (" + minVersion + ") is greater than maxVersion (" + maxVersion + ")"); | ||
} | ||
|
||
return (min == null || currentVersion.compareTo(min) >= 0) && (max == null || currentVersion.compareTo(max) <= 0); | ||
|
||
} catch (VersionParsingException e) { | ||
throw unchecked(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.