diff --git a/Minecraft.World/Chicken.cpp b/Minecraft.World/Chicken.cpp index 355d8a25..e0cf9da9 100644 --- a/Minecraft.World/Chicken.cpp +++ b/Minecraft.World/Chicken.cpp @@ -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 Chicken::getBreedOffspring(shared_ptr target) { // 4J - added limit to chickens that can be bred diff --git a/Minecraft.World/Chicken.h b/Minecraft.World/Chicken.h index 0f406219..fbbcf6c7 100644 --- a/Minecraft.World/Chicken.h +++ b/Minecraft.World/Chicken.h @@ -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 getBreedOffspring(shared_ptr target); diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp index f982d847..96da314f 100644 --- a/Minecraft.World/Zombie.cpp +++ b/Minecraft.World/Zombie.cpp @@ -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> *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 = dynamic_pointer_cast(*it); + if (chicken != nullptr && !chicken->isChickenJockey) + { + chicken->isChickenJockey = true; + ride(chicken); + checkExisting = true; + break; + } + } + } + + if (!checkExisting && level->random->nextFloat() < 0.05f) + { + shared_ptr chicken = std::make_shared(level); + chicken->moveTo(x, y, z, yRot, 0); + chicken->finalizeMobSpawn(nullptr); + chicken->isChickenJockey = true; + level->addEntity(chicken); + ride(chicken); + } } }