barneygale / quarry

Python library that implements the Minecraft network protocol and data types
Other
527 stars 75 forks source link

builtins.TypeError: '<=' not supported between instances of 'int' and 'str' #174

Closed ZaneMCXVII closed 1 year ago

ZaneMCXVII commented 1 year ago

I'm trying to write a proxy that opens a window with some items when a player types a command in chat, but am having issues setting the slots in the window.

This is the code for opening the window and adding the one item:

buf = buff.pack_varint(117) + buff.pack_varint(2) + buff.pack_chat("lol")
            self.downstream.send_packet("open_window", buf)
            self.downstream.send_packet("set_slot", 
    self.buff_type.pack('bh', 117, 0) + \
    self.buff_type.pack_slot("emerald", 1)) 

If you read the title you probably know the error this is giving me: builtins.TypeError: '<=' not supported between instances of 'int' and 'str' I tried replacing the string id of "emerald" in the pack_slot function with a numerical ID, and all that gave me was Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(8) + length(1) exceeds writerIndex(8): PooledUnsafeDirectByteBuf(ridx: 8, widx: 8, cap: 8). I'm not sure if I'm doing something wrong or if this is an issue with quarry.

Any help is appreciated.

davidawesome02 commented 1 year ago

:) add me on discord davidawesome01#3886 did this a lot, made a hacked proxy with it lol

ZaneMCXVII commented 1 year ago

Solved it! All I had to do was add a LookupRegistry to self.buff_type and add minecraft: to the beginning of the ID so it would be encoded correctly. After that it worked perfectly. (Well, not really... the emerald was a piece of andesite. Probably just because I'm using a 1.16.5 registry with a 1.18.2 proxy.)