Compare commits
5 Commits
cf1af0993b
...
e831f8fe01
Author | SHA1 | Date | |
---|---|---|---|
e831f8fe01 | |||
6b1c0517cd | |||
2458975070 | |||
f9a9915ec6 | |||
b0defcde42 |
@ -1,2 +0,0 @@
|
||||
include:
|
||||
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'
|
1
.woodpecker.yml
Normal file
1
.woodpecker.yml
Normal file
@ -0,0 +1 @@
|
||||
#link https://pages.frohnmeyer-wds.de/scripts/jfmod.yml
|
14
build.gradle
14
build.gradle
@ -1,14 +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}")
|
||||
|
||||
include modRuntimeOnly('io.gitlab.jfronny:gson:2.9.0.2022.4.2.19.45.43') // Dependency of LibJF 2.7.0
|
||||
|
||||
modImplementation "com.terraformersmc:modmenu:3.1.0"
|
||||
}
|
15
build.gradle.kts
Normal file
15
build.gradle.kts
Normal file
@ -0,0 +1,15 @@
|
||||
import io.gitlab.jfronny.scripts.*
|
||||
|
||||
plugins {
|
||||
id("jfmod") version "1.2-SNAPSHOT"
|
||||
id("io.gitlab.jfronny.libjf.libjf-config-compiler-plugin")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-web-v0:${prop("libjf_version")}")
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${prop("libjf_version")}")
|
||||
|
||||
// Dev env
|
||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-reflect-v1:${prop("libjf_version")}")
|
||||
modLocalRuntime("com.terraformersmc:modmenu:4.0.6")
|
||||
}
|
@ -1,14 +1,17 @@
|
||||
# check these on https://fabricmc.net/develop/
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=build.2
|
||||
loader_version=0.13.3
|
||||
minecraft_version=1.19.2
|
||||
yarn_mappings=build.24
|
||||
loader_version=0.14.11
|
||||
|
||||
maven_group=io.gitlab.jfronny
|
||||
archives_base_name=dynres
|
||||
|
||||
fabric_version=0.48.0+1.18.2
|
||||
jfapi_version=2.7.0
|
||||
|
||||
modrinth_id=v3lfX2LD
|
||||
modrinth_optional_dependencies=mOgUt4GM
|
||||
modrinth_id=dynres
|
||||
modrinth_required_dependencies=libjf
|
||||
modrinth_optional_dependencies=modmenu
|
||||
curseforge_id=407012
|
||||
curseforge_required_dependencies=libjf
|
||||
curseforge_optional_dependencies=modmenu
|
||||
|
||||
fabric_version=0.68.0+1.19.2
|
||||
libjf_version=3.2.1
|
||||
|
13
settings.gradle.kts
Normal file
13
settings.gradle.kts
Normal file
@ -0,0 +1,13 @@
|
||||
pluginManagement {
|
||||
val libjf_version: String by settings
|
||||
repositories {
|
||||
maven("https://maven.fabricmc.net/") // FabricMC
|
||||
maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
|
||||
gradlePluginPortal()
|
||||
}
|
||||
plugins {
|
||||
id("io.gitlab.jfronny.libjf.libjf-config-compiler-plugin") version libjf_version
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "dynres"
|
@ -0,0 +1,38 @@
|
||||
package io.gitlab.jfronny.dynres.mixin;
|
||||
|
||||
import io.gitlab.jfronny.dynres.*;
|
||||
import net.minecraft.client.network.*;
|
||||
import net.minecraft.network.packet.c2s.play.*;
|
||||
import net.minecraft.network.packet.s2c.play.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.*;
|
||||
|
||||
import java.net.*;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public abstract class ClientPlayNetworkHandlerMixin {
|
||||
@Shadow @Nullable
|
||||
private static URL resolveUrl(String url) {
|
||||
throw new RuntimeException("Mixin not applied");
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@Redirect(method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/play/ResourcePackSendS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;resolveUrl(Ljava/lang/String;)Ljava/net/URL;"))
|
||||
public URL logResourcePackStatus(String url) {
|
||||
URL res = resolveUrl(url);
|
||||
DynRes.LOGGER.info("[CHECK] ResourcePackUrlValid=" + (res != null));
|
||||
return res;
|
||||
}
|
||||
}
|
15
src/client/resources/dynres.client.mixins.json
Normal file
15
src/client/resources/dynres.client.mixins.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "io.gitlab.jfronny.dynres.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"ServerInfoMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"mixins": [
|
||||
]
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
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.v1.Entry;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.JfConfig;
|
||||
|
||||
public class Cfg implements JfConfig {
|
||||
@Entry
|
||||
public static String resourcesFile = "resources.zip";
|
||||
@Entry
|
||||
public static boolean hashResources = false;
|
||||
@JfConfig
|
||||
public class Cfg {
|
||||
@Entry public static String resourcesFile = "resources.zip";
|
||||
@Entry public static boolean hashResources = false;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -1,48 +1,50 @@
|
||||
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.impl.util.WebPaths;
|
||||
import net.minecraft.server.dedicated.ServerPropertiesHandler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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 io.gitlab.jfronny.dynres.*;
|
||||
import io.gitlab.jfronny.libjf.web.api.*;
|
||||
import io.gitlab.jfronny.libjf.web.impl.util.*;
|
||||
import net.minecraft.server.*;
|
||||
import net.minecraft.server.dedicated.*;
|
||||
import net.minecraft.text.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
|
||||
@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;ZLjava/lang/String;)Ljava/util/Optional;", at = @At("HEAD"), cancellable = true)
|
||||
private static void getServerResourcePackProperties(String url, String sha1, @Nullable 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 " + sha1);
|
||||
} catch (IOException | NoSuchAlgorithmException e) {
|
||||
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
|
||||
}
|
||||
}
|
||||
resourcePackHash = resourcePackSha1;
|
||||
cir.setReturnValue(Optional.of(new MinecraftServer.ServerResourcePackProperties(
|
||||
WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip"),
|
||||
sha1,
|
||||
required,
|
||||
parseResourcePackPrompt(prompt)
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
src/main/resources/assets/dynres/icon.png
Normal file
BIN
src/main/resources/assets/dynres/icon.png
Normal file
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",
|
||||
@ -20,12 +20,17 @@
|
||||
"libjf:config": ["io.gitlab.jfronny.dynres.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.7.0"
|
||||
"fabric-api": "*",
|
||||
"libjf-config-core-v1": ">=2.7.0"
|
||||
},
|
||||
"custom": {
|
||||
"libjf": {
|
||||
|
Loading…
Reference in New Issue
Block a user