def encode(self) -> bytes: out = Buffer.pack_varint(self.action) + len(self.players) if self.action == 0: # add player for player in self.players: out += ( Buffer.pack_uuid(player["uuid"]) + Buffer.pack_string(player["name"]) + Buffer.pack_varint(len(player["properties"])) ) for prop in player["properties"]: out += ( Buffer.pack_string(prop["name"]) + Buffer.pack_string(prop["value"]) + Buffer.pack_optional(Buffer.pack_string, prop.get("signature")) ) out += ( Buffer.pack_varint(player["gamemode"]) + Buffer.pack_varint(player["ping"]) + Buffer.pack_optional(Buffer.pack_chat, player["display_name"]) ) elif self.action == 1: # update gamemode out += b"".join(Buffer.pack_uuid(p["uuid"]) + Buffer.pack_varint(p["gamemode"]) for p in self.players) elif self.action == 2: # update latency out += b"".join(Buffer.pack_uuid(p["uuid"]) + Buffer.pack_varint(p["ping"]) for p in self.players) elif self.action == 3: # update display name out += b"".join(Buffer.pack_uuid(p["uuid"]) + Buffer.pack_optional(p.get("display_name")) for p in self.players) elif self.action == 4: out += b"".join(Buffer.pack_uuid(p["uuid"]) for p in self.players) return out
def encode(self) -> bytes: return (Buffer.pack_varint(self.entity_id) + Buffer.pack_uuid(self.object_uuid) + Buffer.pack_varint(self.type_) + Buffer.pack("d" + self.x) + Buffer.pack("d" + self.y) + Buffer.pack("d" + self.z) + Buffer.pack("i" + self.pitch) + Buffer.pack("i" + self.yaw) + Buffer.pack("h" + self.vloc_x) + Buffer.pack("h" + self.vloc_x) + Buffer.pack("h" + self.vloc_z))
def encode(self) -> bytes: # See here for data: https://wiki.vg/Protocol#Boss_Bar out = Buffer.pack_uuid(self.uuid) + Buffer.pack_varint(self.action) if self.action == 0: out += ( Buffer.pack_chat(self.data["title"]) + Buffer.pack("f", self.data["health"]) + Buffer.pack_varint(self.data["color"]) + Buffer.pack_varint(self.data["division"]) + Buffer.pack("B", self.data["flags"]) ) elif self.action == 2: out += Buffer.pack("f", self.data["health"]) elif self.action == 3: out += Buffer.pack_chat(self.data["title"]) elif self.action == 4: out += Buffer.pack_varint(self.data["color"]) + Buffer.pack_varint(self.data["division"]) elif self.action == 5: out += Buffer.pack("B", self.data["flags"]) return out
def encode(self) -> bytes: return Buffer.pack_chat(self.data) + Buffer.pack( "b", self.position) + Buffer.pack_uuid(self.sender)
def encode(self) -> bytes: return Buffer.pack_uuid(self.uuid) + Buffer.pack_string(self.username)
def encode(self) -> bytes: return (Buffer.pack_varint(self.entity_id) + Buffer.pack_uuid(self.player_uuid) + Buffer.pack("d", self.x) + Buffer.pack("d", self.y) + Buffer.pack("d", self.z) + Buffer.pack("B", self.pitch) + Buffer.pack("B", self.yaw))
def encode(self) -> bytes: return (Buffer.pack_varint(self.entity_id) + Buffer.pack_uuid(self.entity_uuid) + Buffer.pack_varint(self.motive) + Buffer.pack_pos(self.location) + Buffer.pack("b", self.direction))