Update for 1.19
This commit is contained in:
parent
cf1af0993b
commit
b0defcde42
10
build.gradle
10
build.gradle
|
@ -3,12 +3,8 @@ 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("io.gitlab.jfronny.libjf:libjf-web-v0:${project.jfapi_version}")
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-config-v0:${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"
|
||||
modImplementation "com.terraformersmc:modmenu:4.0.0-beta.4"
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
# 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
|
||||
yarn_mappings=build.1
|
||||
loader_version=0.14.6
|
||||
maven_group=io.gitlab.jfronny
|
||||
archives_base_name=dynres
|
||||
|
||||
fabric_version=0.48.0+1.18.2
|
||||
jfapi_version=2.7.0
|
||||
fabric_version=0.55.1+1.19
|
||||
jfapi_version=2.9.1
|
||||
|
||||
modrinth_id=v3lfX2LD
|
||||
modrinth_required_dependencies=WKwQAwke
|
||||
modrinth_optional_dependencies=mOgUt4GM
|
||||
curseforge_id=407012
|
||||
curseforge_required_dependencies=libjf
|
||||
curseforge_optional_dependencies=modmenu
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
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;
|
||||
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 class ClientPlayNetworkHandlerMixin {
|
||||
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);
|
||||
|
@ -23,8 +29,10 @@ public class ClientPlayNetworkHandlerMixin {
|
|||
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());
|
||||
@Redirect(method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/play/ResourcePackSendS2CPacket;)V", at = @At(value = "HEAD", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;resolveUrl(Ljava/lang/String;)Ljava/net/URL;"))
|
||||
public URL logResourcePackStatus(String url, CallbackInfo info) {
|
||||
URL res = resolveUrl(url);
|
||||
DynRes.LOGGER.info("[CHECK] ResourcePackUrlValid=" + (res != null));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
"ServerInfoMixin"
|
||||
],
|
||||
"server": [
|
||||
"ServerPropertiesHandlerMixin",
|
||||
"MinecraftServerMixin"
|
||||
"ServerPropertiesHandlerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in New Issue