Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
More mappings stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
melontini committed Apr 19, 2024
1 parent 9909f3a commit 1ebc8ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ jobs:
- name: capture build artifacts
uses: actions/[email protected]
with:
name: Artifacts #https://stackoverflow.com/questions/58886293/getting-current-branch-and-commit-hash-in-github-action
name: Artifacts
path: build/libs/
- name: capture processed mappings
uses: actions/[email protected]
with:
name: Mappings
path: .gradle/commander/mappings/

packages:
needs: build
Expand All @@ -60,6 +65,13 @@ jobs:
distribution: 'temurin'
java-version: 17
cache: gradle
- uses: actions/[email protected]
with:
name: Mappings
path: .gradle/commander/mappings/
- uses: geekyeggo/delete-artifact@v5
with:
name: Mappings
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: publish
Expand Down
7 changes: 4 additions & 3 deletions gradle/mappings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import java.util.zip.DeflaterOutputStream
ext.MANIFEST_URL = new URL("https://launchermeta.mojang.com/mc/game/version_manifest_v2.json")

tasks.register("downloadCommanderMappings") {
File processed = new File("${project.layout.projectDirectory.getAsFile()}/.gradle/downloadCommanderMappings/${project.minecraft_version}/processed.bin")
File processed = new File("${project.layout.projectDirectory.getAsFile()}/.gradle/commander/mappings/${project.minecraft_version}.bin")
if (!processed.exists()) {
project.logger.lifecycle("Downloading and Processing Mappings...")
Files.createDirectories(processed.toPath().getParent())

MemoryMappingTree tree = new MemoryMappingTree()
Expand All @@ -45,8 +46,8 @@ tasks.register("downloadCommanderMappings") {

processResources {
mustRunAfter(tasks.downloadCommanderMappings)
from(new File("${project.layout.projectDirectory.getAsFile()}/.gradle/downloadCommanderMappings/${project.minecraft_version}/processed.bin")) {
rename { "commander/mappings/processed.bin" }
from(new File("${project.layout.projectDirectory.getAsFile()}/.gradle/commander/mappings/${project.minecraft_version}.bin")) {
rename { "commander/mappings/${project.minecraft_version}.bin" }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.melontini.commander.impl.util.mappings;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import net.fabricmc.loader.api.FabricLoader;
Expand Down Expand Up @@ -37,7 +39,7 @@ public static MemoryMappingTree loadMojmapTarget(MemoryMappingTree offMojmap, Me
public static MemoryMappingTree loadOffMojmap() {
if (NAMESPACE.equals("mojang")) return null;
log.info("Loading official->mojmap mappings...");
Path path = FabricLoader.getInstance().getModContainer("commander").orElseThrow().findPath("commander/mappings/processed.bin").orElseThrow();
Path path = FabricLoader.getInstance().getModContainer("commander").orElseThrow().findPath("commander/mappings/%s.bin".formatted(getVersion())).orElseThrow();

var tree = new MemoryMappingTree();
MappingReader.read(new InputStreamReader(new InflaterInputStream(Files.newInputStream(path))), tree);
Expand Down Expand Up @@ -69,4 +71,9 @@ public String getFieldOrMethod(Class<?> cls, String name) {
}
return null;
}

public static String getVersion() {
JsonObject o = JsonParser.parseReader(new InputStreamReader(MappingKeeper.class.getResourceAsStream("/version.json"))).getAsJsonObject();
return o.getAsJsonPrimitive("id").getAsString();
}
}

0 comments on commit 1ebc8ff

Please sign in to comment.