diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 388f0afa..f0f440bb 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -116,7 +116,6 @@ Biome::Biome(int id) : id(id) friendlies_chicken.push_back(new MobSpawnerData(eTYPE_CHICKEN, 10, 4, 4)); // 4J - moved chickens to their own category friendlies.push_back(new MobSpawnerData(eTYPE_COW, 8, 4, 4)); - friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 7, 1, 2)); enemies.push_back(new MobSpawnerData(eTYPE_SPIDER, 10, 4, 4)); enemies.push_back(new MobSpawnerData(eTYPE_ZOMBIE, 10, 4, 4)); diff --git a/Minecraft.World/DesertBiome.cpp b/Minecraft.World/DesertBiome.cpp index e67faef5..ee2e4b69 100644 --- a/Minecraft.World/DesertBiome.cpp +++ b/Minecraft.World/DesertBiome.cpp @@ -10,6 +10,7 @@ DesertBiome::DesertBiome(int id) : Biome(id) friendlies.clear(); friendlies_chicken.clear(); // 4J added friendlies_wolf.clear(); // 4J added + friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 12, 2, 3)); topMaterial = static_cast(Tile::sand_Id); material = static_cast(Tile::sand_Id); diff --git a/Minecraft.World/ForestBiome.cpp b/Minecraft.World/ForestBiome.cpp index b22b8b39..70c8a04f 100644 --- a/Minecraft.World/ForestBiome.cpp +++ b/Minecraft.World/ForestBiome.cpp @@ -8,6 +8,7 @@ ForestBiome::ForestBiome(int id) : Biome(id) { friendlies_wolf.push_back(new MobSpawnerData(eTYPE_WOLF, 5, 4, 4)); // 4J - moved to their own category + friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 4, 2, 3)); decorator->treeCount = 10; decorator->grassCount = 2; } diff --git a/Minecraft.World/PlainsBiome.cpp b/Minecraft.World/PlainsBiome.cpp index df6f4785..22c1e6b3 100644 --- a/Minecraft.World/PlainsBiome.cpp +++ b/Minecraft.World/PlainsBiome.cpp @@ -4,6 +4,7 @@ PlainsBiome::PlainsBiome(int id) : Biome(id) { friendlies.push_back(new MobSpawnerData(eTYPE_HORSE, 5, 2, 6)); + friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 4, 2, 3)); decorator->treeCount = -999; decorator->flowerCount = 4; diff --git a/Minecraft.World/Rabbit.cpp b/Minecraft.World/Rabbit.cpp index 881c9d8f..ca92a97b 100644 --- a/Minecraft.World/Rabbit.cpp +++ b/Minecraft.World/Rabbit.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Rabbit.h" #include "SynchedEntityData.h" #include "AttributeInstance.h" @@ -7,8 +7,15 @@ #include "net.minecraft.world.entity.ai.goal.h" #include "net.minecraft.world.entity.ai.navigation.h" #include "net.minecraft.world.level.h" +#include "net.minecraft.world.level.biome.h" #include "com.mojang.nbt.h" #include "SoundTypes.h" +#include "MobGroupData.h" + +class RabbitGroupData : public MobGroupData { +public: + int groupSize = 0; +}; Rabbit::Rabbit(Level *level) : Animal(level) { @@ -26,9 +33,10 @@ Rabbit::Rabbit(Level *level) : Animal(level) // AI Goals goalSelector.addGoal(1, new FloatGoal(this)); - goalSelector.addGoal(2, new PanicGoal(this, 2.2f)); + goalSelector.addGoal(2, new PanicGoal(this, 1.2f)); goalSelector.addGoal(3, new BreedGoal(this, 0.8f)); goalSelector.addGoal(4, new TemptGoal(this, 1.0f, Item::carrots_Id, false)); + goalSelector.addGoal(5, new FollowParentGoal(this, 1.1f)); goalSelector.addGoal(6, new RandomStrollGoal(this, 0.6f)); goalSelector.addGoal(7, new LookAtPlayerGoal(this, typeid(Player), 10.0f)); } @@ -102,8 +110,17 @@ bool Rabbit::isFood(shared_ptr item) { } shared_ptr Rabbit::getBreedOffspring(shared_ptr target) { - if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) - return std::make_shared(level); + if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) { + shared_ptr offspring = std::make_shared(level); + shared_ptr partner = dynamic_pointer_cast(target); + + if (partner != nullptr) { + + offspring->setVariant(random->nextBoolean() ? this->getVariant() : partner->getVariant()); + } + + return offspring; + } return nullptr; } @@ -122,4 +139,47 @@ void Rabbit::readAdditionalSaveData(CompoundTag *tag) { void Rabbit::addAdditonalSaveData(CompoundTag *tag) { Animal::addAdditonalSaveData(tag); tag->putInt(L"RabbitType", (int)getVariant()); +} + +MobGroupData *Rabbit::finalizeMobSpawn(MobGroupData *groupData, int extraData) { + RabbitGroupData *rabbitData = dynamic_cast(groupData); + if (rabbitData == nullptr) { + rabbitData = new RabbitGroupData(); + } else { + + this->setAge(-24000); + } + rabbitData->groupSize++; + + Biome *biome = level->getBiome(Mth::floor(x), Mth::floor(z)); + int rnd = random->nextInt(100); + + if (biome == Biome::desert || biome == Biome::desertHills) { + setVariant(Variant::GOLD); + } else if (biome == Biome::plains || biome == Biome::forest || biome == Biome::forestHills) { + if (rnd < 33) { + setVariant(Variant::BLACK); + } else if (rnd < 66) { + setVariant(Variant::BROWN); + } else { + setVariant(Variant::SALT); + } + } else if (biome == Biome::taiga || biome == Biome::taigaHills) { + if (rnd < 50) { + setVariant(Variant::WHITE); + } else { + setVariant(Variant::WHITE_SPLOTCHED); + } + } else { + // Default + if (rnd < 50) { + setVariant(Variant::BROWN); + } else if (rnd < 90) { + setVariant(Variant::SALT); + } else { + setVariant(Variant::BLACK); + } + } + + return rabbitData; } \ No newline at end of file diff --git a/Minecraft.World/Rabbit.h b/Minecraft.World/Rabbit.h index d60ca5f7..a094d13b 100644 --- a/Minecraft.World/Rabbit.h +++ b/Minecraft.World/Rabbit.h @@ -53,4 +53,6 @@ public: virtual void readAdditionalSaveData(CompoundTag *tag) override; virtual void addAdditonalSaveData(CompoundTag *tag) override; + + virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0) override; }; \ No newline at end of file diff --git a/Minecraft.World/TaigaBiome.cpp b/Minecraft.World/TaigaBiome.cpp index 7a9cc105..dea881e0 100644 --- a/Minecraft.World/TaigaBiome.cpp +++ b/Minecraft.World/TaigaBiome.cpp @@ -7,6 +7,7 @@ TaigaBiome::TaigaBiome(int id) : Biome(id) { friendlies_wolf.push_back(new MobSpawnerData(eTYPE_WOLF, 8, 4, 4)); // 4J - moved to their own category + friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 4, 2, 3)); decorator->treeCount = 10; decorator->grassCount = 1;