Fix support for Minecraft 20w06a to 1.16.2 (protocols 701 to 751)

This commit is contained in:
joo committed 2020-08-17 11:25:30 +02:00
1 parent b79f8b30eb
commit 4c35517157
20 files changed
+654 -256

No files matched your search

+44 -5
View File
@@ -1,3 +1,5 @@
import pynbt
from minecraft import SUPPORTED_MINECRAFT_VERSIONS
from minecraft.networking import connection
from minecraft.networking import types
@@ -98,10 +100,46 @@ class FakeClientHandler(object):
def handle_play_start(self):
# Called upon entering the play state.
self.write_packet(clientbound.play.JoinGamePacket(
entity_id=0, game_mode=0, dimension=0, hashed_seed=12345,
difficulty=2, max_players=1, level_type='default',
reduced_debug_info=False, render_distance=9, respawn_screen=False))
packet = clientbound.play.JoinGamePacket(
entity_id=0, is_hardcore=False, game_mode=0, previous_game_mode=0,
world_names=['minecraft:overworld'],
world_name='minecraft:overworld',
hashed_seed=12345, difficulty=2, max_players=1,
level_type='default', reduced_debug_info=False, render_distance=9,
respawn_screen=False, is_debug=False, is_flat=False)
if self.server.context.protocol_version >= 748:
packet.dimension = pynbt.TAG_Compound({
'natural': pynbt.TAG_Byte(1),
'effects': pynbt.TAG_String('minecraft:overworld'),
}, '')
packet.dimension_codec = pynbt.TAG_Compound({
'minecraft:dimension_type': pynbt.TAG_Compound({
'type': pynbt.TAG_String('minecraft:dimension_type'),
'value': pynbt.TAG_List(pynbt.TAG_Compound, [
pynbt.TAG_Compound(packet.dimension),
]),
}),
'minecraft:worldgen/biome': pynbt.TAG_Compound({
'type': pynbt.TAG_String('minecraft:worldgen/biome'),
'value': pynbt.TAG_List(pynbt.TAG_Compound, [
pynbt.TAG_Compound({
'id': pynbt.TAG_Int(1),
'name': pynbt.TAG_String('minecraft:plains'),
}),
pynbt.TAG_Compound({
'id': pynbt.TAG_Int(2),
'name': pynbt.TAG_String('minecraft:desert'),
}),
]),
}),
}, '')
elif self.server.context.protocol_version >= 718:
packet.dimension = 'minecraft:overworld'
else:
packet.dimension = types.Dimension.OVERWORLD
self.write_packet(packet)
def handle_play_packet(self, packet):
# Called upon each packet received after handle_play_start() returns.
@@ -178,7 +216,8 @@ class FakeClientHandler(object):
try:
self.handle_connection()
packet = self.read_packet()
assert isinstance(packet, serverbound.handshake.HandShakePacket)
assert isinstance(packet, serverbound.handshake.HandShakePacket), \
type(packet)
self.handle_handshake(packet)
if packet.next_state == 1:
self._run_status()