39 lines
1.8 KiB
Java
39 lines
1.8 KiB
Java
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;
|
|
}
|
|
}
|