aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/OwnerHurtTargetGoal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/OwnerHurtTargetGoal.cpp')
-rw-r--r--Minecraft.World/OwnerHurtTargetGoal.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Minecraft.World/OwnerHurtTargetGoal.cpp b/Minecraft.World/OwnerHurtTargetGoal.cpp
new file mode 100644
index 00000000..c6c367d7
--- /dev/null
+++ b/Minecraft.World/OwnerHurtTargetGoal.cpp
@@ -0,0 +1,25 @@
+#include "stdafx.h"
+#include "net.minecraft.world.entity.h"
+#include "net.minecraft.world.entity.animal.h"
+#include "OwnerHurtTargetGoal.h"
+
+OwnerHurtTargetGoal::OwnerHurtTargetGoal(TamableAnimal *tameAnimal) : TargetGoal(tameAnimal, 32, false)
+{
+ this->tameAnimal = tameAnimal;
+ setRequiredControlFlags(TargetGoal::TargetFlag);
+}
+
+bool OwnerHurtTargetGoal::canUse()
+{
+ if (!tameAnimal->isTame()) return false;
+ shared_ptr<Mob> owner = tameAnimal->getOwner();
+ if (owner == NULL) return false;
+ ownerLastHurt = weak_ptr<Mob>(owner->getLastHurtMob());
+ return canAttack(ownerLastHurt.lock(), false);
+}
+
+void OwnerHurtTargetGoal::start()
+{
+ mob->setTarget(ownerLastHurt.lock());
+ TargetGoal::start();
+} \ No newline at end of file