moved send_join_game
This commit is contained in:
parent
cccc606212
commit
b0b54d9fb9
|
@ -20,7 +20,7 @@ class YTDServerProtocol(ServerProtocol):
|
||||||
ServerProtocol.player_joined(self)
|
ServerProtocol.player_joined(self)
|
||||||
|
|
||||||
# Send join game packet
|
# Send join game packet
|
||||||
self.factory.send_join_game(self)
|
self.send_join_game()
|
||||||
|
|
||||||
# Send "Player Position and Look" packet
|
# Send "Player Position and Look" packet
|
||||||
self.send_packet(
|
self.send_packet(
|
||||||
|
@ -44,6 +44,48 @@ class YTDServerProtocol(ServerProtocol):
|
||||||
# Send full player list
|
# Send full player list
|
||||||
self.factory.send_player_list_add(self, self.factory.players)
|
self.factory.send_player_list_add(self, self.factory.players)
|
||||||
|
|
||||||
|
def send_join_game(self):
|
||||||
|
# Build up fields for "Join Game" packet
|
||||||
|
entity_id = 0
|
||||||
|
max_players = 0
|
||||||
|
hashed_seed = 42
|
||||||
|
view_distance = 2
|
||||||
|
simulation_distance = 2
|
||||||
|
game_mode = 3
|
||||||
|
prev_game_mode = 3
|
||||||
|
is_hardcore = False
|
||||||
|
is_reduced_debug = False
|
||||||
|
is_respawn_screen = False
|
||||||
|
is_debug = False
|
||||||
|
is_flat = True
|
||||||
|
|
||||||
|
dimension_codec = data_packs[self.protocol_version]
|
||||||
|
dimension_name = "minecraft:overworld"
|
||||||
|
dimension_tag = dimension_types[self.protocol_version, dimension_name]
|
||||||
|
world_count = 1
|
||||||
|
world_name = "favorite_place"
|
||||||
|
|
||||||
|
join_game = [
|
||||||
|
self.buff_type.pack("i?Bb", entity_id, is_hardcore, game_mode, prev_game_mode),
|
||||||
|
self.buff_type.pack_varint(world_count),
|
||||||
|
self.buff_type.pack_string(world_name),
|
||||||
|
self.buff_type.pack_nbt(dimension_codec),
|
||||||
|
]
|
||||||
|
|
||||||
|
join_game.append(self.buff_type.pack_nbt(dimension_tag))
|
||||||
|
|
||||||
|
join_game.append(self.buff_type.pack_string(world_name))
|
||||||
|
join_game.append(self.buff_type.pack("q", hashed_seed))
|
||||||
|
join_game.append(self.buff_type.pack_varint(max_players))
|
||||||
|
join_game.append(self.buff_type.pack_varint(view_distance)),
|
||||||
|
|
||||||
|
join_game.append(self.buff_type.pack_varint(simulation_distance))
|
||||||
|
|
||||||
|
join_game.append(self.buff_type.pack("????", is_reduced_debug, is_respawn_screen, is_debug, is_flat))
|
||||||
|
|
||||||
|
# Send "Join Game" packet
|
||||||
|
self.send_packet("join_game", *join_game)
|
||||||
|
|
||||||
def player_left(self):
|
def player_left(self):
|
||||||
ServerProtocol.player_left(self)
|
ServerProtocol.player_left(self)
|
||||||
|
|
||||||
|
@ -83,48 +125,6 @@ class YTDServerFactory(ServerFactory):
|
||||||
motd = "YTD Custom Server (WIP)"
|
motd = "YTD Custom Server (WIP)"
|
||||||
force_protocol_version = 758
|
force_protocol_version = 758
|
||||||
|
|
||||||
def send_join_game(self, player):
|
|
||||||
# Build up fields for "Join Game" packet
|
|
||||||
entity_id = 0
|
|
||||||
max_players = 0
|
|
||||||
hashed_seed = 42
|
|
||||||
view_distance = 2
|
|
||||||
simulation_distance = 2
|
|
||||||
game_mode = 3
|
|
||||||
prev_game_mode = 3
|
|
||||||
is_hardcore = False
|
|
||||||
is_respawn_screen = True
|
|
||||||
is_reduced_debug = False
|
|
||||||
is_debug = False
|
|
||||||
is_flat = False
|
|
||||||
|
|
||||||
dimension_codec = data_packs[player.protocol_version]
|
|
||||||
dimension_name = "minecraft:overworld"
|
|
||||||
dimension_tag = dimension_types[player.protocol_version, dimension_name]
|
|
||||||
world_count = 1
|
|
||||||
world_name = "chat"
|
|
||||||
|
|
||||||
join_game = [
|
|
||||||
player.buff_type.pack("i?Bb", entity_id, is_hardcore, game_mode, prev_game_mode),
|
|
||||||
player.buff_type.pack_varint(world_count),
|
|
||||||
player.buff_type.pack_string(world_name),
|
|
||||||
player.buff_type.pack_nbt(dimension_codec),
|
|
||||||
]
|
|
||||||
|
|
||||||
join_game.append(player.buff_type.pack_nbt(dimension_tag))
|
|
||||||
|
|
||||||
join_game.append(player.buff_type.pack_string(world_name))
|
|
||||||
join_game.append(player.buff_type.pack("q", hashed_seed))
|
|
||||||
join_game.append(player.buff_type.pack_varint(max_players))
|
|
||||||
join_game.append(player.buff_type.pack_varint(view_distance)),
|
|
||||||
|
|
||||||
join_game.append(player.buff_type.pack_varint(simulation_distance))
|
|
||||||
|
|
||||||
join_game.append(player.buff_type.pack("????", is_reduced_debug, is_respawn_screen, is_debug, is_flat))
|
|
||||||
|
|
||||||
# Send "Join Game" packet
|
|
||||||
player.send_packet("join_game", *join_game)
|
|
||||||
|
|
||||||
# Sends an unsigned chat message, using system messages on supporting clients
|
# Sends an unsigned chat message, using system messages on supporting clients
|
||||||
def broadcast_chat(self, message: str, sender: UUID, sender_name: str):
|
def broadcast_chat(self, message: str, sender: UUID, sender_name: str):
|
||||||
for player in self.players:
|
for player in self.players:
|
||||||
|
|
Loading…
Reference in New Issue