From 4bf6f3d852dd1275e3b0c4e0e70a1ad1b1a3fa96 Mon Sep 17 00:00:00 2001 From: PeriodicSeizures <47781580+PeriodicSeizures@users.noreply.github.com> Date: Wed, 16 Aug 2023 09:59:14 -0400 Subject: [PATCH] Spoof resource packs Prevents some servers *cough* *cough* *cubecraft* from kicking you if resource pack denied or failed to download. Disabled by default because its not as necessary when compared to something like NoChatReports or NoTelemetry. --- .../mixin/ClientPlayNetworkHandlerMixin.java | 26 ++++++++++--- .../wurstclient/other_feature/OtfList.java | 1 + .../other_features/SpoofResourcePackOtf.java | 38 +++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 src/main/java/net/wurstclient/other_features/SpoofResourcePackOtf.java diff --git a/src/main/java/net/wurstclient/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/net/wurstclient/mixin/ClientPlayNetworkHandlerMixin.java index 9d246a74be..14af0a15ba 100644 --- a/src/main/java/net/wurstclient/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/net/wurstclient/mixin/ClientPlayNetworkHandlerMixin.java @@ -7,6 +7,9 @@ */ package net.wurstclient.mixin; +import net.minecraft.fluid.FluidState; +import net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket; +import net.minecraft.network.packet.s2c.play.*; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -19,10 +22,6 @@ import net.minecraft.client.toast.SystemToast; import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; -import net.minecraft.network.packet.s2c.play.ChunkData; -import net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket; -import net.minecraft.network.packet.s2c.play.ServerMetadataS2CPacket; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.wurstclient.WurstClient; @@ -37,7 +36,7 @@ public abstract class ClientPlayNetworkHandlerMixin @Shadow @Final private MinecraftClient client; - + @Inject(at = @At("HEAD"), method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) @@ -101,4 +100,21 @@ private void onOnChunkDeltaUpdate(ChunkDeltaUpdateS2CPacket packet, (pos, state) -> WurstClient.INSTANCE.getHax().newChunksHack .afterUpdateBlock(pos)); } + + @Inject(at = @At("HEAD"), + method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/play/ResourcePackSendS2CPacket;)V", + cancellable = true) + private void onOnResourcePackSend(ResourcePackSendS2CPacket packet, + CallbackInfo ci) + { + if(!WurstClient.INSTANCE.getOtfs().spoofResourcePackOtf.isEnabled()) + return; + + this.sendResourcePackStatus(ResourcePackStatusC2SPacket.Status.ACCEPTED); + + ci.cancel(); + } + + @Shadow + protected abstract void sendResourcePackStatus(ResourcePackStatusC2SPacket.Status packet); } diff --git a/src/main/java/net/wurstclient/other_feature/OtfList.java b/src/main/java/net/wurstclient/other_feature/OtfList.java index 5076b5feab..269c4b5d02 100644 --- a/src/main/java/net/wurstclient/other_feature/OtfList.java +++ b/src/main/java/net/wurstclient/other_feature/OtfList.java @@ -27,6 +27,7 @@ public final class OtfList public final NoTelemetryOtf noTelemetryOtf = new NoTelemetryOtf(); public final ReconnectOtf reconnectOtf = new ReconnectOtf(); public final ServerFinderOtf serverFinderOtf = new ServerFinderOtf(); + public final SpoofResourcePackOtf spoofResourcePackOtf = new SpoofResourcePackOtf(); public final TabGuiOtf tabGuiOtf = new TabGuiOtf(); public final TranslationsOtf translationsOtf = new TranslationsOtf(); public final VanillaSpoofOtf vanillaSpoofOtf = new VanillaSpoofOtf(); diff --git a/src/main/java/net/wurstclient/other_features/SpoofResourcePackOtf.java b/src/main/java/net/wurstclient/other_features/SpoofResourcePackOtf.java new file mode 100644 index 0000000000..9b6086e169 --- /dev/null +++ b/src/main/java/net/wurstclient/other_features/SpoofResourcePackOtf.java @@ -0,0 +1,38 @@ +package net.wurstclient.other_features; + +import net.wurstclient.other_feature.OtherFeature; +import net.wurstclient.settings.CheckboxSetting; + +public final class SpoofResourcePackOtf extends OtherFeature { + + private final CheckboxSetting disableResourcePacks = + new CheckboxSetting("Disable downloaded resource packs", false); + + public SpoofResourcePackOtf() + { + super("SpoofResourcePack", + "Skips downloading and success confirmation of resource packs for some servers"); + addSetting(disableResourcePacks); + } + + @Override + public boolean isEnabled() + { + return disableResourcePacks.isChecked(); + } + + @Override + public String getPrimaryAction() + { + return isEnabled() ? "Re-enable downloading" : "Disable downloading"; + } + + @Override + public void doPrimaryAction() + { + disableResourcePacks.setChecked(!disableResourcePacks.isChecked()); + } + + // See ClientPlayNetworkHandlerMixin::onOnResourcePackSend + +}