track player abilities

This commit is contained in:
əlemi 2022-05-05 00:26:45 +02:00
parent b8477c3d22
commit 3548603578
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -1,10 +1,11 @@
import asyncio import asyncio
import datetime import datetime
import functools
#from aiocraft.client import MinecraftClient #from aiocraft.client import MinecraftClient
from aiocraft.mc.definitions import Gamemode, Dimension, Difficulty from aiocraft.mc.definitions import Gamemode, Dimension, Difficulty
from aiocraft.mc.proto import PacketRespawn, PacketLogin, PacketUpdateHealth, PacketExperience, PacketSettings, PacketClientCommand from aiocraft.mc.proto import (
PacketRespawn, PacketLogin, PacketUpdateHealth, PacketExperience, PacketSettings, PacketClientCommand, PacketAbilities
)
from ..events import JoinGameEvent, DeathEvent, ConnectedEvent, DisconnectedEvent from ..events import JoinGameEvent, DeathEvent, ConnectedEvent, DisconnectedEvent
from ..scaffold import Scaffold from ..scaffold import Scaffold
@ -27,6 +28,11 @@ class GameState(Scaffold):
difficulty : Difficulty difficulty : Difficulty
join_time : datetime.datetime join_time : datetime.datetime
# Abilities
flags : int
flyingSpeed : float
walkingSpeed : float
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -114,3 +120,9 @@ class GameState(Scaffold):
self.lvl = packet.level self.lvl = packet.level
self.total_xp = packet.totalExperience self.total_xp = packet.totalExperience
@self.on_packet(PacketAbilities)
async def player_abilities_cb(packet:PacketAbilities):
self.flags = packet.flags
self.flyingSpeed = packet.flyingSpeed
self.walkingSpeed = packet.walkingSpeed