From 7bf73ad13ed79ac3897577c201f4652ebe5f31a2 Mon Sep 17 00:00:00 2001 From: DrPerkyLegit Date: Sat, 23 May 2026 10:56:38 -0400 Subject: [PATCH] feat(TU31): Villagers turn into witches when struck by lightning --- Minecraft.World/Villager.cpp | 18 +++++++++++++++++- Minecraft.World/Villager.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index 4e57aff..ff21005 100644 --- a/Minecraft.World/Villager.cpp +++ b/Minecraft.World/Villager.cpp @@ -156,7 +156,7 @@ bool Villager::mobInteract(shared_ptr player) shared_ptr item = player->inventory->getSelected(); bool holdingSpawnEgg = item != nullptr && item->id == Item::spawnEgg_Id; - if (!holdingSpawnEgg && isAlive() && !isTrading() && !isBaby()) + if (!player->isSneaking() && !holdingSpawnEgg && isAlive() && !isTrading() && !isBaby()) { if (!level->isClientSide) { @@ -775,3 +775,19 @@ wstring Villager::getDisplayName() }; return app.GetString(name); } + +void Villager::thunderHit(const LightningBolt* lightningBolt) +{ + if (level->isClientSide) return; + shared_ptr witch = std::make_shared(level); + witch->moveTo(x, y, z, yRot, xRot); + + if (this->hasCustomName()) + witch->setCustomName(this->getCustomName()); + + if (this->isPersistenceRequired()) + witch->setPersistenceRequired(); + + level->addEntity(witch); + remove(); +} diff --git a/Minecraft.World/Villager.h b/Minecraft.World/Villager.h index d8aeb15..62d9421 100644 --- a/Minecraft.World/Villager.h +++ b/Minecraft.World/Villager.h @@ -147,4 +147,5 @@ public: virtual shared_ptr getBreedOffspring(shared_ptr target); virtual bool canBeLeashed(); virtual wstring getDisplayName(); + virtual void thunderHit(const LightningBolt* lightningBolt); }; \ No newline at end of file