Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jan 3, 2024
2 parents 1c2f0e1 + 1cbc880 commit 53084c4
Showing 1 changed file with 1 addition and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.storage.InventoryAcknowledgements;
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
Expand All @@ -42,7 +40,6 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand Down Expand Up @@ -76,9 +73,6 @@ private static URL getParsedResourcePackUrl(String url) {
return null;
}

@Unique
private URL viaFabricPlus$lastValidatedUrl;

@Redirect(method = "onKeepAlive", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;send(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V"))
private void forceSendKeepAlive(ClientCommonNetworkHandler instance, Packet<? extends ServerPacketListener> packet, BooleanSupplier sendCondition, Duration expiry) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
Expand Down Expand Up @@ -120,21 +114,11 @@ private void handleSyncTask(CustomPayloadS2CPacket packet, CallbackInfo ci) {
@Inject(method = "onResourcePackSend", at = @At("HEAD"), cancellable = true)
private void validateUrlInNetworkThread(ResourcePackSendS2CPacket packet, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) {
viaFabricPlus$lastValidatedUrl = getParsedResourcePackUrl(packet.url());
if (viaFabricPlus$lastValidatedUrl == null) {
if (getParsedResourcePackUrl(packet.url()) == null) {
this.connection.send(new ResourcePackStatusC2SPacket(packet.id(), ResourcePackStatusC2SPacket.Status.INVALID_URL));
ci.cancel();
}
}
}

@WrapOperation(method = "onResourcePackSend", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;getParsedResourcePackUrl(Ljava/lang/String;)Ljava/net/URL;"))
private URL useLastValidatedUrl(String url, Operation<URL> original) {
if (viaFabricPlus$lastValidatedUrl != null) {
return viaFabricPlus$lastValidatedUrl;
} else {
return original.call(url);
}
}

}

0 comments on commit 53084c4

Please sign in to comment.