diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/Chicken.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/Chicken.cpp')
| -rw-r--r-- | Minecraft.World/Chicken.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/Minecraft.World/Chicken.cpp b/Minecraft.World/Chicken.cpp index 0104b2bf..5f4cf2a7 100644 --- a/Minecraft.World/Chicken.cpp +++ b/Minecraft.World/Chicken.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "com.mojang.nbt.h" +#include "net.minecraft.world.entity.ai.attributes.h" #include "net.minecraft.world.entity.ai.goal.h" +#include "net.minecraft.world.entity.monster.h" #include "net.minecraft.world.level.tile.h" #include "net.minecraft.world.phys.h" #include "net.minecraft.world.level.h" @@ -24,22 +26,19 @@ Chicken::Chicken(Level *level) : Animal( level ) { // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that the derived version of the function is called this->defineSynchedData(); - - // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that the derived version of the function is called - health = getMaxHealth(); + registerAttributes(); + setHealth(getMaxHealth()); _init(); - this->textureIdx = TN_MOB_CHICKEN; // 4J - was L"/mob/chicken.png"; - this->setSize(0.3f, 0.7f); // 4J Changed from 0.4 to 0.7 in 1.8.2 + setSize(0.3f, 0.7f); // 4J Changed from 0.4 to 0.7 in 1.8.2 eggTime = random->nextInt(20 * 60 * 5) + 20 * 60 * 5; - float walkSpeed = 0.25f; goalSelector.addGoal(0, new FloatGoal(this)); - goalSelector.addGoal(1, new PanicGoal(this, 0.38f)); - goalSelector.addGoal(2, new BreedGoal(this, walkSpeed)); - goalSelector.addGoal(3, new TemptGoal(this, 0.25f, Item::seeds_wheat_Id, false)); - goalSelector.addGoal(4, new FollowParentGoal(this, 0.28f)); - goalSelector.addGoal(5, new RandomStrollGoal(this, walkSpeed)); + goalSelector.addGoal(1, new PanicGoal(this, 1.4)); + goalSelector.addGoal(2, new BreedGoal(this, 1.0)); + goalSelector.addGoal(3, new TemptGoal(this, 1.0, Item::seeds_wheat_Id, false)); + goalSelector.addGoal(4, new FollowParentGoal(this, 1.1)); + goalSelector.addGoal(5, new RandomStrollGoal(this, 1.0)); goalSelector.addGoal(6, new LookAtPlayerGoal(this, typeid(Player), 6)); goalSelector.addGoal(7, new RandomLookAroundGoal(this)); } @@ -49,9 +48,12 @@ bool Chicken::useNewAi() return true; } -int Chicken::getMaxHealth() +void Chicken::registerAttributes() { - return 4; + Animal::registerAttributes(); + + getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(4); + getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(0.25f); } void Chicken::aiStep() @@ -79,7 +81,7 @@ void Chicken::aiStep() { if (!level->isClientSide && --eggTime <= 0) { - level->playSound(shared_from_this(), eSoundType_MOB_CHICKENPLOP, 1.0f, (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f); + playSound( eSoundType_MOB_CHICKENPLOP, 1.0f, (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f); spawnAtLocation(Item::egg->id, 1); eggTime = random->nextInt(20 * 60 * 5) + 20 * 60 * 5; } @@ -107,6 +109,11 @@ int Chicken::getDeathSound() return eSoundType_MOB_CHICKEN_HURT; } +void Chicken::playStepSound(int xt, int yt, int zt, int t) +{ + playSound(eSoundType_MOB_CHICKEN_STEP, 0.15f, 1); +} + int Chicken::getDeathLoot() { return Item::feather->id; @@ -146,5 +153,5 @@ shared_ptr<AgableMob> Chicken::getBreedOffspring(shared_ptr<AgableMob> target) bool Chicken::isFood(shared_ptr<ItemInstance> itemInstance) { - return (itemInstance->id == Item::seeds_wheat_Id) || (itemInstance->id == Item::netherStalkSeeds_Id) || (itemInstance->id == Item::seeds_melon_Id) || (itemInstance->id == Item::seeds_pumpkin_Id); + return (itemInstance->id == Item::seeds_wheat_Id) || (itemInstance->id == Item::netherwart_seeds_Id) || (itemInstance->id == Item::seeds_melon_Id) || (itemInstance->id == Item::seeds_pumpkin_Id); } |
