From 42ee0b519ebf13abbebeb590ca8c9f681b080d55 Mon Sep 17 00:00:00 2001 From: NSDeathman <104826306+NSDeathman@users.noreply.github.com> Date: Mon, 18 May 2026 23:02:31 +0400 Subject: [PATCH] feat(TU31): Creepers can be ignited with flint and steel (#84) * TU31 feature: Creepers can be ignited with flint and steel * make mobInteract more accurate to decomp --------- Co-authored-by: piebot <274605694+pieeebot@users.noreply.github.com> --- Minecraft.World/Creeper.cpp | 36 +++++++++++++++++++++++++++++++++++ Minecraft.World/Creeper.h | 10 +++++++++- Minecraft.World/SwellGoal.cpp | 6 ++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Minecraft.World/Creeper.cpp b/Minecraft.World/Creeper.cpp index dde58894..e5250fdb 100644 --- a/Minecraft.World/Creeper.cpp +++ b/Minecraft.World/Creeper.cpp @@ -26,6 +26,7 @@ void Creeper::_init() oldSwell = 0; maxSwell = 30; explosionRadius = 3; + ignited = false; } Creeper::Creeper(Level *level) : Monster( level ) @@ -190,3 +191,38 @@ void Creeper::thunderHit(const LightningBolt *lightningBolt) Monster::thunderHit(lightningBolt); entityData->set(DATA_IS_POWERED, static_cast(1)); } + +void Creeper::Ignite() +{ + setSwellDir(1); + ignited = true; +} + +bool Creeper::isIgnited() +{ + return ignited; +} + +bool Creeper::mobInteract(shared_ptr player) +{ + shared_ptr item = player->inventory->getSelected(); + + if (item == nullptr || item->id != Item::flintAndSteel_Id) + return Mob::mobInteract(player); + + playSound(eSoundType_FIRE_NEWIGNITE, 1, random->nextFloat() * 0.4f + 0.8f); + player->swing(); + + if (!level->isClientSide) + { + if (!isIgnited()) + { + Ignite(); + item->hurtAndBreak(1, player); + return true; + } + return Mob::mobInteract(player); + } + + return true; +} diff --git a/Minecraft.World/Creeper.h b/Minecraft.World/Creeper.h index d5cd4cff..ed9ff59d 100644 --- a/Minecraft.World/Creeper.h +++ b/Minecraft.World/Creeper.h @@ -21,6 +21,8 @@ private: int maxSwell; int explosionRadius; + bool ignited; + void _init(); public: @@ -34,6 +36,8 @@ public: virtual int getMaxFallDistance(); + virtual bool mobInteract(shared_ptr player); + protected: virtual void causeFallDamage(float distance); virtual void defineSynchedData(); @@ -61,5 +65,9 @@ protected: public: int getSwellDir(); void setSwellDir(int dir); - void thunderHit(const LightningBolt *lightningBolt) ; + void thunderHit(const LightningBolt *lightningBolt); + +public: + void Ignite(); + bool isIgnited(); }; diff --git a/Minecraft.World/SwellGoal.cpp b/Minecraft.World/SwellGoal.cpp index 0fd3c34a..a77037a4 100644 --- a/Minecraft.World/SwellGoal.cpp +++ b/Minecraft.World/SwellGoal.cpp @@ -32,6 +32,12 @@ void SwellGoal::stop() void SwellGoal::tick() { + if(creeper->isIgnited()) + { + creeper->setSwellDir(1); + return; + } + if (target.lock() == nullptr) { creeper->setSwellDir(-1);