meteor-client icon indicating copy to clipboard operation
meteor-client copied to clipboard

ServerSpoof - RescurcePack

Open Nippaku-Zanmu opened this issue 1 year ago • 1 comments

Describe the bug

The RescurcePack in the ServerSpoof module does not work and will cause players to be unable to join the server

https://github.com/user-attachments/assets/9f09e9a0-1ae8-4207-bdb0-43e7a1ab4e88

https://github.com/user-attachments/assets/ccd3fd93-c2c8-428f-bbad-1508cb183658

Steps to reproduce

1.Enable ServerSpoof and check RescurcePack 2.Add a server that requires a RescurcePack 3.You will be taken to the Reconfiguring screen and will be stuck in this screen and will not be able to access the server

Meteor Version

0.5.8

Minecraft Version

1.21

Operating System

Windows

Before submitting a bug report

  • [X] This bug wasn't already reported (I have searched bug reports on GitHub).

  • [X] This is a valid bug (I am able to reproduce this on the latest dev build).

Nippaku-Zanmu avatar Aug 07 '24 08:08 Nippaku-Zanmu

I wrote a module to fix the bug but I couldn't find a server to force the installation of the resource pack for testing

public class AntiResourcePacket extends Module {

    public AntiResourcePacket() {
        super(Addon.CATEGORY, "anti-resourcePacket", "");
        this.runInMainMenu = true;
    }

    @EventHandler
    public void onPacket(PacketEvent.Send event) {

        if (event.packet instanceof ResourcePackStatusC2SPacket resPack) {

            if (resPack.status()== ResourcePackStatusC2SPacket.Status.DECLINED){
                event.cancel();
                event.connection.send(new ResourcePackStatusC2SPacket(resPack.id(), ResourcePackStatusC2SPacket.Status.ACCEPTED));
                event.connection.send(new ResourcePackStatusC2SPacket(resPack.id(),ResourcePackStatusC2SPacket.Status.SUCCESSFULLY_LOADED));
            }
        }
    }
    private MutableText msg;
    @EventHandler
    private void onPacketReceive(PacketEvent.Receive event) {
        if (!(event.packet instanceof ResourcePackSendS2CPacket packet)) return;

        msg = Text.literal("This server has ");
        msg.append(packet.required() ? "a required " : "an optional ").append("resource pack. ");
        System.out.println(packet.url());
        MutableText link = Text.literal("[Download]");
        link.setStyle(link.getStyle()
            .withColor(Formatting.BLUE)
            .withUnderline(true)
            .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, packet.url()))
            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to download")))
        );

        msg.append(link).append(" ");
    }
    @EventHandler
    private void onTick(TickEvent.Post event){
        if (mc.world!=null&&msg!=null){
            info(msg);
            msg = null;
        }
    }
}

Nippaku-Zanmu avatar Aug 08 '24 05:08 Nippaku-Zanmu

should be fixed as of 3ba75dff0a158d145c7c8f3434f7691c5bc58fd8

Wide-Cat avatar Sep 06 '24 20:09 Wide-Cat