From 3548603578c005c2cfa92935ef98e1f86ec6a91b Mon Sep 17 00:00:00 2001 From: alemidev Date: Thu, 5 May 2022 00:26:45 +0200 Subject: [PATCH] track player abilities --- src/treepuncher/game/state.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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 +