• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python datautils.pack函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spock.mcp.datautils.pack函数的典型用法代码示例。如果您正苦于以下问题:Python pack函数的具体用法?Python pack怎么用?Python pack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pack函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: encode_extra

 def encode_extra(packet):
     o = b''
     act = packet.data['action']
     if act == mcdata.SO_CREATE_BOARD or act == mcdata.SO_UPDATE_BOARD:
         o += datautils.pack(MC_STRING, packet.data['obj_val'])
         o += datautils.pack(MC_STRING, packet.data['type'])
     return o
开发者ID:guineawheek,项目名称:spock,代码行数:7,代码来源:mcpacket_extensions.py


示例2: encode_extra

	def encode_extra(packet):
		o = datautils.pack('int', len(packet.data['blocks']))
		for block in packet.data['blocks']:
			for coord in block:
				o += datautils.pack('byte', coord)
		o += datautils.pack('float', packet.data['player_x'])
		o += datautils.pack('float', packet.data['player_y'])
		o += datautils.pack('float', packet.data['player_z'])
		return o
开发者ID:pickardjoe,项目名称:spock,代码行数:9,代码来源:mcpacket_extensions.py


示例3: encode

	def encode(self):
		#Ident
		o = datautils.pack('ubyte', self.__ident[2])
		#Payload
		for dtype, name in mcdata.hashed_structs[self.__hashed_ident]:
			o += datautils.pack(dtype, self.data[name])
		#Extension
		if self.__hashed_ident in hashed_extensions:
			o += hashed_extensions[self.__hashed_ident].encode_extra(self)
		return datautils.pack('varint', len(o)) + o
开发者ID:pickardjoe,项目名称:spock,代码行数:10,代码来源:mcpacket.py


示例4: encode_extra

 def encode_extra(packet):
     o  = datautils.pack(MC_SHORT, len(packet.data['blocks']))
     o += datautils.pack(MC_INT, 4*len(packet.data['blocks']))
     for block in packet.data['blocks']:
         o += datautils.pack(MC_UINT,
             block['metadata']  +
             (block['type']<<4) +
             (block['y'] << 16) +
             (block['z'] << 24) +
             (block['x'] << 28)
         )
     return o
开发者ID:OvercastNetwork,项目名称:spock,代码行数:12,代码来源:mcpacket_extensions.py


示例5: encode_extra

	def encode_extra(self, packet):
		packet.data['data_size'] = len(packet.data['data'])
		
		append = packet.data['data']
		
		for d in packet.data["bitmaps"]:
			append += pack('int', d['x'])
			append += pack('int', d['z'])
			append += pack('short', d['primary_bitmap'])
			append += pack('short', d['secondary_bitmap'])
		
		return append
开发者ID:JonnyD,项目名称:spock,代码行数:12,代码来源:mcpacket_extensions.py


示例6: encode

    def encode(self):
        #Ident
        o = datautils.pack(MC_VARINT, self.id)
        #Payload
        for dtype, name in mcdata.hashed_structs[self.__hashed_ident]:
            o += datautils.pack(dtype, self.data[name])
        #Extension
        if self.__hashed_ident in hashed_extensions:
            o += hashed_extensions[self.__hashed_ident].encode_extra(self)

        self.length = len(o)
        return datautils.pack(MC_VARINT, self.length) + o
开发者ID:OvercastNetwork,项目名称:spock,代码行数:12,代码来源:mcpacket.py


示例7: encode

	def encode(self):
		#Ident
		output = datautils.pack('ubyte', self.ident)
		
		#Extension
		if self.ident in mcpacket_extensions.extensions:
			append = mcpacket_extensions.extensions[self.ident].encode_extra(self)
		else:
			append = b''
		
		#Payload
		for dtype, name in mcdata.structs[self.ident][self.direction]:
			output += datautils.pack(dtype, self.data[name])

		return output + append
开发者ID:JonnyD,项目名称:spock,代码行数:15,代码来源:mcpacket.py


示例8: encode

    def encode(self, proto_comp_state, proto_comp_threshold, comp_level = 6):
        #Ident
        o = datautils.pack(MC_VARINT, self.ident[2])
        #Payload
        for dtype, name in mcdata.hashed_structs[self.ident]:
            o += datautils.pack(dtype, self.data[name])
        #Extension
        if self.ident in hashed_extensions:
            o += hashed_extensions[self.ident].encode_extra(self)

        if proto_comp_state == mcdata.PROTO_COMP_ON:
            uncompressed_len = len(o)
            if uncompressed_len < proto_comp_threshold:
                header = datautils.pack(MC_VARINT, uncompressed_len + 1)
                header += datautils.pack(MC_VARINT, 0)
            elif uncompressed_len >= proto_comp_threshold:
                o = zlib.compress(o, comp_level)
                ulen_varint = datautils.pack(MC_VARINT, uncompressed_len)
                header = datautils.pack(MC_VARINT, uncompressed_len + len(ulen_varint))
                header += ulen_varint
            return header + o
        elif proto_comp_state == mcdata.PROTO_COMP_OFF:
            return datautils.pack(MC_VARINT, len(o)) + o
        else:
            return None
开发者ID:guineawheek,项目名称:spock,代码行数:25,代码来源:mcpacket.py


示例9: encode_extra

 def encode_extra(packet):
     act = packet.data['action']
     o = b''
     if act in [mcdata.TE_CREATE_TEAM, mcdata.TE_UPDATE_TEAM]:
         o += datautils.pack(MC_STRING, packet.data['display_name'])
         o += datautils.pack(MC_STRING, packet.data['team_prefix'])
         o += datautils.pack(MC_STRING, packet.data['team_suffix'])
         o += datautils.pack(MC_BYTE, packet.data['friendly_fire'])
         o += datautils.pack(MC_STRING, packet.data['name_visibility'])
         o += datautils.pack(MC_BYTE, packet.data['color'])
     if act in [mcdata.TE_CREATE_TEAM, mcdata.TE_ADDPLY_TEAM,
                mcdata.TE_REMPLY_TEAM]:
         o += datautils.pack(MC_VARINT, len(packet.data['players']))
         for player in packet.data['players']:
             o += datautils.pack(MC_STRING, player)
     return o
开发者ID:nicoxxl,项目名称:SpockBot,代码行数:16,代码来源:mcpacket_extensions.py


示例10: encode_extra

	def encode_extra(packet):
		action = packet.data['action']
		o = b''
		if action == 0 or action == 2:
			o += datautils.pack(MC_STRING, packet.data['display_name'])
			o += datautils.pack(MC_STRING, packet.data['team_prefix'])
			o += datautils.pack(MC_STRING, packet.data['team_suffix'])
			o += datautils.pack(MC_BYTE, packet.data['friendly_fire'])
			o += datautils.pack(MC_STRING, packet.data['name_visibility'])
		if action == 0 or action == 3 or action == 4:
			o += datautils.pack(MC_VARINT, len(packet.data['players']))
			for player in packet.data['players']:
				o += datautils.pack(MC_STRING, player)
		return o
开发者ID:nheir,项目名称:spock,代码行数:14,代码来源:mcpacket_extensions.py



注:本文中的spock.mcp.datautils.pack函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python datautils.unpack函数代码示例发布时间:2022-05-27
下一篇:
Python searchcommands.dispatch函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap