Build every version with Mojang mappings instead of Yarn
Minecraft ships unobfuscated from 26.1, and 1.21.11 has the last Yarn release, so the shared src/ has to use Mojang's names before newer versions can be added (#39). Each version's sources were migrated with Loom's migrateMappings and merged back into src/, so code that is only active on other versions is migrated too. Where Mojang's names differ between 1.21.x versions, src/ uses the newest ones: Stonecutter replacements swap in the older Identifier/ResourceLocation and Avatar/Player renderer names, and version comments cover the few package moves and renamed methods. The fog mixin now targets setupFog on every version. Yarn's applyFog named two methods from 1.21.6 on, so it also applied to updateBuffer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+13
-7
@@ -8,29 +8,35 @@ Every supported Minecraft version (1.21.4 to 1.21.11) builds from one copy of th
|
||||
|
||||
- `common/`: all version-independent code (mods, UI, cosmetics, the server client). It has no Minecraft dependency and reaches the game only through the interfaces in `org.saturnclient.common`.
|
||||
- `src/`: the version-specific code (providers, refs, mixins and the three mixin configs), one copy for every version. Where Minecraft's API differs between versions, the code goes behind version comments (see below).
|
||||
- `versions/<mc>/`: each version's `gradle.properties` (Minecraft, Yarn, Fabric Loader and Fabric API versions), plus its `build/` and `run/` folders. Each version is the Gradle project `:<mc>`.
|
||||
- `versions/<mc>/`: each version's `gradle.properties` (Minecraft, Fabric Loader and Fabric API versions), plus its `build/` and `run/` folders. Each version is the Gradle project `:<mc>`.
|
||||
|
||||
`settings.gradle.kts` lists the versions in `stonecutterVersions`. The root `build.gradle.kts` builds each version, and `stonecutter.gradle.kts` configures the root project (shared repositories, the `common` wiring and `buildAll`). Loom's version is `loom_version` in the root `gradle.properties`.
|
||||
|
||||
## Mappings
|
||||
|
||||
Every version is built with Mojang's official names (`loom.officialMojangMappings()`), the names Minecraft itself ships from 26.1 on. Yarn isn't used any more: 1.21.11 has the last Yarn release.
|
||||
|
||||
Mojang renamed a few classes within 1.21.x. `src/` uses the newest names, and `stonecutter.gradle.kts` lists replacements that swap in the older name when Stonecutter processes an older version (for example `Identifier`, which was `ResourceLocation` before 1.21.11, and `AvatarRenderState`, which was `PlayerRenderState` before 1.21.9). Add a replacement there when a rename touches many lines. A class that only moved package needs just a version comment on its import, and a renamed method a version comment where it's called.
|
||||
|
||||
## Version-specific code with Stonecutter
|
||||
|
||||
The code in `src/` is always plain Java for the **active** version (1.21.11, set in `stonecutter.gradle.kts`). Code for other versions sits in comments that Stonecutter swaps before building each version:
|
||||
|
||||
```java
|
||||
//? if >=1.21.9 {
|
||||
public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {
|
||||
public void submit(PoseStack matrices, SubmitNodeCollector output, int light, AvatarRenderState state, float limbAngle, float limbDistance) {
|
||||
//?} else
|
||||
//public void render(MatrixStack matrices, VertexConsumerProvider consumers, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {
|
||||
//public void render(PoseStack matrices, MultiBufferSource output, int light, AvatarRenderState state, float limbAngle, float limbDistance) {
|
||||
```
|
||||
|
||||
A condition without braces covers the next line only. For several lines, use braces and wrap the inactive block in `/* … */`:
|
||||
|
||||
```java
|
||||
//? if >=1.21.11 {
|
||||
import net.minecraft.client.render.RenderLayers;
|
||||
import net.minecraft.client.render.RenderSetup;
|
||||
import net.minecraft.client.renderer.rendertype.RenderTypes;
|
||||
import net.minecraft.client.renderer.rendertype.RenderSetup;
|
||||
//?} else {
|
||||
/*import net.minecraft.client.render.RenderPhase.Textures;
|
||||
/*import net.minecraft.client.renderer.RenderStateShard.MultiTextureStateShard;
|
||||
*///?}
|
||||
```
|
||||
|
||||
@@ -62,7 +68,7 @@ For bigger changes, `./gradlew buildAll` builds every version's jar into `build/
|
||||
|
||||
## Adding a Minecraft version
|
||||
|
||||
1. Create `versions/<new>/gradle.properties` with `minecraft_version`, `yarn_mappings`, `loader_version` and `fabric_api_version` (copy 1.21.11's and change the values; they're listed at <https://fabricmc.net/develop>). Loom's version is shared, in the root `gradle.properties`.
|
||||
1. Create `versions/<new>/gradle.properties` with `minecraft_version`, `loader_version` and `fabric_api_version` (copy 1.21.11's and change the values; they're listed at <https://fabricmc.net/develop>). Loom's version is shared, in the root `gradle.properties`.
|
||||
2. Add `<new>` to `stonecutterVersions` in `settings.gradle.kts`.
|
||||
3. Build it with `./gradlew :<new>:compileJava` and put what Minecraft changed behind version comments. Check the mixin configs in `src/main/resources/*.mixins.json` as well: a mixin whose target changed fails at startup, not at compile time, so launch it with `./gradlew :<new>:runClient`.
|
||||
4. The release workflow builds everything through `buildAll`, and "Publish to Modrinth" takes the game version from each jar's name, so neither needs changing.
|
||||
|
||||
Reference in New Issue
Block a user