diff --git a/src/treepuncher/game/state.py b/src/treepuncher/game/state.py index c10cd07..62bf83e 100644 --- a/src/treepuncher/game/state.py +++ b/src/treepuncher/game/state.py @@ -1,10 +1,11 @@ import asyncio import datetime -import functools #from aiocraft.client import MinecraftClient 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 ..scaffold import Scaffold @@ -27,6 +28,11 @@ class GameState(Scaffold): difficulty : Difficulty join_time : datetime.datetime + # Abilities + flags : int + flyingSpeed : float + walkingSpeed : float + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -114,3 +120,9 @@ class GameState(Scaffold): self.lvl = packet.level 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 +