renamed "Position" to "BlockPos"

This commit is contained in:
əlemi 2021-11-30 13:17:48 +01:00
parent 577b7f3de7
commit 317a8a79e5

View file

@ -8,7 +8,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
from aiocraft.client import MinecraftClient from aiocraft.client import MinecraftClient
from aiocraft.mc.packet import Packet from aiocraft.mc.packet import Packet
from aiocraft.mc.definitions import Difficulty, Dimension, Gamemode, Position from aiocraft.mc.definitions import Difficulty, Dimension, Gamemode, BlockPos
from aiocraft.mc.proto.play.clientbound import ( from aiocraft.mc.proto.play.clientbound import (
PacketRespawn, PacketLogin, PacketPosition, PacketUpdateHealth, PacketExperience, PacketRespawn, PacketLogin, PacketPosition, PacketUpdateHealth, PacketExperience,
@ -41,7 +41,7 @@ class Treepuncher(MinecraftClient):
slot : int slot : int
# TODO inventory # TODO inventory
position : Position position : BlockPos
# TODO world # TODO world
# TODO player abilities # TODO player abilities
@ -69,7 +69,7 @@ class Treepuncher(MinecraftClient):
self.slot = 0 self.slot = 0
self.position = Position(0, 0, 0) self.position = BlockPos(0, 0, 0)
self._register_handlers() self._register_handlers()
self.modules = [] self.modules = []
@ -170,7 +170,7 @@ class Treepuncher(MinecraftClient):
@self.on_packet(PacketPosition) @self.on_packet(PacketPosition)
async def player_rubberband_cb(packet:PacketPosition): async def player_rubberband_cb(packet:PacketPosition):
self._logger.info("Position synchronized") self._logger.info("Position synchronized")
self.position = Position(packet.x, packet.y, packet.z) self.position = BlockPos(packet.x, packet.y, packet.z)
await self.dispatcher.write( await self.dispatcher.write(
PacketTeleportConfirm( PacketTeleportConfirm(
self.dispatcher.proto, self.dispatcher.proto,
@ -187,10 +187,10 @@ class Treepuncher(MinecraftClient):
) )
self.run_callbacks(TreepuncherEvents.DIED) self.run_callbacks(TreepuncherEvents.DIED)
self.hp = packet.health self.hp = packet.health
self.food = packet.food self.food = packet.food + packet.foodSaturation
@self.on_packet(PacketExperience) @self.on_packet(PacketExperience)
async def player_hp_cb(packet:PacketExperience): async def player_xp_cb(packet:PacketExperience):
if packet.level != self.lvl: if packet.level != self.lvl:
self._logger.info("Level up : %d", packet.level) self._logger.info("Level up : %d", packet.level)
self.xp = packet.experienceBar self.xp = packet.experienceBar