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 {
|
dependencies {
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
include modImplementation("io.gitlab.jfronny.libjf:libjf-web-v0:${project.jfapi_version}")
|
modImplementation("io.gitlab.jfronny.libjf:libjf-web-v0:${project.jfapi_version}")
|
||||||
include modImplementation("io.gitlab.jfronny.libjf:libjf-config-v0:${project.jfapi_version}")
|
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:4.0.0-beta.4"
|
||||||
|
|
||||||
modImplementation "com.terraformersmc:modmenu:3.1.0"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
# check these on https://fabricmc.net/develop/
|
# check these on https://fabricmc.net/develop/
|
||||||
minecraft_version=1.18.2
|
minecraft_version=1.19
|
||||||
yarn_mappings=build.2
|
yarn_mappings=build.1
|
||||||
loader_version=0.13.3
|
loader_version=0.14.6
|
||||||
maven_group=io.gitlab.jfronny
|
maven_group=io.gitlab.jfronny
|
||||||
archives_base_name=dynres
|
archives_base_name=dynres
|
||||||
|
|
||||||
fabric_version=0.48.0+1.18.2
|
fabric_version=0.55.1+1.19
|
||||||
jfapi_version=2.7.0
|
jfapi_version=2.9.1
|
||||||
|
|
||||||
modrinth_id=v3lfX2LD
|
modrinth_id=v3lfX2LD
|
||||||
|
modrinth_required_dependencies=WKwQAwke
|
||||||
modrinth_optional_dependencies=mOgUt4GM
|
modrinth_optional_dependencies=mOgUt4GM
|
||||||
curseforge_id=407012
|
curseforge_id=407012
|
||||||
|
curseforge_required_dependencies=libjf
|
||||||
curseforge_optional_dependencies=modmenu
|
curseforge_optional_dependencies=modmenu
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
package io.gitlab.jfronny.dynres.mixin;
|
package io.gitlab.jfronny.dynres.mixin;
|
||||||
|
|
||||||
import io.gitlab.jfronny.dynres.DynRes;
|
import io.gitlab.jfronny.dynres.*;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.*;
|
||||||
import net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket;
|
import net.minecraft.network.packet.c2s.play.*;
|
||||||
import net.minecraft.network.packet.s2c.play.ResourcePackSendS2CPacket;
|
import net.minecraft.network.packet.s2c.play.*;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.jetbrains.annotations.*;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.*;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.*;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
@Mixin(ClientPlayNetworkHandler.class)
|
@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")
|
@Inject(at = @At("HEAD"), method = "sendResourcePackStatus(Lnet/minecraft/network/packet/c2s/play/ResourcePackStatusC2SPacket$Status;)V")
|
||||||
public void logSentResourcePackStatus(ResourcePackStatusC2SPacket.Status packStatus, CallbackInfo info) {
|
public void logSentResourcePackStatus(ResourcePackStatusC2SPacket.Status packStatus, CallbackInfo info) {
|
||||||
DynRes.LOGGER.info("[SEND] ResourcePackStatus=" + packStatus);
|
DynRes.LOGGER.info("[SEND] ResourcePackStatus=" + packStatus);
|
||||||
|
@ -23,8 +29,10 @@ public class ClientPlayNetworkHandlerMixin {
|
||||||
DynRes.LOGGER.info("[RECEIVE] ResourcePackSha1=" + status.getSHA1());
|
DynRes.LOGGER.info("[RECEIVE] ResourcePackSha1=" + status.getSHA1());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "validateResourcePackUrl(Ljava/lang/String;)Z")
|
@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 void logUrlValid(String url, CallbackInfoReturnable<Boolean> info) {
|
public URL logResourcePackStatus(String url, CallbackInfo info) {
|
||||||
DynRes.LOGGER.info("[CHECK] ResourcePackUrlValid=" + info.getReturnValue());
|
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;
|
package io.gitlab.jfronny.dynres.mixin;
|
||||||
|
|
||||||
import io.gitlab.jfronny.dynres.Cfg;
|
import io.gitlab.jfronny.dynres.*;
|
||||||
import io.gitlab.jfronny.dynres.DynRes;
|
import io.gitlab.jfronny.libjf.web.api.*;
|
||||||
import io.gitlab.jfronny.libjf.web.api.WebServer;
|
import io.gitlab.jfronny.libjf.web.impl.util.*;
|
||||||
import io.gitlab.jfronny.libjf.web.impl.util.WebPaths;
|
import net.minecraft.server.*;
|
||||||
import net.minecraft.server.dedicated.ServerPropertiesHandler;
|
import net.minecraft.server.dedicated.*;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import net.minecraft.text.*;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.jetbrains.annotations.*;
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
import org.spongepowered.asm.mixin.*;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.callback.*;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.*;
|
||||||
import java.security.MessageDigest;
|
import java.security.*;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.util.*;
|
||||||
|
|
||||||
@Mixin(ServerPropertiesHandler.class)
|
@Mixin(ServerPropertiesHandler.class)
|
||||||
public class ServerPropertiesHandlerMixin {
|
public abstract class ServerPropertiesHandlerMixin {
|
||||||
@Mutable @Final @Shadow public String resourcePackHash;
|
@Shadow @Nullable
|
||||||
@Mutable @Final @Shadow public String resourcePackSha1;
|
private static Text parseResourcePackPrompt(String prompt) {
|
||||||
@Mutable @Final @Shadow public String resourcePack;
|
throw new IllegalStateException("Mixin not applied");
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "<init>(Ljava/util/Properties;)V")
|
@Inject(method = "getServerResourcePackProperties(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;)Ljava/util/Optional;", at = @At("HEAD"), cancellable = true)
|
||||||
public void init(CallbackInfo info) {
|
private static void getServerResourcePackProperties(String url, String sha1, @Nullable String hash, boolean required, String prompt, CallbackInfoReturnable<Optional<MinecraftServer.ServerResourcePackProperties>> cir) {
|
||||||
if (DynRes.packFile != null) {
|
if (DynRes.packFile != null) {
|
||||||
resourcePack = WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip");
|
sha1 = "";
|
||||||
DynRes.LOGGER.info("Pack link: " + resourcePack);
|
|
||||||
resourcePackSha1 = "";
|
|
||||||
if (Cfg.hashResources) {
|
if (Cfg.hashResources) {
|
||||||
try {
|
try {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
for (byte b : MessageDigest.getInstance("SHA-1").digest(Files.readAllBytes(DynRes.packFile))) {
|
for (byte b : MessageDigest.getInstance("SHA-1").digest(Files.readAllBytes(DynRes.packFile))) {
|
||||||
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||||
}
|
}
|
||||||
resourcePackSha1 = result.toString();
|
sha1 = result.toString();
|
||||||
DynRes.LOGGER.info("Set hash to " + resourcePackSha1);
|
DynRes.LOGGER.info("Set hash to " + sha1);
|
||||||
} catch (IOException | NoSuchAlgorithmException e) {
|
} catch (IOException | NoSuchAlgorithmException e) {
|
||||||
DynRes.LOGGER.error("Failed to get hash, continuing with empty", 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"
|
"ServerInfoMixin"
|
||||||
],
|
],
|
||||||
"server": [
|
"server": [
|
||||||
"ServerPropertiesHandlerMixin",
|
"ServerPropertiesHandlerMixin"
|
||||||
"MinecraftServerMixin"
|
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Reference in New Issue