Beispiel #1
0
 def send_mob(self,eid,type_,pos=(0,0,0),yaw=0,pitch=0,headpitch=0,uuid=UUID.random()):
     if self.protocol_version < 400:
         self.send_packet('spawn_mob', 
               self.bt.pack_varint(eid)
             + self.bt.pack_uuid(uuid)
             + self.bt.pack_varint(type_)
             + self.bt.pack('dddfffhhh',*pos,yaw,pitch,headpitch,0,0,0)
             + self.bt.pack_entity_metadata({}))
Beispiel #2
0
    def __init__(self, protocol: Protocol, bedrock: False):
        self.protocol = protocol
        self.viewpoint_id = 999
        self.viewpoint_uuid = UUID.random()

        self.current_chunk = None
        self.current_viewpoint = None
        self.raining = False

        self.player_spawned = False
        self.viewpoint_spawned = False
        self.viewpoint_used = False

        self.last_click = time.time()

        self.version_name = None
        self.is_bedrock = bedrock
Beispiel #3
0
    def __init__(self,
                 factory,
                 buff_class,
                 handle_direction,
                 other_factory,
                 protocol_version,
                 uuid=None):
        """
		Protocol args:
			factory: factory that made this protocol (subclass of BaseFactory)
			buff_class: buffer class that this protocol will use
			handle_direction: direction packets being handled by this protocol are going (can be "downstream" or "upstream")
			other_factory: the other factory that communicates with this protocol (in this case an instance of EWProtocol)
			protocol_version: protocol specification to use
			uuid: uuid of client, don't set to autogen
		"""
        super().__init__(factory, buff_class, handle_direction, other_factory)
        self.protocol_version = protocol_version
        self.protocol_mode = "init"
        self.uuid = uuid or UUID.random()
Beispiel #4
0
    def __init__(self, factory, remote_addr):
        from queueserver.versions import Version_1_15, Version_1_16, Version_1_16_2, Version_1_17, Version_1_17_1
        self.uuid = UUID.random()

        self.forwarded_uuid = None
        self.forwarded_host = None
        self.is_bedrock = False
        self.version = None
        self.versions = {
            578: Version_1_15,
            736: Version_1_16,
            751: Version_1_16_2,
            755: Version_1_17,
            756: Version_1_17_1
        }

        super(Protocol, self).__init__(factory, remote_addr)

        self.logger.addHandler(console_handler)
        self.logger.addHandler(file_handler)
Beispiel #5
0
    def update_music(self, create=False):
        if not self.song_start:
            self.song_start = datetime.now()

        percent = (datetime.now() - self.song_start).seconds / ((2 * 60) + 32)

        if create:
            self.music_bar_uuid = UUID.random()
            self.send_packet(
                "boss_bar",
                self.buff_type.pack_uuid(self.music_bar_uuid),
                self.buff_type.pack_varint(0),
                self.buff_type.pack_chat(
                    Message({
                        "text": "Server is loading -- Playing Stal by C418",
                        "color": "bold",
                    })),
                self.buff_type.pack("f", percent),
                self.buff_type.pack_varint(1),
                self.buff_type.pack_varint(0),
                self.buff_type.pack("B", 0b00000),
            )

            # Play "Stal" by C418
            self.send_packet(
                "sound_effect",
                self.buff_type.pack_varint(474),
                self.buff_type.pack_varint(2),
                self.buff_type.pack(
                    "iiiff",
                    int(default_pos[0] * 8),
                    int(default_pos[1] * 8),
                    int(default_pos[2] * 8),
                    1,
                    1,
                ),
            )  # teleport id
        elif self.playing_music:
            if percent > 1:
                self.send_packet(
                    "boss_bar",
                    self.buff_type.pack_uuid(self.music_bar_uuid),
                    self.buff_type.pack_varint(2),
                    self.buff_type.pack("f", 1),
                )
                self.send_packet(
                    "boss_bar",
                    self.buff_type.pack_uuid(self.music_bar_uuid),
                    self.buff_type.pack_varint(3),
                    self.buff_type.pack_chat(
                        Message({
                            "text": "Server is still loading -- hang tight!",
                            "color": "bold",
                        })),
                )

                self.playing_music = False
                return
            self.send_packet(
                "boss_bar",
                self.buff_type.pack_uuid(self.music_bar_uuid),
                self.buff_type.pack_varint(2),
                self.buff_type.pack("f", percent),
            )
Beispiel #6
0
 def create(self):
     self.protocol_version = self.config["global"]["protocol_version"]
     self.protocol_mode = "init"
     self.uuid = UUID.random()  # UUID can be overriden
Beispiel #7
0
	def __init__(self, *args, **kwargs):
		self.core = CoreProtocol(self)
		self._uuid = UUID.random()
		self.real_uuid = None
		
		super(DownstreamProtocol, self).__init__(*args, **kwargs)