Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click Window packet #226

Open
bluehahaa opened this issue May 22, 2021 · 2 comments
Open

Click Window packet #226

bluehahaa opened this issue May 22, 2021 · 2 comments

Comments

@bluehahaa
Copy link

bluehahaa commented May 22, 2021

Heya there, I've been trying for some time now to try to get the bot to click on a specific slot when a GUI pops up for it.
For that, I defined

class ClickWindowPacket(Packet):
    @staticmethod
    def get_id(context):
        return 0x09
    packet_name = 'Click Window'
    get_definition = staticmethod(lambda context: [{'slot': Short}, {'button': Byte}, {'windowID': Byte}])
in the serverbound>play>__init__ file, & tried using it in my bot, just as a test.
   if text == "/gui":
                print("Trying to click on slot 10")
                packet2 = serverbound.play.ClickWindowPacket()
                packet2.slot = 10
                packet2.button = 0
                packet2.windowID = 0
                connection.write_packet(packet2)

Absolutely no help. The server kicks the bot for io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(5) + length(2) exceeds writerIndex(5): PooledUnsafeDirectByteBuf(ridx: 5, widx: 5, cap: 5) & I couldn't figure out why.

I've already tried changing slot numbers, window ID, button...
I didn't define mode, action number nor clicked item (even though the latter would be extremely helpful) because there was no "Slot" type, & I didn't know how to define that.

The GUI open is a large chest container, also tried getting the unique windowID when a GUI opens but I couldn't get the OpenWindowPacket to properly work.

Spent a very long time on this & hoping someone could possibly help, would be greatly appreciated; thanks.

@MisterSoandSo
Copy link
Contributor

It might be helpful to include a fork of the repository that you working with for people help better debug your issue. Otherwise, it would be ignored till a later date.

@joodicator
Copy link
Collaborator

@bluehahaa Since you're giving the packet ID of Click Window as 0x09, I assume you're trying to implement the 1.14-1.16 version of this packet. In that case, you're missing some fields from the packet definition, and the fields you have included are in the wrong order, and some have the wrong types: https://wiki.vg/index.php?title=Protocol&oldid=14643#Click_Window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants