From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: 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 --- Minecraft.World/Pig.cpp | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'Minecraft.World/Pig.cpp') diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp index b556a936..cc042f58 100644 --- a/Minecraft.World/Pig.cpp +++ b/Minecraft.World/Pig.cpp @@ -6,6 +6,7 @@ #include "net.minecraft.world.level.h" #include "net.minecraft.world.item.h" #include "net.minecraft.world.entity.h" +#include "net.minecraft.world.entity.ai.attributes.h" #include "net.minecraft.world.entity.ai.goal.h" #include "net.minecraft.world.entity.ai.navigation.h" #include "net.minecraft.world.entity.item.h" @@ -23,23 +24,20 @@ Pig::Pig(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(); + registerAttributes(); + setHealth(getMaxHealth()); - // 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(); - - this->textureIdx = TN_MOB_PIG; // 4J - was L"/mob/pig.png"; - this->setSize(0.9f, 0.9f); + setSize(0.9f, 0.9f); getNavigation()->setAvoidWater(true); - float walkSpeed = 0.25f; goalSelector.addGoal(0, new FloatGoal(this)); - goalSelector.addGoal(1, new PanicGoal(this, 0.38f)); - goalSelector.addGoal(2, controlGoal = new ControlledByPlayerGoal(this, 0.34f, walkSpeed)); - goalSelector.addGoal(3, new BreedGoal(this, walkSpeed)); - goalSelector.addGoal(4, new TemptGoal(this, 0.3f, Item::carrotOnAStick_Id, false)); - goalSelector.addGoal(4, new TemptGoal(this, 0.25f, Item::carrots_Id, false)); - goalSelector.addGoal(5, new FollowParentGoal(this, 0.28f)); - goalSelector.addGoal(6, new RandomStrollGoal(this, walkSpeed)); + goalSelector.addGoal(1, new PanicGoal(this, 1.25)); + goalSelector.addGoal(2, controlGoal = new ControlledByPlayerGoal(this, 0.3f, 0.25f)); + goalSelector.addGoal(3, new BreedGoal(this, 1.0)); + goalSelector.addGoal(4, new TemptGoal(this, 1.2, Item::carrotOnAStick_Id, false)); + goalSelector.addGoal(4, new TemptGoal(this, 1.2, Item::carrots_Id, false)); + goalSelector.addGoal(5, new FollowParentGoal(this, 1.1)); + goalSelector.addGoal(6, new RandomStrollGoal(this, 1.0)); goalSelector.addGoal(7, new LookAtPlayerGoal(this, typeid(Player), 6)); goalSelector.addGoal(8, new RandomLookAroundGoal(this)); } @@ -49,9 +47,17 @@ bool Pig::useNewAi() return true; } -int Pig::getMaxHealth() +void Pig::registerAttributes() +{ + Animal::registerAttributes(); + + getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(10); + getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(0.25f); +} + +void Pig::newServerAiStep() { - return 10; + Animal::newServerAiStep(); } bool Pig::canBeControlledByRider() @@ -94,9 +100,14 @@ int Pig::getDeathSound() return eSoundType_MOB_PIG_DEATH; } -bool Pig::interact(shared_ptr player) +void Pig::playStepSound(int xt, int yt, int zt, int t) +{ + playSound(eSoundType_MOB_PIG_STEP, 0.15f, 1); +} + +bool Pig::mobInteract(shared_ptr player) { - if(!Animal::interact(player)) + if(!Animal::mobInteract(player)) { if (hasSaddle() && !level->isClientSide && (rider.lock() == NULL || rider.lock() == player)) { @@ -162,7 +173,7 @@ void Pig::thunderHit(const LightningBolt *lightningBolt) void Pig::causeFallDamage(float distance) { Animal::causeFallDamage(distance); - if (distance > 5 && dynamic_pointer_cast( rider.lock() ) != NULL) + if ( (distance > 5) && rider.lock() != NULL && rider.lock()->instanceof(eTYPE_PLAYER) ) { (dynamic_pointer_cast(rider.lock()))->awardStat(GenericStats::flyPig(),GenericStats::param_flyPig()); } -- cgit v1.2.3