Compare commits
15 Commits
Author | SHA1 | Date |
---|---|---|
Johannes Frohnmeyer | 449a54bc64 | |
Johannes Frohnmeyer | 25e99adc33 | |
Johannes Frohnmeyer | 715504d4d5 | |
Johannes Frohnmeyer | 7af7faa24d | |
Johannes Frohnmeyer | 2fc3da9b78 | |
Johannes Frohnmeyer | 96ce0801ad | |
Johannes Frohnmeyer | b46790d6a3 | |
Johannes Frohnmeyer | ec5d2d4908 | |
Johannes Frohnmeyer | cf3bbdcd1b | |
Johannes Frohnmeyer | e831f8fe01 | |
Johannes Frohnmeyer | 6b1c0517cd | |
Johannes Frohnmeyer | 2458975070 | |
Johannes Frohnmeyer | f9a9915ec6 | |
Johannes Frohnmeyer | b0defcde42 | |
Johannes Frohnmeyer | cf1af0993b |
|
@ -1,2 +0,0 @@
|
|||
include:
|
||||
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'
|
|
@ -0,0 +1 @@
|
|||
#link https://pages.frohnmeyer-wds.de/scripts/jfmod.yml
|
12
build.gradle
12
build.gradle
|
@ -1,12 +0,0 @@
|
|||
apply from: "https://jfmods.gitlab.io/scripts/jfmod.gradle"
|
||||
|
||||
dependencies {
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
include modImplementation("io.gitlab.jfronny.libjf:libjf-web-v0:${project.jfapi_version}")
|
||||
include modImplementation("io.gitlab.jfronny.libjf:libjf-config-v0:${project.jfapi_version}")
|
||||
include("io.gitlab.jfronny.libjf:libjf-unsafe-v0:${project.jfapi_version}")
|
||||
include("io.gitlab.jfronny.libjf:libjf-base:${project.jfapi_version}")
|
||||
|
||||
modImplementation "com.terraformersmc:modmenu:3.1.0"
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
plugins {
|
||||
id("jfmod") version "1.6-SNAPSHOT"
|
||||
}
|
||||
|
||||
allprojects { group = "io.gitlab.jfronny" }
|
||||
base.archivesName = "dynres"
|
||||
|
||||
jfMod {
|
||||
minecraftVersion = "1.20.5"
|
||||
yarn("build.1")
|
||||
loaderVersion = "0.15.10"
|
||||
libJfVersion = "3.15.4"
|
||||
fabricApiVersion = "0.97.6+1.20.5"
|
||||
|
||||
modrinth {
|
||||
projectId = "dynres"
|
||||
requiredDependencies.add("libjf")
|
||||
optionalDependencies.add("modmenu")
|
||||
}
|
||||
|
||||
curseforge {
|
||||
projectId = "407012"
|
||||
requiredDependencies.add("libjf")
|
||||
optionalDependencies.add("modmenu")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-web-v1")
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2")
|
||||
|
||||
// Dev env
|
||||
modLocalRuntime("com.terraformersmc:modmenu:10.0.0-beta.1")
|
||||
// for modmenu
|
||||
modLocalRuntime("net.fabricmc.fabric-api:fabric-resource-loader-v0")
|
||||
modLocalRuntime("net.fabricmc.fabric-api:fabric-screen-api-v1")
|
||||
modLocalRuntime("net.fabricmc.fabric-api:fabric-key-binding-api-v1")
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
# check these on https://fabricmc.net/develop/
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=build.2
|
||||
loader_version=0.13.3
|
||||
maven_group=io.gitlab.jfronny
|
||||
archives_base_name=dynres
|
||||
|
||||
fabric_version=0.48.0+1.18.2
|
||||
jfapi_version=2.6.0
|
||||
|
||||
modrinth_id=v3lfX2LD
|
||||
modrinth_optional_dependencies=mOgUt4GM
|
||||
curseforge_id=407012
|
||||
curseforge_optional_dependencies=modmenu
|
|
@ -0,0 +1,9 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
maven("https://maven.fabricmc.net/") // FabricMC
|
||||
maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "dynres"
|
|
@ -0,0 +1,33 @@
|
|||
package io.gitlab.jfronny.dynres.mixin;
|
||||
|
||||
import io.gitlab.jfronny.dynres.DynRes;
|
||||
import net.minecraft.client.network.ClientCommonNetworkHandler;
|
||||
import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket;
|
||||
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@Mixin(ClientCommonNetworkHandler.class)
|
||||
public abstract class ClientCommonNetworkHandlerMixin {
|
||||
@Shadow @Nullable protected static URL getParsedResourcePackUrl(String url) {
|
||||
throw new RuntimeException("Mixin not applied");
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/common/ResourcePackSendS2CPacket;)V")
|
||||
public void logResourcePackStatus(ResourcePackSendS2CPacket status, CallbackInfo info) {
|
||||
DynRes.LOGGER.info("[RECEIVE] ResourcePackUrl={0}", status.url());
|
||||
DynRes.LOGGER.info("[RECEIVE] ResourcePackHash={0}", status.hash());
|
||||
}
|
||||
|
||||
@Redirect(method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/common/ResourcePackSendS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;getParsedResourcePackUrl(Ljava/lang/String;)Ljava/net/URL;"))
|
||||
public URL logResourcePackStatus(String url) {
|
||||
URL res = getParsedResourcePackUrl(url);
|
||||
DynRes.LOGGER.info("[CHECK] ResourcePackUrlValid={0}", res != null);
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
public class ServerInfoMixin {
|
||||
@Inject(at = @At("RETURN"), method = "getResourcePackPolicy()Lnet/minecraft/client/network/ServerInfo$ResourcePackPolicy;")
|
||||
public void getResPackState(CallbackInfoReturnable<ServerInfo.ResourcePackPolicy> info) {
|
||||
DynRes.LOGGER.info("[RECEIVE] ResourcePackStatus=" + info.getReturnValue());
|
||||
DynRes.LOGGER.info("[RECEIVE] ResourcePackStatus={0}", info.getReturnValue());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "io.gitlab.jfronny.dynres.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"ClientCommonNetworkHandlerMixin",
|
||||
"ServerInfoMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"mixins": [
|
||||
]
|
||||
}
|
|
@ -1,11 +1,14 @@
|
|||
package io.gitlab.jfronny.dynres;
|
||||
|
||||
import io.gitlab.jfronny.libjf.config.api.Entry;
|
||||
import io.gitlab.jfronny.libjf.config.api.JfConfig;
|
||||
import io.gitlab.jfronny.libjf.config.api.v2.Entry;
|
||||
import io.gitlab.jfronny.libjf.config.api.v2.JfConfig;
|
||||
|
||||
public class Cfg implements JfConfig {
|
||||
@Entry
|
||||
public static String resourcesFile = "resources.zip";
|
||||
@Entry
|
||||
public static boolean hashResources = false;
|
||||
@JfConfig(referencedConfigs = "libjf-web-v0")
|
||||
public class Cfg {
|
||||
@Entry public static String resourcesFile = "resources.zip";
|
||||
@Entry public static boolean hashResources = false;
|
||||
|
||||
static {
|
||||
JFC_Cfg.ensureInitialized();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package io.gitlab.jfronny.dynres;
|
||||
|
||||
import io.gitlab.jfronny.libjf.web.api.WebInit;
|
||||
import io.gitlab.jfronny.libjf.web.api.WebServer;
|
||||
import io.gitlab.jfronny.commons.logger.SystemLoggerPlus;
|
||||
import io.gitlab.jfronny.libjf.web.api.v1.*;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class DynRes implements WebInit {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("DynRes");
|
||||
public class DynRes implements WebEntrypoint {
|
||||
public static final SystemLoggerPlus LOGGER = SystemLoggerPlus.forName("DynRes");
|
||||
public static Path packFile;
|
||||
public static String packUrl = "";
|
||||
|
||||
|
@ -30,10 +28,10 @@ public class DynRes implements WebInit {
|
|||
public void register(WebServer api) {
|
||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER && packFile != null) {
|
||||
try {
|
||||
packUrl = api.registerFile("/resources.zip", packFile, !Cfg.hashResources);
|
||||
LOGGER.info("Initialized DynRes at " + packUrl);
|
||||
packUrl = api.registerFile(PathSegment.of("resources.zip"), packFile, !Cfg.hashResources);
|
||||
LOGGER.info("Initialized DynRes at {0}", packUrl);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("Could not register DynRes resource pack", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package io.gitlab.jfronny.dynres.mixin;
|
||||
|
||||
import io.gitlab.jfronny.dynres.DynRes;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket;
|
||||
import net.minecraft.network.packet.s2c.play.ResourcePackSendS2CPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public class ClientPlayNetworkHandlerMixin {
|
||||
@Inject(at = @At("HEAD"), method = "sendResourcePackStatus(Lnet/minecraft/network/packet/c2s/play/ResourcePackStatusC2SPacket$Status;)V")
|
||||
public void logSentResourcePackStatus(ResourcePackStatusC2SPacket.Status packStatus, CallbackInfo info) {
|
||||
DynRes.LOGGER.info("[SEND] ResourcePackStatus=" + packStatus);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/play/ResourcePackSendS2CPacket;)V")
|
||||
public void logResourcePackStatus(ResourcePackSendS2CPacket status, CallbackInfo info) {
|
||||
DynRes.LOGGER.info("[RECEIVE] ResourcePackUrl=" + status.getURL());
|
||||
DynRes.LOGGER.info("[RECEIVE] ResourcePackSha1=" + status.getSHA1());
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "validateResourcePackUrl(Ljava/lang/String;)Z")
|
||||
public void logUrlValid(String url, CallbackInfoReturnable<Boolean> info) {
|
||||
DynRes.LOGGER.info("[CHECK] ResourcePackUrlValid=" + info.getReturnValue());
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package io.gitlab.jfronny.dynres.mixin;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
@Redirect(method = "loadWorldResourcePack()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setResourcePack(Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void cancelResourcePackSet(MinecraftServer server, String url, String hash) {
|
||||
// cancel
|
||||
}
|
||||
}
|
|
@ -2,47 +2,57 @@ package io.gitlab.jfronny.dynres.mixin;
|
|||
|
||||
import io.gitlab.jfronny.dynres.Cfg;
|
||||
import io.gitlab.jfronny.dynres.DynRes;
|
||||
import io.gitlab.jfronny.libjf.web.api.WebServer;
|
||||
import io.gitlab.jfronny.libjf.web.api.v1.WebServer;
|
||||
import io.gitlab.jfronny.libjf.web.impl.util.WebPaths;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.dedicated.ServerPropertiesHandler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import net.minecraft.text.Text;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(ServerPropertiesHandler.class)
|
||||
public class ServerPropertiesHandlerMixin {
|
||||
@Mutable @Final @Shadow public String resourcePackHash;
|
||||
@Mutable @Final @Shadow public String resourcePackSha1;
|
||||
@Mutable @Final @Shadow public String resourcePack;
|
||||
public abstract class ServerPropertiesHandlerMixin {
|
||||
@Shadow @Nullable
|
||||
private static Text parseResourcePackPrompt(String prompt) {
|
||||
throw new IllegalStateException("Mixin not applied");
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "<init>(Ljava/util/Properties;)V")
|
||||
public void init(CallbackInfo info) {
|
||||
@Inject(method = "getServerResourcePackProperties(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;)Ljava/util/Optional;", at = @At("HEAD"), cancellable = true)
|
||||
private static void getServerResourcePackProperties(String id, String url, String sha1, String hash, boolean required, String prompt, CallbackInfoReturnable<Optional<MinecraftServer.ServerResourcePackProperties>> cir) {
|
||||
if (DynRes.packFile != null) {
|
||||
resourcePack = WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip");
|
||||
DynRes.LOGGER.info("Pack link: " + resourcePack);
|
||||
resourcePackSha1 = "";
|
||||
sha1 = "";
|
||||
if (Cfg.hashResources) {
|
||||
try {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (byte b : MessageDigest.getInstance("SHA-1").digest(Files.readAllBytes(DynRes.packFile))) {
|
||||
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
resourcePackSha1 = result.toString();
|
||||
DynRes.LOGGER.info("Set hash to " + resourcePackSha1);
|
||||
sha1 = result.toString();
|
||||
DynRes.LOGGER.info("Set hash to {0}", sha1);
|
||||
} catch (IOException | NoSuchAlgorithmException e) {
|
||||
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
|
||||
}
|
||||
}
|
||||
resourcePackHash = resourcePackSha1;
|
||||
url = WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip");
|
||||
cir.setReturnValue(Optional.of(new MinecraftServer.ServerResourcePackProperties(
|
||||
UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8)),
|
||||
url,
|
||||
sha1,
|
||||
required,
|
||||
parseResourcePackPrompt(prompt)
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
|
@ -3,13 +3,8 @@
|
|||
"minVersion": "0.8",
|
||||
"package": "io.gitlab.jfronny.dynres.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"ServerInfoMixin"
|
||||
],
|
||||
"server": [
|
||||
"ServerPropertiesHandlerMixin",
|
||||
"MinecraftServerMixin"
|
||||
"ServerPropertiesHandlerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
"id": "dynres",
|
||||
"version": "${version}",
|
||||
"name": "DynRes",
|
||||
"description": "Host resourcepacks directly in-server",
|
||||
"authors": [
|
||||
"JFronny"
|
||||
],
|
||||
"description": "Host a resource pack directly on your server",
|
||||
"authors": ["JFronny"],
|
||||
"contact": {
|
||||
"website": "https://jfronny.gitlab.io",
|
||||
"repo": "https://www.gitlab.com/jfmods/DynRes"
|
||||
"email": "projects.contact@frohnmeyer-wds.de",
|
||||
"homepage": "https://jfronny.gitlab.io",
|
||||
"issues": "https://git.frohnmeyer-wds.de/JfMods/DynRes/issues",
|
||||
"sources": "https://git.frohnmeyer-wds.de/JfMods/DynRes"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/dynres/icon.png",
|
||||
|
@ -17,15 +17,19 @@
|
|||
"entrypoints": {
|
||||
"libjf:web": ["io.gitlab.jfronny.dynres.DynRes"],
|
||||
"client": ["io.gitlab.jfronny.dynres.DebugClient"],
|
||||
"libjf:config": ["io.gitlab.jfronny.dynres.Cfg"]
|
||||
"libjf:config": ["io.gitlab.jfronny.dynres.JFC_Cfg"]
|
||||
},
|
||||
"mixins": [
|
||||
"dynres.mixins.json"
|
||||
"dynres.mixins.json",
|
||||
{
|
||||
"config": "dynres.client.mixins.json",
|
||||
"environment": "client"
|
||||
}
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.0",
|
||||
"minecraft": "*",
|
||||
"libjf-config-v0": ">=2.1.2"
|
||||
"libjf-config-core-v1": ">=2.7.0"
|
||||
},
|
||||
"custom": {
|
||||
"libjf": {
|
||||
|
|
Loading…
Reference in New Issue