Skip to content
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
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

Screenshots, made simple

<img alt="Available for Fabric" src="https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/compact/supported/fabric_vector.svg">

<img alt="Won't support Forge" src="https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/compact/unsupported/forge_vector.svg">

<img alt="Made by Spirit Studios" src="https://raw.githubusercontent.com/SpiritGameStudios/.github/main/assets/brand/badge/compact.svg">

![Minimal Powered by OneConfig](https://polyfrost.org/media/branding/badges/badge_3.svg)

<img alt="As seen on ModFest 1.21" height="40" src="https://badger-api-staging.worldwidepixel.ca/compact?gradientStart=4B2018&gradientEnd=220D09&lineOne=As+seen+on&lineTwo=ModFest+1.21&colourOne=FFFFFF&colourTwo=de634c&iconUrl=https://raw.githubusercontent.com/ModFest/art/refs/heads/v2/icon/svg/1.21/transparent.svg">

<img alt="Featured in BlanketCon '25" height="40" src="https://raw.githubusercontent.com/ModFest/art/refs/heads/v2/badge/svg/bc25/compact.svg">
Expand All @@ -25,15 +23,10 @@ With Snapper, you can:
- ~~Not having to install a mod from an EXE~~

## ❓ FAQ
* Forge? <br/>
No. Please do not ask us for a forge port.

* Do you plan to / Could you add `X`? <br/>
If you want to suggest something, join the [Discord](https://discord.gg/TTmx7d2axf) or make a [GitHub issue](https://github.com/SpiritGameStudios/Snapper/issues).

* Can you port/backport to `X` version? <br/>
Probably not. Multi-version projects are hard :<

* My screenshots aren't copying and my game is logging `Failed to get clipboard`. <br />
The official Minecraft launcher doesn't have all of the necessary tools provided by a standard Java runtime. This may cause issues with copying for some users on Windows & Linux. Other launchers are not affected.

Expand All @@ -47,4 +40,4 @@ Special thanks to our quality assurance team:

---

Snapper's image uploading is powered by the wonderful (and [open-source](https://github.com/axolotlclient)) [AxolotlClient](https://modrinth.com/mod/axolotlclient) and governed by their [terms of use](https://axolotlclient.com/terms). Agreement is opt-in and you may revoke it at any time.
Snapper's image uploading is powered by the wonderful (and [open-source](https://github.com/axolotlclient)) [AxolotlClient](https://modrinth.com/mod/axolotlclient) and governed by their [terms of use](https://axolotlclient.com/terms). Agreement is opt-in and you may revoke it at any time.
159 changes: 120 additions & 39 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,37 +1,84 @@
@file:Suppress("UnstableApiUsage", "PropertyName")

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import dev.deftu.gradle.utils.GameSide
import dev.deftu.gradle.utils.version.MinecraftVersions

plugins {
java
alias(libs.plugins.fabric.loom)
alias(libs.plugins.minotaur)
id("xyz.wagyourtail.jvmdowngrader") version "1.3.3"
kotlin("jvm")
id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders.
id("dev.deftu.gradle.tools.configure")
id("dev.deftu.gradle.tools.repo")
id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources.
id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files.
id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those!
id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you.
id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth.
}

class ModInfo {
val id = property("mod.id").toString()
val group = property("mod.group").toString()
val version = property("mod.version").toString()
}
toolkitLoomHelper {
useOneConfig {
version = "1.0.0-alpha.134"
loaderVersion = "1.1.0-alpha.48"

usePolyMixin = true
polyMixinVersion = "0.8.4+build.6"

val mod = ModInfo()
applyLoaderTweaker = true

version = "${mod.version}+${libs.versions.minecraft.get()}"
group = mod.group
for (module in arrayOf("hud", "commands", "config", "config-impl", "events", "internal", "ui", "utils")) {
+module
}
}

base.archivesName = mod.id
useDevAuth("1.2.1")
useMixinExtras("0.4.1")

// Turns off the server-side run configs, as we're building a client-sided mod.
disableRunConfigs(GameSide.SERVER)

// Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes.
if (!mcData.isNeoForge) {
useMixinRefMap(modData.id)
}

if (mcData.isForge) {
// Configures the Mixin tweaker if we are building for Forge.
useForgeMixin(modData.id)
}
}

val mod_id = property("mod.id").toString()

loom {
splitEnvironmentSourceSets()
if (mcData.version >= MinecraftVersions.VERSION_1_19 && mcData.isFabric) {
splitEnvironmentSourceSets()

mods.create(mod.id) {
sourceSet(sourceSets["main"])
sourceSet(sourceSets["client"])
mods.create(mod_id) {
sourceSet(sourceSets["main"])
sourceSet(sourceSets["client"])
}
}
}

accessWidenerPath = file("src/main/resources/snapper.accesswidener")
if (mcData.version < MinecraftVersions.VERSION_1_19 || mcData.isForgeLike) {
sourceSets {
main {
val thisProject = if (mcData.version == MinecraftVersions.VERSION_1_21_5 && mcData.isFabric) rootProject else project
java {
srcDirs(thisProject.file("src/client/java"), thisProject.file("src/main/java"))
}
resources {
srcDirs(thisProject.file("src/client/resources"), thisProject.file("src/main/resources"))
}
}
}
}

repositories {
mavenCentral()
maven("https://maven.spiritstudios.dev/releases/")
maven("https://maven.bawnorton.com/releases")
maven("https://moehreag.duckdns.org/maven/releases") {
content {
includeGroup("io.github.axolotlclient.AxolotlClient")
Expand All @@ -41,32 +88,64 @@ repositories {
}

dependencies {
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn) { classifier("v2") })
modImplementation(libs.fabric.loader)
fun Dependency?.applyExclusions() {
check(this != null && this is ModuleDependency)
exclude(module = "fabric-loader")
}

modImplementation(libs.fabric.api)
/**
* A pair of mappings used for the given environment.
*
* The first value is the mappings string, and the second value is whether these should be forced despite the requested configuration.
*/
val defaultMappings: Pair<String, Boolean> = when {
mcData.isLegacyFabric -> "net.legacyfabric:yarn:${mcData.dependencies.legacyFabric.legacyYarnVersion}" to true
mcData.isFabric -> "net.fabricmc:yarn:${mcData.dependencies.fabric.yarnVersion}:v2" to false
mcData.isForge && mcData.version <= MinecraftVersions.VERSION_1_15_2 -> mcData.dependencies.forge.mcpDependency to true
else -> "official" to false
}
val mappingsNotation = defaultMappings.first

mappings(when(mappingsNotation) {
"official", "mojang", "mojmap" -> loom.officialMojangMappings()

"official-like" -> {
if (mcData.version <= MinecraftVersions.VERSION_1_12_2) {
if (mcData.isForge) {
mcData.dependencies.forge.mcpDependency
} else {
repositories {
maven("https://raw.githubusercontent.com/BleachDev/cursed-mappings/main/")
}

"net.legacyfabric:yarn:${mcData.version}+build.mcp"
}
} else loom.officialMojangMappings()
}

include(libs.bundles.specter)
modImplementation(libs.bundles.specter)
else -> mappingsNotation
}).applyExclusions()

implementation(libs.objc.bridge)
//TODO remove the above once https://github.com/Deftu/Gradle-Toolkit/pull/24 is merged

include("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.3.3")
implementation("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.3.3")
annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.3.3")
implementation(libs.objc.bridge)
}

tasks.processResources {
val map = mapOf(
"mod_id" to mod.id,
"mod_version" to mod.version,
"fabric_loader_version" to libs.versions.fabric.loader.get(),
"minecraft_version" to libs.versions.minecraft.get()
)
tasks {
fatJar {
sourceSets.findByName("client")?.let { clientSourceSet ->
from(sourceSets.getByName("main").output, clientSourceSet.output)
}
}
downgradeJar {
inputFile = this@tasks.named<ShadowJar>("fatJar").get().archiveFile
archiveClassifier = "downgraded-8-shaded"
}

inputs.properties(map)
filesMatching("fabric.mod.json") { expand(map) }
remapJar {
inputFile.set(shadeDowngradedApi.get().archiveFile)
dependsOn(shadeDowngradedApi)
}
}

java {
Expand All @@ -82,7 +161,7 @@ tasks.withType<JavaCompile> {
}

tasks.jar { from("LICENSE") { rename { "${it}_${base.archivesName.get()}" } } }

/*
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(mod.id)
Expand All @@ -94,4 +173,6 @@ modrinth {
dependencies {
required.version("fabric-api", libs.versions.fabric.api.get())
}
}
}

*/
8 changes: 6 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.configureoncommand=true
org.gradle.parallel.threads=4
loom.ignoreDependencyLoomVersionValidation=true

mod.name=Snapper
mod.version = 1.1
mod.group = dev.spiritstudios
mod.id = snapper

deps.minecraft=1.21.4
deps.loader=0.16.5
dgt.loom.mappings.use=false
19 changes: 1 addition & 18 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
[versions]
fabric_loom = "1.11-SNAPSHOT"
minotaur = "2.+"

minecraft = "1.21.4"
yarn = "1.21.4+build.3"

fabric_loader = "0.16.14"
fabric_api = "0.119.3+1.21.4"

specter = "1.1.3"
specter = "1.1.7"
objc_bridge = "1.0.0"

[plugins]
fabric_loom = { id = "fabric-loom", version.ref = "fabric_loom" }
minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" }

[libraries]
minecraft = { group = "mojang", name = "minecraft", version.ref = "minecraft" }
yarn = { group = "net.fabricmc", name = "yarn", version.ref = "yarn" }

fabric_loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric_loader" }
fabric_api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric_api" }

specter_config = { group = "dev.spiritstudios.specter", name = "specter-config", version.ref = "specter" }
specter_core = { group = "dev.spiritstudios.specter", name = "specter-core", version.ref = "specter" }
Expand Down
76 changes: 76 additions & 0 deletions root.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
plugins {
id("dev.deftu.gradle.multiversion-root")
}

preprocess {
// Adding new versions/loaders can be done like so:
// For each version, we add a new wrapper around the last from highest to lowest.
// Each mod loader needs to link up to the previous version's mod loader so that the mappings can be processed from the previous version.
// "1.12.2-forge"(11202, "srg") {
// "1.8.9-forge"(10809, "srg")
// }

"1.21.5-fabric"(1_21_05, "yarn") {
"1.21.5-neoforge"(1_21_05, "srg") {
"1.21.4-neoforge"(1_21_04, "srg") {
"1.21.4-fabric"(1_21_04, "yarn") {
"1.21.3-fabric"(1_21_04, "yarn") {
"1.21.3-neoforge"(1_21_03, "srg") {
"1.21.2-neoforge"(1_21_02, "srg") {
"1.21.2-fabric"(1_21_02, "yarn") {
"1.21.1-fabric"(1_21_01, "yarn") {
"1.21.1-neoforge"(1_21_01, "srg") {
"1.20.6-neoforge"(1_20_06, "srg") {
"1.20.6-fabric"(1_20_06, "yarn") {
"1.20.4-fabric"(1_20_04, "yarn") {
"1.20.4-neoforge"(1_20_04, "srg") {
"1.20.4-forge"(1_20_04, "srg") {
"1.20.1-forge"(1_20_01, "srg") {
"1.20.1-fabric"(1_20_01, "yarn") {
"1.19.4-fabric"(1_19_04, "yarn") {
"1.19.4-forge"(1_19_04, "srg") {
"1.19.2-forge"(1_19_02, "srg") {
"1.19.2-fabric"(1_19_02, "yarn") {
"1.18.2-fabric"(1_18_02, "yarn") {
"1.18.2-forge"(1_18_02, "srg") {
"1.17.1-forge"(1_17_01, "srg") {
"1.17.1-fabric"(1_17_01, "yarn") {
"1.16.5-fabric"(1_16_05, "yarn"){
"1.16.5-forge"(1_16_05, "srg") {
"1.12.2-forge"(1_12_02, "srg") {
"1.12.2-fabric"(1_12_02, "yarn") {
"1.8.9-fabric"(1_08_09, "yarn"){
"1.8.9-forge"(1_08_09, "srg")
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

strictExtraMappings.set(true)
}
Loading
Loading