Skip to content

Commit

Permalink
yipeee
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Nov 1, 2024
1 parent 82569e6 commit b07f1e4
Show file tree
Hide file tree
Showing 43 changed files with 815 additions and 99 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
changes:
- fix auto gui scaling looking broken with weird window sizes
- fix auto gui scaling looking broken with weird window sizes
- **add support for forge & neoforge!!!!**
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# WayFix

[![Supports minecraft versions from 1.16](https://notcoded.needs.rest/r/badge_minecraft_1.16plus.svg)](https://minecraft.net) [![Cloth Config API](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/requires/cloth-config-api_vector.svg)](https://www.modrinth.com/mod/cloth-config) ![Won't support forge](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/unsupported/forge_vector.svg)
[![Supports minecraft versions from 1.16](https://notcoded.needs.rest/r/badge_minecraft_1.16plus.svg)](https://minecraft.net) [![Cloth Config API](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/requires/cloth-config-api_vector.svg)](https://www.modrinth.com/mod/cloth-config)

Fixes multiple issues regarding Wayland compatibility for Minecraft.

Expand Down
61 changes: 21 additions & 40 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
plugins {
id("fabric-loom") version "1.8-SNAPSHOT"
id("dev.architectury.loom")
id("architectury-plugin")
id("com.modrinth.minotaur") version "2.+"
}

val modName = property("mod.name").toString()
version = "${property("mod.version")}" + "+" + "${property("mod.version_name")}"
group = property("mod.maven_group").toString()

val minecraft = stonecutter.current.version
version = "${mod.version}+${mod.version_name}-common"
group = mod.maven_group

base {
archivesName.set(modName)
archivesName.set(mod.name)
}

architectury.common(stonecutter.tree.branches.mapNotNull {
if (stonecutter.current.project !in it) null
else it.prop("loom.platform")
})

repositories {
maven("https://maven.shedaniel.me/")
maven("https://maven.terraformersmc.com/releases/")
}

dependencies {
minecraft("com.mojang:minecraft:${property("deps.minecraft")}")
mappings("net.fabricmc:yarn:${property("deps.yarn_mappings")}:v2")
modImplementation("net.fabricmc:fabric-loader:${property("deps.fabric_loader")}")
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:${mod.dep("yarn_mappings")}:v2")
modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}")

modImplementation("me.shedaniel.cloth:cloth-config-fabric:${property("deps.cloth_config_version")}")
modImplementation("com.terraformersmc:modmenu:${property("deps.mod_menu_version")}")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${mod.dep("cloth_config_version")}")
modImplementation("com.terraformersmc:modmenu:${mod.dep("mod_menu_version")}")

implementation("org.lwjgl:lwjgl-glfw:3.3.2")
}
Expand All @@ -34,44 +39,20 @@ loom {
options.put("mark-corresponding-synthetics", "1")
}
}

runConfigs.all {
ideConfigGenerated(true)
vmArgs("-Dmixin.debug.export=true")
runDir = "../../run"
}
}

val target = ">=${property("mod.min_target")}- <=${property("mod.max_target")}"

tasks.processResources {
val expandProps = mapOf(
"version" to project.version,
"minecraftVersion" to target,
"javaVersion" to project.property("deps.java")
)

filesMatching("fabric.mod.json") {
expand(expandProps)
}

inputs.properties(expandProps)
}

java {
withSourcesJar()

val javaVersion = if (project.property("deps.java") == "9") JavaVersion.VERSION_1_9 else JavaVersion.VERSION_17
val javaVersion = if (mod.dep("java") == "9") JavaVersion.VERSION_1_9 else JavaVersion.VERSION_17

sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

tasks.register<Copy>("buildAndCollect") {
group = "build"
from(tasks.remapJar.get().archiveFile)
into(rootProject.layout.buildDirectory.file("libs"))
dependsOn("build")
tasks.build {
group = "versioned"
description = "Must run through 'chiseledBuild'"
}


Expand All @@ -92,5 +73,5 @@ modrinth {
}

val changes = rootProject.file("CHANGES.md").readText()
changelog = if (project.property("deps.java") == "9") "# Requires Java 9+\n\n$changes" else changes
changelog = if (mod.dep("java") == "9") "# Requires Java 9+\n\n$changes" else changes
}
8 changes: 8 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "2.0.20"
}

repositories {
mavenCentral()
}
32 changes: 32 additions & 0 deletions buildSrc/src/main/kotlin/build-extensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.kotlin.dsl.maven
import org.gradle.language.jvm.tasks.ProcessResources

val Project.mod: ModData get() = ModData(this)
fun Project.prop(key: String): String? = findProperty(key)?.toString()
fun String.upperCaseFirst() = replaceFirstChar { if (it.isLowerCase()) it.uppercaseChar() else it }

fun RepositoryHandler.strictMaven(url: String, alias: String, vararg groups: String) = exclusiveContent {
forRepository { maven(url) { name = alias } }
filter { groups.forEach(::includeGroup) }
}

fun ProcessResources.properties(files: Iterable<String>, vararg properties: Pair<String, Any>) {
for ((name, value) in properties) inputs.property(name, value)
filesMatching(files) {
expand(properties.toMap())
}
}

@JvmInline
value class ModData(private val project: Project) {
val id: String get() = requireNotNull(project.prop("mod.id")) { "Missing 'mod.id'" }
val name: String get() = requireNotNull(project.prop("mod.name")) { "Missing 'mod.name'" }
val version: String get() = requireNotNull(project.prop("mod.version")) { "Missing 'mod.version'" }
val version_name: String get() = requireNotNull(project.prop("mod.version_name")) { "Missing 'mod.version_name'" }
val maven_group: String get() = requireNotNull(project.prop("mod.maven_group")) { "Missing 'mod.maven_group'" }

fun prop(key: String) = requireNotNull(project.prop("mod.$key")) { "Missing 'mod.$key'" }
fun dep(key: String) = requireNotNull(project.prop("deps.$key")) { "Missing 'deps.$key'" }
}
128 changes: 128 additions & 0 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
@file:Suppress("UnstableApiUsage")

plugins {
id("dev.architectury.loom")
id("architectury-plugin")
id("com.github.johnrengelman.shadow")
}

val loader = prop("loom.platform")!!
val minecraft = stonecutter.current.version
val common: Project = requireNotNull(stonecutter.node.sibling("")) {
"No common project for $project"
}

version = "${common.mod.version}+${common.mod.version_name}-${loader}"
group = "${common.mod.maven_group}.$loader"

base {
archivesName.set(common.mod.name)
}

repositories {
maven("https://maven.shedaniel.me/")
maven("https://maven.terraformersmc.com/releases/")
}

architectury {
platformSetupLoomIde()
fabric()
}

val commonBundle: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
}

val shadowBundle: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
}

configurations {
compileClasspath.get().extendsFrom(commonBundle)
runtimeClasspath.get().extendsFrom(commonBundle)
get("developmentFabric").extendsFrom(commonBundle)
}

dependencies {
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:${common.mod.dep("yarn_mappings")}:v2")
modImplementation("net.fabricmc:fabric-loader:${common.mod.dep("fabric_loader")}")

modImplementation("me.shedaniel.cloth:cloth-config-fabric:${common.mod.dep("cloth_config_version")}")
modImplementation("com.terraformersmc:modmenu:${common.mod.dep("mod_menu_version")}")

implementation("org.lwjgl:lwjgl-glfw:3.3.2")

commonBundle(project(common.path, "namedElements")) { isTransitive = false }
shadowBundle(project(common.path, "transformProductionFabric")) { isTransitive = false }
}

loom {
decompilers {
get("vineflower").apply { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}

runConfigs.all {
isIdeConfigGenerated = true
runDir = "../../../run"
vmArgs("-Dmixin.debug.export=true")
}
}

val target = ">=${common.property("mod.min_target")}- <=${common.property("mod.max_target")}"

tasks.processResources {
val expandProps = mapOf(
"version" to version,
"minecraftVersion" to target,
"javaVersion" to common.mod.dep("java")
)

filesMatching("fabric.mod.json") {
expand(expandProps)
}

inputs.properties(expandProps)
}

tasks.shadowJar {
configurations = listOf(shadowBundle)
archiveClassifier = "dev-shadow"
}

tasks.remapJar {
injectAccessWidener = true
input = tasks.shadowJar.get().archiveFile
archiveClassifier = null
dependsOn(tasks.shadowJar)
}

tasks.jar {
archiveClassifier = "dev"
}

java {
withSourcesJar()

val javaVersion = if (common.property("deps.java") == "9") JavaVersion.VERSION_1_9 else JavaVersion.VERSION_17

sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

tasks.build {
group = "versioned"
description = "Must run through 'chiseledBuild'"
}

tasks.register<Copy>("buildAndCollect") {
group = "versioned"
description = "Must run through 'chiseledBuild'"
from(tasks.remapJar.get().archiveFile, tasks.remapSourcesJar.get().archiveFile)
into(rootProject.layout.buildDirectory.file("libs/${mod.version}/$loader"))
dependsOn("build")
}
1 change: 1 addition & 0 deletions fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=fabric
11 changes: 11 additions & 0 deletions fabric/src/main/java/net/notcoded/wayfix/fabric/WayFixFabric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.notcoded.wayfix.fabric;

import net.fabricmc.api.ClientModInitializer;
import net.notcoded.wayfix.common.WayFix;

public class WayFixFabric implements ClientModInitializer {
@Override
public void onInitializeClient() {
WayFix.init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.notcoded.wayfix.fabric.config;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.notcoded.wayfix.common.config.ModConfig;
import me.shedaniel.autoconfig.AutoConfig;

public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfig.getConfigScreen(ModConfig.class, parent).get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
"environment": "client",
"entrypoints": {
"client": [
"net.notcoded.wayfix.WayFix"
"net.notcoded.wayfix.fabric.WayFixFabric"
],
"modmenu": [
"net.notcoded.wayfix.config.ModMenuIntegration"
"net.notcoded.wayfix.fabric.config.ModMenuIntegration"
]
},
"mixins": [
"wayfix.mixins.json"
"wayfix-common.mixins.json"
],

"depends": {
Expand Down
Loading

0 comments on commit b07f1e4

Please sign in to comment.