Skip to content

Commit 95690c7

Browse files
committed
Version Fixes + QOL
1 parent 4ebbf2f commit 95690c7

19 files changed

+1658
-185
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release -> Discord
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-post:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Java
16+
uses: actions/setup-java@v4
17+
with:
18+
distribution: temurin
19+
java-version: "21"
20+
21+
- name: Grant execute permission for Gradle
22+
run: chmod +x ./gradlew
23+
24+
- name: Build
25+
run: ./gradlew build
26+
27+
- name: Find built jar
28+
id: jar
29+
shell: bash
30+
run: |
31+
# pick the main jar from build/libs; ignore extra jars
32+
JAR="$(ls -1 build/libs/*.jar \
33+
| grep -Ev '(-sources|-javadoc|-dev|-shadow|-all)\.jar$' \
34+
| head -n 1)"
35+
36+
if [ -z "$JAR" ]; then
37+
echo "No suitable jar found in build/libs/"
38+
ls -la build/libs || true
39+
exit 1
40+
fi
41+
42+
echo "Found jar: $JAR"
43+
echo "jar_path=$JAR" >> "$GITHUB_OUTPUT"
44+
45+
- name: Post to Discord (message + jar attachment)
46+
shell: bash
47+
run: |
48+
TAG="${{ github.event.release.tag_name }}"
49+
URL="${{ github.event.release.html_url }}"
50+
NAME="${{ github.event.repository.name }}"
51+
JAR="${{ steps.jar.outputs.jar_path }}"
52+
53+
curl \
54+
-F "payload_json={\"content\":\"**${NAME} ${TAG}**\\nGitHub Release: ${URL}\\n\\n📦 **Download:** (file attached)\"}" \
55+
-F "file=@\"${JAR}\"" \
56+
"${{ secrets.DISCORD_WEBHOOK_URL }}"

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Pathmind
22

3-
[![Minecraft](https://img.shields.io/badge/Minecraft-1.21.x-00AA00?style=for-the-badge&logo=minecraft)](https://minecraft.net)
3+
[![Minecraft](https://img.shields.io/badge/Minecraft-Multi--Version-00AA00?style=for-the-badge&logo=minecraft)](https://minecraft.net)
44
[![Fabric](https://img.shields.io/badge/Fabric-0.17.2-CC6E3E?style=for-the-badge&logo=modrinth)](https://fabricmc.net)
55
[![Java](https://img.shields.io/badge/Java-21+-FF6B6B?style=for-the-badge&logo=openjdk)](https://openjdk.java.net)
66
[![License](https://img.shields.io/badge/License-All%20Rights%20Reserved-lightgrey?style=for-the-badge)](LICENSE)
@@ -11,20 +11,20 @@ A Minecraft Fabric mod that introduces a visual node editor system for creating
1111
## Quick Start
1212

1313
### Prerequisites
14-
- **Minecraft**: any 1.21.x release
14+
- **Minecraft**: Any supported version (match the `+mc<version>` suffix on the jar you download)
1515
- **Fabric Loader**: 0.17.2 or higher
16-
- **Fabric API**: latest release for your 1.21.x version
17-
- **Baritone API**: 1.21.x release (download separately)
16+
- **Fabric API**: release that matches your chosen Minecraft version
17+
- **Baritone API**: version that matches your Minecraft/Fabric combo (download separately)
1818
- **Java**: 21 or higher
1919

2020
### Installation
2121

2222
1. **Install Fabric Loader**
23-
- Download and install Fabric Loader for Minecraft 1.21.x
23+
- Download and install Fabric Loader for your chosen Minecraft version
2424
- [Download from FabricMC](https://fabricmc.net/use/installer/)
2525

2626
2. **Install Fabric API**
27-
- Download the latest Fabric API for your 1.21.x version
27+
- Download the Fabric API build that matches your chosen Minecraft version
2828
- [Download from Modrinth](https://modrinth.com/mod/fabric-api)
2929

3030
3. **Install Baritone API**
@@ -33,13 +33,19 @@ A Minecraft Fabric mod that introduces a visual node editor system for creating
3333
- [Download from GitHub](https://github.com/cabaletta/baritone/releases/latest)
3434

3535
4. **Install Pathmind**
36-
- Download the latest Pathmind mod jar
36+
- Download the Pathmind jar whose filename ends with your Minecraft version (every release ships with `+mc<version>` in the filename)
3737
- Place it in your `mods` folder
3838

3939
5. **Launch and Enjoy!**
4040
- Start Minecraft with Fabric Loader
4141
- Use your configured keybind to open the visual editor
4242

43+
## Compatibility
44+
45+
- Release jars are suffixed with `+mc<version>` so you can keep multiple Minecraft targets side-by-side (e.g., `pathmind-1.0.1+mc1.21.4.jar`).
46+
- The default Gradle build targets the version listed in `gradle.properties`, but passing `-Pmc_version=<version>` (or using the auto-generated `buildMc<version>` tasks) compiles the identical codebase against any entry in `supportedMinecraftVersions`.
47+
- Use the `buildAllTargets` task to batch-build jars for every configured version.
48+
4349
## Development
4450

4551
### Building from Source
@@ -70,15 +76,25 @@ A Minecraft Fabric mod that introduces a visual node editor system for creating
7076
./gradlew runClient
7177
```
7278

79+
### Building for Specific Minecraft Versions
80+
81+
- `./gradlew build` creates a jar for the default target (set in `gradle.properties`), but the source code is the same across all supported versions.
82+
- To build for another version, override the property:
83+
`./gradlew build -Pmc_version=<minecraftVersion>`
84+
- Convenience tasks are available:
85+
- `./gradlew buildMc1_21_4` (build only for `1.21.4`, as an example)
86+
- `./gradlew buildAllTargets` (build every configured version sequentially)
87+
- Each jar is versioned as `pathmind-<modVersion>+mc<gameVersion>.jar` so you can publish multiple targets side by side.
88+
7389
## Version Information
7490

7591
| Component | Version |
7692
|-----------|---------|
7793
| **Mod Version** | 1.0.1 |
78-
| **Minecraft Version** | 1.21.x |
79-
| **Yarn Mappings** | 1.21.8+build.1 (with :v2 for compilation) |
94+
| **Minecraft Version** | Matches the `+mc<version>` suffix on each jar |
95+
| **Yarn Mappings** | Automatically selected per target version |
8096
| **Fabric Loader** | 0.17.2 |
81-
| **Fabric API** | Latest 1.21.x-compatible release |
97+
| **Fabric API** | Automatically selected per target version |
8298
| **Baritone API** | 1.15.0 (external dependency) |
8399

84100
### Development Guidelines

build.gradle.kts

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
1+
import org.gradle.api.GradleException
2+
import org.gradle.api.tasks.GradleBuild
3+
import org.gradle.api.tasks.TaskProvider
4+
15
plugins {
26
id("fabric-loom") version "1.10.3"
37
id("maven-publish")
48
}
59

6-
version = project.property("mod_version") as String
10+
data class MinecraftVersionSpec(
11+
val yarnMappings: String,
12+
val fabricApiVersion: String
13+
)
14+
15+
val supportedMinecraftVersions = linkedMapOf(
16+
"1.21" to MinecraftVersionSpec("1.21+build.9", "0.102.0+1.21"),
17+
"1.21.1" to MinecraftVersionSpec("1.21.1+build.3", "0.116.7+1.21.1"),
18+
"1.21.2" to MinecraftVersionSpec("1.21.2+build.1", "0.106.1+1.21.2"),
19+
"1.21.3" to MinecraftVersionSpec("1.21.3+build.2", "0.114.1+1.21.3"),
20+
"1.21.4" to MinecraftVersionSpec("1.21.4+build.8", "0.119.4+1.21.4"),
21+
"1.21.5" to MinecraftVersionSpec("1.21.5+build.1", "0.128.2+1.21.5"),
22+
"1.21.6" to MinecraftVersionSpec("1.21.6+build.1", "0.128.2+1.21.6"),
23+
"1.21.7" to MinecraftVersionSpec("1.21.7+build.8", "0.129.0+1.21.7"),
24+
"1.21.8" to MinecraftVersionSpec("1.21.8+build.1", "0.133.4+1.21.8")
25+
)
26+
27+
fun String.toTaskSuffix(): String = replace(".", "_")
28+
29+
val requestedMinecraftVersion = providers.gradleProperty("mc_version")
30+
.orElse(providers.gradleProperty("minecraft_version"))
31+
.get()
32+
33+
val requestedSpec = supportedMinecraftVersions[requestedMinecraftVersion]
34+
35+
val yarnMappings = providers.gradleProperty("yarn_mappings").orElse(
36+
requestedSpec?.let { provider { it.yarnMappings } }
37+
?: throw GradleException(
38+
"No Yarn mappings configured for Minecraft $requestedMinecraftVersion. " +
39+
"Either add it to supportedMinecraftVersions or pass -Pyarn_mappings=<mapping>"
40+
)
41+
).get()
42+
43+
val fabricApiVersion = providers.gradleProperty("fabric_api_version").orElse(
44+
requestedSpec?.let { provider { it.fabricApiVersion } }
45+
?: throw GradleException(
46+
"No Fabric API version configured for Minecraft $requestedMinecraftVersion. " +
47+
"Either add it to supportedMinecraftVersions or pass -Pfabric_api_version=<version>"
48+
)
49+
).get()
50+
51+
version = "${project.property("mod_version") as String}+mc$requestedMinecraftVersion"
752
group = project.property("maven_group") as String
853

954
base {
@@ -40,12 +85,12 @@ val baritoneApiJar: File by extra {
4085

4186
dependencies {
4287
// To change the versions see the gradle.properties file
43-
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
44-
mappings("net.fabricmc:yarn:${project.property("yarn_mappings")}:v2")
88+
minecraft("com.mojang:minecraft:$requestedMinecraftVersion")
89+
mappings("net.fabricmc:yarn:$yarnMappings:v2")
4590
modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")
4691

4792
// Fabric API. This is technically optional, but you probably want it anyway.
48-
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_api_version")}")
93+
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion")
4994

5095
// Baritone API dependency (compile-time only, users must provide the mod at runtime)
5196
val baritoneApi = files(baritoneApiJar)
@@ -59,9 +104,9 @@ dependencies {
59104
tasks.processResources {
60105
val properties = mapOf(
61106
"version" to version,
62-
"minecraft_version" to project.property("minecraft_version"),
107+
"minecraft_version" to requestedMinecraftVersion,
63108
"loader_version" to project.property("loader_version"),
64-
"fabric_api_version" to project.property("fabric_api_version")
109+
"fabric_api_version" to fabricApiVersion
65110
)
66111
inputs.properties(properties)
67112

@@ -96,6 +141,33 @@ tasks.jar {
96141
}
97142
}
98143

144+
val cleanTask = tasks.named("clean")
145+
val multiVersionBuildTasks = mutableListOf<TaskProvider<GradleBuild>>()
146+
var previousVersionTask: TaskProvider<GradleBuild>? = null
147+
supportedMinecraftVersions.keys.forEach { version ->
148+
val taskName = "buildMc${version.toTaskSuffix()}"
149+
val provider = tasks.register<GradleBuild>(taskName) {
150+
group = "build"
151+
description = "Build Pathmind for Minecraft $version"
152+
dir = projectDir
153+
tasks = listOf("build")
154+
startParameter.projectProperties = mapOf("mc_version" to version)
155+
}
156+
provider.configure {
157+
mustRunAfter(cleanTask)
158+
previousVersionTask?.let { mustRunAfter(it) }
159+
}
160+
multiVersionBuildTasks += provider
161+
previousVersionTask = provider
162+
}
163+
164+
tasks.register("buildAllTargets") {
165+
group = "build"
166+
description = "Build Pathmind for every configured Minecraft target"
167+
dependsOn(cleanTask)
168+
multiVersionBuildTasks.forEach { dependsOn(it) }
169+
}
170+
99171
// configure the maven publication
100172
publishing {
101173
publications {

gradle.properties

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ org.gradle.parallel=true
55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
77
minecraft_version=1.21.8
8-
yarn_mappings=1.21.8+build.1
98
loader_version=0.17.2
109

1110
# Mod Properties
1211
mod_version=1.0.1
1312
maven_group=com.pathmind
1413
archives_base_name=pathmind
15-
16-
# Dependencies
17-
fabric_api_version=0.133.4+1.21.8

src/main/java/com/pathmind/PathmindClientMod.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import net.fabricmc.api.ClientModInitializer;
1111
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
1212
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
13-
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientWorldEvents;
1413
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
1514
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
1615
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
@@ -58,14 +57,6 @@ public void onInitializeClient() {
5857
handleKeybinds(client);
5958
});
6059

61-
ClientWorldEvents.AFTER_CLIENT_WORLD_CHANGE.register((client, world) -> {
62-
if (world != null) {
63-
worldShutdownHandled = false;
64-
} else {
65-
handleClientShutdown("world change (null)", false);
66-
}
67-
});
68-
6960
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
7061
worldShutdownHandled = false;
7162
});

src/main/java/com/pathmind/PathmindMod.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.pathmind;
22

3+
import com.pathmind.util.VersionSupport;
34
import net.fabricmc.api.ModInitializer;
45
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
6+
import net.fabricmc.loader.api.FabricLoader;
57
import net.minecraft.util.Identifier;
68
import org.slf4j.Logger;
79
import org.slf4j.LoggerFactory;
@@ -21,6 +23,14 @@ public static Identifier id(String path) {
2123
@Override
2224
public void onInitialize() {
2325
LOGGER.info("Initializing Pathmind mod");
26+
27+
String minecraftVersion = FabricLoader.getInstance()
28+
.getModContainer("minecraft")
29+
.map(container -> container.getMetadata().getVersion().getFriendlyString())
30+
.orElse("unknown");
31+
if (!VersionSupport.isSupported(minecraftVersion)) {
32+
LOGGER.warn("Pathmind targets Minecraft {} but detected {}", VersionSupport.SUPPORTED_RANGE, minecraftVersion);
33+
}
2434

2535
// Register server tick events
2636
ServerTickEvents.END_SERVER_TICK.register(server -> {

0 commit comments

Comments
 (0)