Git Product home page Git Product logo

Comments (6)

gurland avatar gurland commented on July 27, 2024 1

I found that packet http://wiki.vg/Protocol#Player_Block_Placement by looking at raw representation of sent packet.

from pycraft.

MiniDigger avatar MiniDigger commented on July 27, 2024

you want to take a look at the use item packet

from pycraft.

gurland avatar gurland commented on July 27, 2024

I'm trying this

class UseItemPacket(Packet):
    @staticmethod
    def get_id(context):
        return 0x20

    packet_name = 'use item'
    get_definition = staticmethod(lambda context: [
        {'hand': VarInt}
])
...
while True:
    try:
        text = input()
        if text == "/rmb":
            print("Pressing")
            packet = UseItemPacket()
            packet.hand = 0
            connection.write_packet(packet)
        else:
            packet = serverbound.play.ChatPacket()
            packet.message = text
            connection.write_packet(packet)
    except KeyboardInterrupt:
        print("Bye!")
        sys.exit()

What's in log:

/rmb
Pressing
<-- 0x20 UseItemPacket(hand=0)

And nothing else. After issuing /home command (which is aviable only after clicking on that sign) nothing happens (server says Unknown command).

After that I was searching for logging debug info (especially network packets). So I made this config active (http://wiki.vg/Debugging#Network_packets_only).
Here is log:

# Here I'm clicking
[15:17:42] [Netty Epoll Client IO #0/DEBUG]: OUT: [PLAY:13] lk$a
[15:17:42] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:71] ko
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:9] ih
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:9] ih
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:9] ih
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:9] ih
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:9] ih
[15:17:43] [Netty Epoll Client IO #0/DEBUG]: OUT: [PLAY:31] ma
[15:17:43] [Netty Epoll Client IO #0/DEBUG]: OUT: [PLAY:29] ly
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:20] is
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:22] iu
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:22] iu
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:11] ij
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:11] ij
[15:17:43] [main/INFO]: [CHAT] You do not have permission to build here.
# That's written after click
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:53] jw
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:53] jw
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:24] iw
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:24] iw
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:13] il
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:44] jn
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:58] kb
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:27] iz
[15:17:43] [main/INFO]: [CHAT] Welcome to alpha!
[15:17:43] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:49] js
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:15] in
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:46] jp
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:73] kq
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:73] kq
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:73] kq
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:73] kq
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:32] je
[15:17:44] [Netty Epoll Client IO #0/DEBUG]:  IN: [PLAY:0] hx
# Now I'm on the server

Unfortunately I'm not able to understand packets in that representation.
So I skimmed wiki and found that packet. I think it's much more suitable in my case. But I don't know how work with it. Maybe Target field should contain entity id? But I haven't found sign entity ID so I'm confused how to construct packets now...

from pycraft.

gurland avatar gurland commented on July 27, 2024

I thought if there is no entity id for sign then I can try use entity by cords so I tried this code:

class UseEntityPacket(Packet):
    @staticmethod
    def get_id(context):
        return 0x0A

    packet_name = 'use entity'
    get_definition = staticmethod(lambda context: [
        {'target': VarInt},
        {'type': VarInt},  
        {'x': Float},
        {'y': Float},
        {'z': Float},
        {'hand': VarInt},
])
...
if text == "/rmb":
    print("Pressing")
    packet = UseEntityPacket()
    packet.target = 1
    packet.type = 2
    packet.x = 1400.2
    packet.y = 6
    packet.z = 1293.3
    packet.hand = 0
    connection.write_packet(packet)

But unfortunately nothing happens. Same result as in previous code, so I really require some help
Also @joodicator add question label please and maybe try to help me solve my problem

from pycraft.

gurland avatar gurland commented on July 27, 2024

I've decompiled minecraft using Mod Coder Pack and inserted some debugging code. Here we are, now I know exact packets which real game sends:

OUT: [PLAY:31] net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock
OUT: [PLAY:29] net.minecraft.network.play.client.CPacketAnimation
[10:07:28] [Client thread/INFO]: [CHAT] You do not have permission to build here.
OUT: [PLAY:13] net.minecraft.network.play.client.CPacketPlayer$Position
[10:07:28] [Client thread/INFO]: [CHAT] Welcome to alpha!
...
TryUseItemOnBlock: pos[BlockPos{x=1399, y=5, z=1293}] | dir[west] | hand[MAIN_HAND] | x[0.875] | y[0.468] | z[0.686]

So I've almost got to the point

from pycraft.

gurland avatar gurland commented on July 27, 2024

Yes, I finally made this.
Also I found bug in Position type so I'll fix it in pull request.

from pycraft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.