Handle player teleport packet
This commit is contained in:
parent
c49ce127b9
commit
b754a4746d
2
data.py
2
data.py
|
@ -3,7 +3,7 @@ from munch import Munch
|
|||
|
||||
import minecraft_data
|
||||
|
||||
mcd = minecraft_data('1.16.2')
|
||||
mcd = minecraft_data('1.16.4')
|
||||
|
||||
with open('mcdata/registries.json') as f:
|
||||
DATA = json.load(f)
|
||||
|
|
24
game.py
24
game.py
|
@ -20,7 +20,7 @@ from protocol.packets import (
|
|||
ClickWindowPacket, CloseWindowPacket, ServerWindowConfirmationPacket,
|
||||
ClientWindowConfirmationPacket, EntityMetadataPacket,
|
||||
SpawnLivingEntityPacket, EntityPositionRotationPacket, DestroyEntitiesPacket,
|
||||
EntityActionPacket, SpawnPlayerPacket,
|
||||
EntityActionPacket, EntityTeleport,
|
||||
)
|
||||
|
||||
from protocol.types import Slot
|
||||
|
@ -330,9 +330,10 @@ class Game:
|
|||
register(self.handle_entity_position, clientbound.play.EntityPositionDeltaPacket)
|
||||
register(self.handle_entity_position_rotation, EntityPositionRotationPacket)
|
||||
register(self.handle_destroy_entities, DestroyEntitiesPacket)
|
||||
register(self.handle_spawn_player, SpawnPlayerPacket)
|
||||
register(self.handle_spawn_player, clientbound.play.SpawnPlayerPacket)
|
||||
register(self.handle_respawn, clientbound.play.RespawnPacket)
|
||||
register(self.handle_player_list, clientbound.play.PlayerListItemPacket)
|
||||
register(self.handle_entity_teleport, EntityTeleport)
|
||||
#register(self.handle_entity_velocity, clientbound.play.EntityVelocityPacket)
|
||||
|
||||
#register(self.handle_packet, Packet, early=True)
|
||||
|
@ -917,7 +918,7 @@ class Game:
|
|||
print(packet)
|
||||
self.g.players[packet.entity_id] = Munch(
|
||||
entity_id=packet.entity_id,
|
||||
player_uuid=packet.player_uuid,
|
||||
player_uuid=packet.player_UUID,
|
||||
x=packet.x,
|
||||
y=packet.y,
|
||||
z=packet.z,
|
||||
|
@ -1009,6 +1010,21 @@ class Game:
|
|||
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_teleport(self, packet):
|
||||
mob = self.g.mobs.get(packet.entity_id, None)
|
||||
if mob:
|
||||
mob.x = packet.x
|
||||
mob.y = packet.y
|
||||
mob.z = packet.z
|
||||
|
||||
player = self.g.players.get(packet.entity_id, None)
|
||||
if player:
|
||||
player.x = packet.x
|
||||
player.y = packet.y
|
||||
player.z = packet.z
|
||||
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_velocity(self, packet):
|
||||
obj = self.g.objects.get(packet.entity_id, None)
|
||||
if obj:
|
||||
|
@ -1023,6 +1039,8 @@ class Game:
|
|||
del self.g.objects[eid]
|
||||
if eid in self.g.mobs:
|
||||
del self.g.mobs[eid]
|
||||
if eid in self.g.players:
|
||||
del self.g.players[eid]
|
||||
|
||||
def leave_bed(self):
|
||||
packet = EntityActionPacket()
|
||||
|
|
|
@ -11,20 +11,13 @@ def get_packets(old_get_packets):
|
|||
mc_packets.add(packets.AcknowledgePlayerDiggingPacket)
|
||||
mc_packets.add(packets.BlockBreakAnimationPacket)
|
||||
mc_packets.add(packets.SetSlotPacket)
|
||||
#mc_packets.add(packets.PlayerDiggingPacket)
|
||||
#mc_packets.add(packets.PickItemPacket)
|
||||
#mc_packets.add(packets.HeldItemChangePacket)
|
||||
mc_packets.add(packets.OpenWindowPacket)
|
||||
#mc_packets.add(packets.CloseWindowPacket)
|
||||
#mc_packets.add(packets.ClickWindowPacket)
|
||||
mc_packets.add(packets.ClientWindowConfirmationPacket)
|
||||
#mc_packets.add(packets.ServerWindowConfirmationPacket)
|
||||
mc_packets.add(packets.EntityMetadataPacket)
|
||||
mc_packets.add(packets.SpawnLivingEntityPacket)
|
||||
mc_packets.add(packets.EntityPositionRotationPacket)
|
||||
mc_packets.add(packets.DestroyEntitiesPacket)
|
||||
#mc_packets.add(packets.EntityActionPacket)
|
||||
mc_packets.add(packets.SpawnPlayerPacket)
|
||||
mc_packets.add(packets.EntityTeleport)
|
||||
|
||||
|
||||
return mc_packets
|
||||
|
|
|
@ -330,6 +330,23 @@ class SpawnLivingEntityPacket(Packet):
|
|||
{'velocity_z': Short},
|
||||
]
|
||||
|
||||
class EntityTeleport(Packet):
|
||||
# Sent by the server when an entity moves more than 8 blocks
|
||||
# https://wiki.vg/Protocol#Entity_Teleport
|
||||
|
||||
id = 0x56
|
||||
packet_name = 'entity teleport'
|
||||
|
||||
definition = [
|
||||
{'entity_id': VarInt},
|
||||
{'x': Double},
|
||||
{'y': Double},
|
||||
{'z': Double},
|
||||
{'yaw': Angle},
|
||||
{'pitch': Angle},
|
||||
{'on_ground': Boolean},
|
||||
]
|
||||
|
||||
class EntityPositionRotationPacket(Packet):
|
||||
# Sent by the server when an entity rotates and moves
|
||||
# https://wiki.vg/Protocol#Entity_Position_and_Rotation
|
||||
|
@ -374,19 +391,3 @@ class EntityActionPacket(Packet):
|
|||
{'action_id': VarInt},
|
||||
{'jump_boost': VarInt},
|
||||
]
|
||||
|
||||
class SpawnPlayerPacket(Packet):
|
||||
# https://wiki.vg/Protocol#Spawn_Player
|
||||
|
||||
id = 0x04
|
||||
packet_name = 'spawn player'
|
||||
|
||||
definition = [
|
||||
{'entity_id': VarInt},
|
||||
{'player_uuid': UUID},
|
||||
{'x': Double},
|
||||
{'y': Double},
|
||||
{'z': Double},
|
||||
{'yaw': Angle},
|
||||
{'pitch': Angle},
|
||||
]
|
||||
|
|
|
@ -1,23 +1,40 @@
|
|||
appdirs==1.4.3
|
||||
astar==0.92
|
||||
CacheControl==0.12.6
|
||||
certifi==2020.6.20
|
||||
cffi==1.14.2
|
||||
chardet==3.0.4
|
||||
click==7.1.2
|
||||
colorama==0.4.3
|
||||
contextlib2==0.6.0
|
||||
cryptography==3.1
|
||||
distlib==0.3.0
|
||||
distro==1.4.0
|
||||
Flask==1.1.2
|
||||
html5lib==1.0.1
|
||||
idna==2.10
|
||||
ipaddr==2.2.0
|
||||
itsdangerous==1.1.0
|
||||
Jinja2==2.11.2
|
||||
lockfile==0.12.2
|
||||
MarkupSafe==1.1.1
|
||||
minecraft-data==2.67.0
|
||||
minecraft-data==2.70.1
|
||||
msgpack==0.6.2
|
||||
munch==2.5.0
|
||||
packaging==20.3
|
||||
panda3d==1.10.6.post2
|
||||
pathtools==0.1.2
|
||||
pep517==0.8.2
|
||||
progress==1.5
|
||||
pycparser==2.20
|
||||
pyCraft @ git+https://github.com/ammaraskar/pyCraft.git@2813d02ae7fb8182c3e5227a73de2240b09878d9
|
||||
pyCraft==0.7.0
|
||||
PyNBT==3.0.0
|
||||
pyparsing==2.4.6
|
||||
pytoml==0.1.21
|
||||
requests==2.24.0
|
||||
retrying==1.3.3
|
||||
six==1.15.0
|
||||
urllib3==1.25.10
|
||||
watchdog==0.10.3
|
||||
webencodings==0.5.1
|
||||
Werkzeug==1.0.1
|
||||
|
|
Loading…
Reference in New Issue
Block a user