From 5672a4ad36e5b3f21eb0e80ffb333874b9dcc309 Mon Sep 17 00:00:00 2001 From: alemidev Date: Sat, 15 Jan 2022 01:59:14 +0100 Subject: [PATCH] pass some values, check blocks above and below at intervals --- treepuncher/treepuncher.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/treepuncher/treepuncher.py b/treepuncher/treepuncher.py index e096a95..3566567 100644 --- a/treepuncher/treepuncher.py +++ b/treepuncher/treepuncher.py @@ -12,6 +12,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from aiocraft.client import MinecraftClient from aiocraft.mc.packet import Packet +from aiocraft.mc.types import Context from aiocraft.mc.definitions import Difficulty, Dimension, Gamemode, BlockPos from aiocraft.mc.proto.play.clientbound import ( @@ -88,7 +89,6 @@ class Treepuncher(MinecraftClient): self.tablist = {} - self._register_handlers() self.modules = [] tz = datetime.datetime.now(datetime.timezone.utc).astimezone().tzname() # APScheduler will complain if I don't specify a timezone... @@ -96,6 +96,8 @@ class Treepuncher(MinecraftClient): logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) # So it's way less spammy self.scheduler.start(paused=True) + self._register_handlers() + @property def name(self) -> str: if self.online_mode and self.token: @@ -287,8 +289,15 @@ class Treepuncher(MinecraftClient): @self.on_packet(PacketMapChunk) async def process_chunk_packet(packet:PacketMapChunk): - chunk = Chunk(packet.x, packet.z, packet.bitMap) - chunk.read(io.BytesIO(packet.chunkData)) + chunk = Chunk(packet.x, packet.z, packet.bitMap, ground_up_continuous=packet.groundUp) + # self._logger.info("Processing chunk buffer of length %d", len(packet.chunkData)) + chunk.read(io.BytesIO(packet.chunkData), Context(overworld=self.dimension == Dimension.OVERWORLD)) self.world.put(chunk, x=packet.x, z=packet.z) + @self.scheduler.scheduled_job('interval', seconds=15) + async def check_blocks_under_self(): + for i in range(-5, 5): + block = self.world.get(self.position.x, self.position.y-i, self.position.z) + self._logger.info("Block %d positions below self : %d", i, block) +