diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index e20a9924..a181df84 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) { @@ -776,3 +776,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 d8aeb15a..f08a028b 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