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>
This commit is contained in:
NSDeathman
2026-05-18 23:02:31 +04:00
committed by GitHub
parent d36a027e00
commit 42ee0b519e
3 changed files with 51 additions and 1 deletions

View File

@@ -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<byte>(1));
}
void Creeper::Ignite()
{
setSwellDir(1);
ignited = true;
}
bool Creeper::isIgnited()
{
return ignited;
}
bool Creeper::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> 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;
}

View File

@@ -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> 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();
};

View File

@@ -32,6 +32,12 @@ void SwellGoal::stop()
void SwellGoal::tick()
{
if(creeper->isIgnited())
{
creeper->setSwellDir(1);
return;
}
if (target.lock() == nullptr)
{
creeper->setSwellDir(-1);