the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2using namespace std;
3
4#include "LivingEntity.h"
5#include "MobType.h"
6#include "GoalSelector.h"
7
8class HitResult;
9class Level;
10class CompoundTag;
11class MobEffectInstance;
12class DamageSource;
13class MobEffect;
14class LookControl;
15class MoveControl;
16class JumpControl;
17class BodyControl;
18class PathNavigation;
19class Sensing;
20class Icon;
21class Pos;
22class MobGroupData;
23
24class Mob : public LivingEntity
25{
26 friend class MobSpawner;
27public:
28 // 4J-PB - added to replace (e instanceof Type), avoiding dynamic casts
29 eINSTANCEOF GetType() { return eTYPE_MOB;}
30 static Entity *create(Level *level) { return NULL; }
31
32public:
33 static const float MAX_WEARING_ARMOR_CHANCE;
34 static const float MAX_PICKUP_LOOT_CHANCE;
35 static const float MAX_ENCHANTED_ARMOR_CHANCE;
36 static const float MAX_ENCHANTED_WEAPON_CHANCE;
37
38private:
39 static const int DATA_CUSTOM_NAME = 10;
40 static const int DATA_CUSTOM_NAME_VISIBLE = 11;
41
42public:
43 int ambientSoundTime;
44
45protected:
46 int xpReward;
47
48private:
49 LookControl *lookControl;
50 MoveControl *moveControl;
51 JumpControl *jumpControl;
52 BodyControl *bodyControl;
53 PathNavigation *navigation;
54
55protected:
56 GoalSelector goalSelector;
57 GoalSelector targetSelector;
58
59private:
60 shared_ptr<LivingEntity> target;
61 Sensing *sensing;
62
63 ItemInstanceArray equipment;
64
65protected:
66 floatArray dropChances;
67
68private:
69 bool _canPickUpLoot;
70 bool persistenceRequired;
71
72protected:
73 // 4J - added for common ctor code
74 void _init();
75
76public:
77 Mob(Level* level);
78 virtual ~Mob();
79
80protected:
81 void registerAttributes();
82
83public:
84 virtual LookControl *getLookControl();
85 virtual MoveControl *getMoveControl();
86 virtual JumpControl *getJumpControl();
87 virtual PathNavigation *getNavigation();
88 virtual Sensing *getSensing();
89 shared_ptr<LivingEntity> getTarget();
90 virtual void setTarget(shared_ptr<LivingEntity> target);
91 virtual bool canAttackType(eINSTANCEOF targetType);
92 virtual void ate();
93
94protected:
95 virtual void defineSynchedData();
96
97public:
98 virtual int getAmbientSoundInterval();
99 void playAmbientSound();
100 virtual void baseTick();
101
102protected:
103 virtual int getExperienceReward(shared_ptr<Player> killedBy);
104
105public:
106 virtual void spawnAnim();
107 virtual void tick();
108
109protected:
110 virtual float tickHeadTurn(float yBodyRotT, float walkSpeed);
111 virtual int getAmbientSound();
112 virtual int getDeathLoot();
113 virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
114
115public:
116 virtual void addAdditonalSaveData(CompoundTag *entityTag);
117 virtual void readAdditionalSaveData(CompoundTag *tag);
118
119protected:
120 float defaultLookAngle;
121
122public:
123 virtual void setYya(float yya);
124 virtual void setSpeed(float speed);
125 virtual void aiStep();
126
127protected:
128 virtual bool useNewAi();
129 virtual bool removeWhenFarAway();
130
131private:
132 shared_ptr<Entity> lookingAt;
133
134protected:
135 int lookTime;
136
137 virtual void checkDespawn();
138 virtual void newServerAiStep();
139 virtual void serverAiStep();
140
141public:
142 virtual int getMaxHeadXRot();
143
144protected:
145 void lookAt(shared_ptr<Entity> e, float yMax, float xMax);
146 bool isLookingAtAnEntity();
147 shared_ptr<Entity> getLookingAt();
148
149private:
150 float rotlerp(float a, float b, float max);
151
152public:
153 virtual bool canSpawn();
154 virtual float getSizeScale();
155 virtual float getHeadSizeScale();
156 virtual int getMaxSpawnClusterSize();
157 virtual int getMaxFallDistance();
158 virtual shared_ptr<ItemInstance> getCarriedItem();
159 virtual shared_ptr<ItemInstance> getCarried(int slot);
160 virtual shared_ptr<ItemInstance> getArmor(int pos);
161 virtual void setEquippedSlot(int slot, shared_ptr<ItemInstance> item);
162 virtual ItemInstanceArray getEquipmentSlots();
163
164protected:
165 virtual void dropEquipment(bool byPlayer, int playerBonusLevel);
166 virtual void populateDefaultEquipmentSlots();
167
168public:
169 static int getEquipmentSlotForItem(shared_ptr<ItemInstance> item);
170 static Item *getEquipmentForSlot(int slot, int type);
171
172protected:
173 virtual void populateDefaultEquipmentEnchantments();
174
175public:
176 /**
177 * Added this method so mobs can handle their own spawn settings instead of
178 * hacking MobSpawner.java
179 *
180 * @param groupData
181 * TODO
182 * @return TODO
183 */
184 virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param
185 virtual void finalizeSpawnEggSpawn(int extraData); // 4J Added
186 virtual bool canBeControlledByRider();
187 virtual wstring getAName();
188 virtual void setPersistenceRequired();
189 virtual void setCustomName(const wstring &name);
190 virtual wstring getCustomName();
191 virtual bool hasCustomName();
192 virtual void setCustomNameVisible(bool visible);
193 virtual bool isCustomNameVisible();
194 virtual bool shouldShowName();
195 virtual void setDropChance(int slot, float pct);
196 virtual bool canPickUpLoot();
197 virtual void setCanPickUpLoot(bool canPickUpLoot);
198 virtual bool isPersistenceRequired();
199 virtual bool interact(shared_ptr<Player> player);
200
201protected:
202 virtual bool mobInteract(shared_ptr<Player> player);
203
204 // roper / leash methods
205
206private:
207 bool _isLeashed;
208 shared_ptr<Entity> leashHolder;
209 CompoundTag *leashInfoTag;
210
211protected:
212 virtual void tickLeash();
213
214public:
215 virtual void dropLeash(bool synch, bool createItemDrop);
216 virtual bool canBeLeashed();
217 virtual bool isLeashed();
218 virtual shared_ptr<Entity> getLeashHolder();
219 virtual void setLeashedTo(shared_ptr<Entity> holder, bool synch);
220
221private:
222 virtual void restoreLeashFromSave();
223 virtual bool shouldRender(Vec3 *c);
224
225
226public:
227
228 // 4J Added override to update ai elements when loading entity from schematics
229 virtual void setLevel(Level *level);
230};