How to use the quarry.net.client.register function in quarry

To help you get started, we’ve selected a few quarry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x2f)
    def received_set_slot(self, buff):
        window_id = buff.unpack('b')
        slot_nr = buff.unpack('h') # number of the changed slot in the window
        slot = self.unpack_slot(buff) # tuple for slot instantiation
        if window_id != -1: # Notchian server apparently sends window_id = slot_nr = -1 on /clear, ignore
            self.window_handler[window_id].set_slot(slot_nr, *slot)
            self.on_slot_change(window_id, slot_nr)
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x06)
    def received_uptate_health(self, buff):
        self.health = buff.unpack('f')
        self.food = buff.unpack_varint()
        self.saturation = buff.unpack('f')
        self.on_update_health()
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x19)
    def received_entity_head_look(self, buff):
        eid = buff.unpack_varint()
        yaw = buff.unpack('B') * 360 / 256
        self.entities[eid].head_look(yaw)
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x32)
    def received_confirm_transaction(self, buff):
        window_id = buff.unpack('b')
        action_id = buff.unpack('h')
        accepted = buff.unpack('?')
        self.on_confirm_transaction(window_id, action_id, accepted)
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x30)
    def received_window_items(self, buff):
        window_id = buff.unpack('B')
        num_slots = buff.unpack('h')
        for slot_nr in range(num_slots):
            self.window_handler[window_id].set_slot(slot_nr, *self.unpack_slot(buff))
            self.on_slot_change(window_id, slot_nr)
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x0e)
    def received_spawn_object(self, buff):
        eid = buff.unpack_varint()
        obj_type = buff.unpack('b')
        coords = [float(i) / 32 for i in buff.unpack('iii')]
        pitch, yaw = (i * 360 / 256 for i in buff.unpack('BB'))
        data = {}
        buff.discard() # TODO read entity data
        self.entities.add_object(eid, obj_type, coords, yaw, pitch, data)
        self.on_spawn_object(eid)
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x0f)
    def received_spawn_mob(self, buff):
        eid = buff.unpack_varint()
        mob_type = buff.unpack('b')
        coords = [float(i) / 32 for i in buff.unpack('iii')]
        yaw, pitch = (i * 360 / 256 for i in buff.unpack('BB'))
        head_pitch = buff.unpack('B') * 360 / 256
        velocity = [0,0,0]
        data = {}
        buff.discard() # TODO read velocity, metadata
        self.entities.add_mob(eid, mob_type, coords, yaw, pitch, data, velocity, head_pitch)
        self.on_spawn_mob(eid)
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x2d)
    def received_open_window(self, buff):
        window_id = buff.unpack('B')
        window_type = buff.unpack_string()
        window_title = buff.unpack_chat()
        num_slots = buff.unpack('B')
        horse_entity_id = buff.unpack('i') if window_type == 'EntityHorse' else None
        self.window_handler.open_window(window_id, window_type, window_title, num_slots, horse_entity_id)
        self.on_open_window(window_id)
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x08)
    def received_player_position_and_look(self, buff):
        """ Sent on spawning, teleport and motion error """
        coords = list(buff.unpack('ddd'))
        yaw = buff.unpack('f')
        pitch = buff.unpack('f')
        position_flags = buff.unpack('B')

        # bits in position_flags indicate relative values
        if position_flags & (1 << 0): coords[0] += self.coords[0]
        if position_flags & (1 << 1): coords[1] += self.coords[1]
        if position_flags & (1 << 2): coords[2] += self.coords[2]
        if position_flags & (1 << 3): yaw += self.yaw
        if position_flags & (1 << 4): pitch += self.pitch

        # if client just spawned, start sending player_look to prevent timeout
        # once per 30s, TODO might skip when sent some other packet recently
github Gjum / Bat / botProtocol.py View on Github external
    @register("play", 0x22)
    def received_multi_block_change(self, buff):
        chunk_x, chunk_z = buff.unpack('ii')
        block_count = buff.unpack_varint()
        for i in range(block_count):
            coord_bits = buff.unpack('H')
            y = coord_bits & 0xff
            z = (chunk_z * 16) + (coord_bits >> 8) & 0xf
            x = (chunk_x * 16) + (coord_bits >> 12) & 0xf
            data = buff.unpack_varint()
            self.world.set_block((x, y, z), data)
        self.on_world_changed('received_multi_block_change')