chore: update to 1.20.2
ci/woodpecker/push/jfmod Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2023-09-22 20:34:51 +02:00
parent d828de9464
commit c4d424b792
Signed by: Johannes
GPG Key ID: E76429612C2929F4
12 changed files with 86 additions and 44 deletions

View File

@ -1,16 +1,39 @@
import io.gitlab.jfronny.scripts.*
plugins {
id("jfmod") version "1.3-SNAPSHOT"
id("jfmod") version "1.5-SNAPSHOT"
}
loom {
accessWidenerPath.set(file("src/main/resources/resclone.accesswidener"))
}
allprojects { group = "io.gitlab.jfronny" }
base.archivesName = "resclone"
val fabricVersion = "0.89.1+1.20.2"
val modmenuVersion = "8.0.0-beta.2"
jfMod {
minecraftVersion = "1.20.2"
yarn("build.1")
loaderVersion = "0.14.22"
libJfVersion = "3.13.1"
modrinth {
projectId = "resclone"
optionalDependencies.add("fabric-api")
}
curseforge {
projectId = "839008"
optionalDependencies.add("fabric-api")
}
}
dependencies {
include(modImplementation("io.gitlab.jfronny.libjf:libjf-base:${prop("libjf_version")}")!!) // for JfCommons
include(modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${prop("libjf_version")}")!!) // for JfCommons
include(modImplementation(fabricApi.module("fabric-resource-loader-v0", prop("fabric_version")))!!)
include(modImplementation("io.gitlab.jfronny.libjf:libjf-base:${jfMod.libJfVersion.get()}")!!) // for JfCommons
include(modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2:${jfMod.libJfVersion.get()}")!!) // for JfCommons
include(modImplementation(fabricApi.module("fabric-resource-loader-v0", fabricVersion))!!)
// Dev env
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${prop("libjf_version")}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}")
modLocalRuntime("com.terraformersmc:modmenu:${prop("modmenu_version")}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny:${jfMod.libJfVersion.get()}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${jfMod.libJfVersion.get()}")
modLocalRuntime("com.terraformersmc:modmenu:$modmenuVersion")
}

View File

@ -1,16 +0,0 @@
# https://fabricmc.net/develop
minecraft_version=1.20
yarn_mappings=build.1
loader_version=0.14.21
maven_group=io.gitlab.jfronny
archives_base_name=resclone
modrinth_id=resclone
modrinth_optional_dependencies=fabric-api
curseforge_id=839008
curseforge_optional_dependencies=fabric-api
fabric_version=0.83.0+1.20
libjf_version=3.8.0
modmenu_version=7.0.1

View File

@ -1,7 +1,7 @@
package io.gitlab.jfronny.resclone;
import io.gitlab.jfronny.commons.log.Logger;
import io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolders;
import io.gitlab.jfronny.commons.logging.Logger;
import io.gitlab.jfronny.commons.serialize.gson.api.v2.GsonHolders;
import io.gitlab.jfronny.resclone.data.PackMetaLoaded;
import io.gitlab.jfronny.resclone.data.PackMetaUnloaded;
import io.gitlab.jfronny.resclone.fetchers.*;

View File

@ -1,11 +1,11 @@
package io.gitlab.jfronny.resclone;
import com.google.gson.reflect.TypeToken;
import io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolders;
import io.gitlab.jfronny.commons.serialize.gson.api.v2.GsonHolders;
import io.gitlab.jfronny.gson.JsonParseException;
import io.gitlab.jfronny.gson.stream.*;
import io.gitlab.jfronny.libjf.config.api.v1.JfCustomConfig;
import io.gitlab.jfronny.libjf.config.api.v1.dsl.DSL;
import io.gitlab.jfronny.libjf.config.api.v2.JfCustomConfig;
import io.gitlab.jfronny.libjf.config.api.v2.dsl.DSL;
import io.gitlab.jfronny.resclone.data.PackMetaUnloaded;
import java.io.*;
@ -100,7 +100,7 @@ public class RescloneConfig implements JfCustomConfig {
Resclone.LOGGER.error("Could not write config", e);
}
}).setPath(path)
.<Set<PackMetaUnloaded>>value(PACKS, new HashSet<>(), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, io.gitlab.jfronny.libjf.config.api.v1.type.Type.ofClass(META_SET), 100, () -> packs, p -> packs = p)
.<Set<PackMetaUnloaded>>value(PACKS, new HashSet<>(), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, io.gitlab.jfronny.libjf.config.api.v2.type.Type.ofClass(META_SET), 100, () -> packs, p -> packs = p)
.value(PRUNE_UNUSED, pruneUnused, () -> pruneUnused, p -> pruneUnused = p)
).load();
}

View File

@ -3,16 +3,18 @@ package io.gitlab.jfronny.resclone;
import net.fabricmc.fabric.api.resource.ModResourcePack;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.resource.ZipResourcePack;
import net.minecraft.resource.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class RescloneResourcePack extends ZipResourcePack implements ModResourcePack {
private static final ModMetadata METADATA = FabricLoader.getInstance().getModContainer(Resclone.MOD_ID).orElseThrow().getMetadata();
private final String name;
public RescloneResourcePack(File file, String name) {
super(name, file, true);
RescloneResourcePack(ZipFileWrapper file, String name, String overlay) {
super(name, file, true, overlay);
this.name = name;
}
@ -25,4 +27,31 @@ public class RescloneResourcePack extends ZipResourcePack implements ModResource
public ModMetadata getFabricModMetadata() {
return METADATA;
}
public static class Factory implements ResourcePackProfile.PackFactory {
private final File file;
private final String name;
public Factory(File file, String name) {
this.file = file;
this.name = name;
}
@Override
public ResourcePack open(String name) {
ZipFileWrapper zipFileWrapper = new ZipFileWrapper(this.file);
return new RescloneResourcePack(zipFileWrapper, this.name, "");
}
@Override
public ResourcePack openWithOverlays(String name, ResourcePackProfile.Metadata metadata) {
ZipFileWrapper zipFileWrapper = new ZipFileWrapper(this.file);
ZipResourcePack resourcePack = new RescloneResourcePack(zipFileWrapper, this.name, "");
List<String> overlays = metadata.overlays();
if (overlays.isEmpty()) return resourcePack;
List<ResourcePack> overlayPacks = new ArrayList<>(overlays.size());
for (String string : overlays) overlayPacks.add(new RescloneResourcePack(zipFileWrapper, this.name, string));
return new OverlayResourcePack(resourcePack, overlayPacks);
}
}
}

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.resclone.fetchers;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.resclone.Resclone;
import java.io.*;
@ -32,7 +32,7 @@ public abstract class BasePackFetcher implements PackFetcher {
Resclone.LOGGER.info("Downloading pack: " + url);
try (InputStream is = HttpUtils.get(url).userAgent(Resclone.USER_AGENT).sendInputStream();
try (InputStream is = HttpClient.get(url).userAgent(Resclone.USER_AGENT).sendInputStream();
OutputStream os = Files.newOutputStream(p)) {
byte[] dataBuffer = new byte[1024];
int bytesRead;

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.resclone.fetchers;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.resclone.Resclone;
import io.gitlab.jfronny.resclone.data.curseforge.GetModFilesResponse;
import io.gitlab.jfronny.resclone.data.curseforge.GetModResponse;
@ -64,7 +64,7 @@ public class CurseforgeFetcher extends BasePackFetcher {
}
private static <T> T GET(String suffix, Class<T> klazz) throws URISyntaxException, IOException {
return HttpUtils.get("https://api.curseforge.com/v1/mods/" + suffix).header("x-api-key", API_KEY).sendSerialized(klazz);
return HttpClient.get("https://api.curseforge.com/v1/mods/" + suffix).header("x-api-key", API_KEY).sendSerialized(klazz);
}
private static byte[] unsalt(byte[] data, int salt) {

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.resclone.fetchers;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.resclone.Resclone;
import io.gitlab.jfronny.resclone.data.github.Release;
import io.gitlab.jfronny.resclone.data.github.Repository;
@ -40,7 +40,7 @@ public class GitHubFetcher extends BasePackFetcher {
//"user/repo/release" - Gets from the latest release.
else if (parts[2].equalsIgnoreCase("release")) {
try {
Release latestRelease = HttpUtils.get("https://api.github.com/repos/" + parts[0] + "/" + parts[1] + "/releases/latest").sendSerialized(Release.class);
Release latestRelease = HttpClient.get("https://api.github.com/repos/" + parts[0] + "/" + parts[1] + "/releases/latest").sendSerialized(Release.class);
String res = null;
for (Release.Asset asset : latestRelease.assets) {
@ -74,7 +74,7 @@ public class GitHubFetcher extends BasePackFetcher {
private String getFromBranch(String repo, @Nullable String branch) {
if (branch == null) {
try {
branch = HttpUtils.get("https://api.github.com/repos/" + repo).<Repository>sendSerialized(Repository.class).default_branch;
branch = HttpClient.get("https://api.github.com/repos/" + repo).<Repository>sendSerialized(Repository.class).default_branch;
} catch (IOException | URISyntaxException e) {
Resclone.LOGGER.error("Failed to fetch branch for " + repo + ". Choosing \"main\"", e);
branch = "main";

View File

@ -1,7 +1,7 @@
package io.gitlab.jfronny.resclone.fetchers;
import com.google.common.reflect.TypeToken;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.resclone.Resclone;
import io.gitlab.jfronny.resclone.data.modrinth.Version;
import net.minecraft.MinecraftVersion;
@ -28,7 +28,7 @@ public class ModrinthFetcher extends BasePackFetcher {
Date latestDate = null;
boolean foundMatchingVersion = false;
for (Version ver : HttpUtils.get("https://api.modrinth.com/v2/project/" + baseUrl + "/version")
for (Version ver : HttpClient.get("https://api.modrinth.com/v2/project/" + baseUrl + "/version")
.userAgent(Resclone.USER_AGENT)
.<List<Version>>sendSerialized(versionType)) {
if (foundMatchingVersion && !ver.game_versions.contains(version)) continue;

View File

@ -24,7 +24,7 @@ public class FileResourcePackProviderMixin {
"resclone/" + meta.name(),
Text.literal(meta.name()),
meta.forceEnable(),
name -> new RescloneResourcePack(meta.zipPath().toFile(), meta.name()),
new RescloneResourcePack.Factory(meta.zipPath().toFile(), meta.name()),
type,
ResourcePackProfile.InsertionPosition.TOP,
source

View File

@ -27,6 +27,7 @@
"environment": "client"
}
],
"accessWidener": "resclone.accesswidener",
"depends": {
"fabricloader": ">=0.12.0",
"minecraft": "*",

View File

@ -0,0 +1,5 @@
accessWidener v2 named
accessible class net/minecraft/resource/ZipResourcePack$ZipFileWrapper
extendable method net/minecraft/resource/ZipResourcePack <init> (Ljava/lang/String;Lnet/minecraft/resource/ZipResourcePack$ZipFileWrapper;ZLjava/lang/String;)V
accessible method net/minecraft/resource/ZipResourcePack$ZipFileWrapper <init> (Ljava/io/File;)V