mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-08 23:22:56 +00:00
Baby Zombies
This commit is contained in:
parent
2158cce6f1
commit
7bd468f03c
|
|
@ -20,6 +20,7 @@ void Chicken::_init()
|
|||
flapping = 1;
|
||||
oFlapSpeed = oFlap = 0.0f;
|
||||
eggTime = 0;
|
||||
isChickenJockey = false;
|
||||
}
|
||||
|
||||
Chicken::Chicken(Level *level) : Animal( level )
|
||||
|
|
@ -77,7 +78,7 @@ void Chicken::aiStep()
|
|||
|
||||
flap += flapping * 2;
|
||||
|
||||
if (!isBaby())
|
||||
if (!isBaby() && !isChickenJockey)
|
||||
{
|
||||
if (!level->isClientSide && --eggTime <= 0)
|
||||
{
|
||||
|
|
@ -138,6 +139,20 @@ void Chicken::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
|
|||
}
|
||||
}
|
||||
|
||||
void Chicken::addAdditonalSaveData(CompoundTag *tag)
|
||||
{
|
||||
Animal::addAdditonalSaveData(tag);
|
||||
|
||||
if (isChickenJockey) tag->putBoolean(L"IsChickenJockey", true);
|
||||
}
|
||||
|
||||
void Chicken::readAdditionalSaveData(CompoundTag *tag)
|
||||
{
|
||||
Animal::readAdditionalSaveData(tag);
|
||||
|
||||
if (tag->getBoolean(L"IsChickenJockey")) isChickenJockey = true;
|
||||
}
|
||||
|
||||
shared_ptr<AgableMob> Chicken::getBreedOffspring(shared_ptr<AgableMob> target)
|
||||
{
|
||||
// 4J - added limit to chickens that can be bred
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public:
|
|||
float oFlapSpeed, oFlap;
|
||||
float flapping;
|
||||
int eggTime;
|
||||
bool isChickenJockey;
|
||||
|
||||
private:
|
||||
void _init();
|
||||
|
|
@ -39,6 +40,9 @@ protected:
|
|||
virtual void playStepSound(int xt, int yt, int zt, int t);
|
||||
virtual int getDeathLoot();
|
||||
virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
|
||||
|
||||
virtual void addAdditonalSaveData(CompoundTag *tag);
|
||||
virtual void readAdditionalSaveData(CompoundTag *tag);
|
||||
|
||||
public:
|
||||
virtual shared_ptr<AgableMob> getBreedOffspring(shared_ptr<AgableMob> target);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
#include "net.minecraft.world.entity.monster.h"
|
||||
#include "net.minecraft.world.entity.npc.h"
|
||||
#include "net.minecraft.world.entity.player.h"
|
||||
#include "AABB.h"
|
||||
#include "Zombie.h"
|
||||
#include "Chicken.h"
|
||||
#include "GenericStats.h"
|
||||
#include "..\Minecraft.Client\Textures.h"
|
||||
#include "net.minecraft.world.entity.h"
|
||||
|
|
@ -364,6 +366,33 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
|
|||
if (zombieData->isBaby)
|
||||
{
|
||||
setBaby(true);
|
||||
|
||||
bool checkExisting = false;
|
||||
if (level->random->nextFloat() < 0.05f)
|
||||
{
|
||||
vector<shared_ptr<Entity>> *entities = level->getEntitiesOfClass(typeid(Chicken), bb->grow(5.0f, 3.0f, 5.0f));
|
||||
for (auto it = entities->begin(); it != entities->end(); ++it)
|
||||
{
|
||||
shared_ptr<Chicken> chicken = dynamic_pointer_cast<Chicken>(*it);
|
||||
if (chicken != nullptr && !chicken->isChickenJockey)
|
||||
{
|
||||
chicken->isChickenJockey = true;
|
||||
ride(chicken);
|
||||
checkExisting = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkExisting && level->random->nextFloat() < 0.05f)
|
||||
{
|
||||
shared_ptr<Chicken> chicken = std::make_shared<Chicken>(level);
|
||||
chicken->moveTo(x, y, z, yRot, 0);
|
||||
chicken->finalizeMobSpawn(nullptr);
|
||||
chicken->isChickenJockey = true;
|
||||
level->addEntity(chicken);
|
||||
ride(chicken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue