aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Mob.h
diff options
context:
space:
mode:
authordaoge <3523206925@qq.com>2026-03-03 03:04:10 +0800
committerGitHub <noreply@github.com>2026-03-03 03:04:10 +0800
commitb3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch)
tree267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/Mob.h
parent84c31a2331f7a0ec85b9d438992e244f60e5020f (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/Mob.h')
-rw-r--r--Minecraft.World/Mob.h323
1 files changed, 92 insertions, 231 deletions
diff --git a/Minecraft.World/Mob.h b/Minecraft.World/Mob.h
index 0e1af2be..11310509 100644
--- a/Minecraft.World/Mob.h
+++ b/Minecraft.World/Mob.h
@@ -1,7 +1,7 @@
#pragma once
using namespace std;
-#include "Entity.h"
+#include "LivingEntity.h"
#include "MobType.h"
#include "GoalSelector.h"
@@ -19,105 +19,33 @@ class PathNavigation;
class Sensing;
class Icon;
class Pos;
+class MobGroupData;
-class Mob : public Entity
+class Mob : public LivingEntity
{
friend class MobSpawner;
-protected:
- // 4J - added for common ctor code
- void _init();
public:
- Mob(Level* level);
- virtual ~Mob();
-
// 4J-PB - added to replace (e instanceof Type), avoiding dynamic casts
eINSTANCEOF GetType() { return eTYPE_MOB;}
static Entity *create(Level *level) { return NULL; }
public:
- static const int ATTACK_DURATION = 5;
- static const int PLAYER_HURT_EXPERIENCE_TIME = 20 * 3;
-
-public: // 4J Stu - Made public
- static const int DATA_EFFECT_COLOR_ID = 8;
+ static const float MAX_WEARING_ARMOR_CHANCE;
+ static const float MAX_PICKUP_LOOT_CHANCE;
+ static const float MAX_ENCHANTED_ARMOR_CHANCE;
+ static const float MAX_ENCHANTED_WEAPON_CHANCE;
private:
- static const double MIN_MOVEMENT_DISTANCE;
-
-public:
- int invulnerableDuration;
- float timeOffs;
- float rotA;
- float yBodyRot, yBodyRotO;
- float yHeadRot, yHeadRotO;
-
-protected:
- float oRun, run;
- float animStep, animStepO;
- bool hasHair;
- // wstring textureName;
- int textureIdx; // 4J changed from wstring textureName
- bool allowAlpha;
- float rotOffs;
- wstring modelName;
- float bobStrength;
- int deathScore;
- float renderOffset;
-
-public:
- float walkingSpeed;
- float flyingSpeed;
- float oAttackAnim, attackAnim;
-
-protected:
- int health;
-
-public:
- int lastHealth;
-
-protected:
- int dmgSpill;
+ static const int DATA_CUSTOM_NAME = 10;
+ static const int DATA_CUSTOM_NAME_VISIBLE = 11;
public:
int ambientSoundTime;
- int hurtTime;
- int hurtDuration;
- float hurtDir;
- int deathTime;
- int attackTime;
- float oTilt, tilt;
protected:
- bool dead;
int xpReward;
-public:
- int modelNum;
- float animSpeed;
- float walkAnimSpeedO;
- float walkAnimSpeed;
- float walkAnimPos;
-
-protected:
- shared_ptr<Player> lastHurtByPlayer;
- int lastHurtByPlayerTime;
-
private:
- shared_ptr<Mob> lastHurtByMob;
- int lastHurtByMobTime;
- shared_ptr<Mob> lastHurtMob;
-
-public:
- int arrowCount;
- int removeArrowTime;
-
-protected:
- map<int, MobEffectInstance *> activeEffects;
-
-private:
- bool effectsDirty;
- int effectColor;
-
LookControl *lookControl;
MoveControl *moveControl;
JumpControl *jumpControl;
@@ -129,12 +57,28 @@ protected:
GoalSelector targetSelector;
private:
- shared_ptr<Mob> target;
+ shared_ptr<LivingEntity> target;
Sensing *sensing;
- float speed;
- Pos *restrictCenter;
- float restrictRadius;
+ ItemInstanceArray equipment;
+
+protected:
+ floatArray dropChances;
+
+private:
+ bool _canPickUpLoot;
+ bool persistenceRequired;
+
+protected:
+ // 4J - added for common ctor code
+ void _init();
+
+public:
+ Mob(Level* level);
+ virtual ~Mob();
+
+protected:
+ void registerAttributes();
public:
virtual LookControl *getLookControl();
@@ -142,147 +86,46 @@ public:
virtual JumpControl *getJumpControl();
virtual PathNavigation *getNavigation();
virtual Sensing *getSensing();
- virtual Random *getRandom();
- virtual shared_ptr<Mob> getLastHurtByMob();
- virtual shared_ptr<Mob> getLastHurtMob();
- void setLastHurtMob(shared_ptr<Entity> target);
- virtual int getNoActionTime();
- float getYHeadRot();
- void setYHeadRot(float yHeadRot);
- float getSpeed();
- void setSpeed(float speed);
- virtual bool doHurtTarget(shared_ptr<Entity> target);
- shared_ptr<Mob> getTarget();
- virtual void setTarget(shared_ptr<Mob> target);
+ shared_ptr<LivingEntity> getTarget();
+ virtual void setTarget(shared_ptr<LivingEntity> target);
virtual bool canAttackType(eINSTANCEOF targetType);
virtual void ate();
- bool isWithinRestriction();
- bool isWithinRestriction(int x, int y, int z);
- void restrictTo(int x, int y, int z, int radius);
- Pos *getRestrictCenter();
- float getRestrictRadius();
- void clearRestriction();
- bool hasRestriction();
-
- virtual void setLastHurtByMob(shared_ptr<Mob> hurtBy);
-
protected:
virtual void defineSynchedData();
public:
- bool canSee(shared_ptr<Entity> target);
- virtual int getTexture(); // 4J - changed from wstring to int
- virtual bool isPickable() ;
- virtual bool isPushable();
- virtual float getHeadHeight();
virtual int getAmbientSoundInterval();
void playAmbientSound();
virtual void baseTick();
protected:
- virtual void tickDeath();
- virtual int decreaseAirSupply(int currentSupply);
virtual int getExperienceReward(shared_ptr<Player> killedBy);
- virtual bool isAlwaysExperienceDropper();
-
-public:
- void spawnAnim();
- virtual void rideTick();
-
-protected:
- int lSteps;
- double lx, ly, lz, lyr, lxr;
public:
- virtual void lerpTo(double x, double y, double z, float yRot, float xRot, int steps);
-
-private:
- float fallTime;
-
-public:
- void superTick();
+ virtual void spawnAnim();
virtual void tick();
- virtual void heal(int heal);
- virtual int getMaxHealth() = 0;
- virtual int getHealth();
- virtual void setHealth(int health);
-
-protected:
- int lastHurt;
-
-public:
- virtual bool hurt(DamageSource *source, int dmg);
protected:
- float getVoicePitch();
-
-public:
- virtual void animateHurt();
-
- /**
- * Fetches the mob's armor value, from 0 (no armor) to 20 (full armor)
- *
- * @return
- */
- virtual int getArmorValue();
-
-protected:
- virtual void hurtArmor(int damage);
- virtual int getDamageAfterArmorAbsorb(DamageSource *damageSource, int damage);
- virtual int getDamageAfterMagicAbsorb(DamageSource *damageSource, int damage);
-
- virtual void actuallyHurt(DamageSource *source, int dmg);
- virtual float getSoundVolume();
+ virtual float tickHeadTurn(float yBodyRotT, float walkSpeed);
virtual int getAmbientSound();
- virtual int getHurtSound();
- virtual int getDeathSound();
-
-public:
- void knockback(shared_ptr<Entity> source, int dmg, double xd, double zd);
- virtual void die(DamageSource *source);
-
-protected:
- virtual void dropRareDeathLoot(int rareLootLevel);
- virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
virtual int getDeathLoot();
- virtual void causeFallDamage(float distance);
+ virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
public:
- virtual void travel(float xa, float ya);
- virtual bool onLadder();
- virtual bool isShootable();
virtual void addAdditonalSaveData(CompoundTag *entityTag);
virtual void readAdditionalSaveData(CompoundTag *tag);
- virtual bool isAlive();
- virtual bool isWaterMob();
- virtual int getLightColor(float a); // 4J - added
protected:
- int noActionTime;
- float xxa, yya, yRotA;
- bool jumping;
float defaultLookAngle;
- float runSpeed;
-protected:
- int noJumpDelay;
public:
virtual void setYya(float yya);
- virtual void setJumping(bool jump);
-
+ virtual void setSpeed(float speed);
virtual void aiStep();
protected:
virtual bool useNewAi();
- virtual bool isEffectiveAI();
- virtual bool isImmobile();
-
-public:
- virtual bool isBlocking();
-
-protected:
- virtual void jumpFromGround();
virtual bool removeWhenFarAway();
private:
@@ -293,7 +136,6 @@ protected:
virtual void checkDespawn();
virtual void newServerAiStep();
- virtual void serverAiMobStep();
virtual void serverAiStep();
public:
@@ -309,60 +151,79 @@ private:
public:
virtual bool canSpawn();
-
-protected:
- virtual void outOfWorld();
-
-public:
- float getAttackAnim(float a);
- virtual Vec3 *getPos(float a);
- virtual Vec3 *getLookAngle();
- Vec3 *getViewVector(float a);
virtual float getSizeScale();
virtual float getHeadSizeScale();
- HitResult *pick(double range, float a);
virtual int getMaxSpawnClusterSize();
+ virtual int getMaxFallDistance();
virtual shared_ptr<ItemInstance> getCarriedItem();
+ virtual shared_ptr<ItemInstance> getCarried(int slot);
virtual shared_ptr<ItemInstance> getArmor(int pos);
- virtual void handleEntityEvent(byte id);
- virtual bool isSleeping();
- virtual Icon *getItemInHandIcon(shared_ptr<ItemInstance> item, int layer);
- virtual bool shouldRender(Vec3 *c);
+ virtual void setEquippedSlot(int slot, shared_ptr<ItemInstance> item);
+ virtual ItemInstanceArray getEquipmentSlots();
protected:
- void tickEffects();
+ virtual void dropEquipment(bool byPlayer, int playerBonusLevel);
+ virtual void populateDefaultEquipmentSlots();
public:
- void removeAllEffects();
- vector<MobEffectInstance *> *getActiveEffects();
- bool hasEffect(int id);
- bool hasEffect(MobEffect *effect);
- MobEffectInstance *getEffect(MobEffect *effect);
- void addEffect(MobEffectInstance *newEffect);
- void addEffectNoUpdate(MobEffectInstance *newEffect); // 4J Added
- virtual bool canBeAffected(MobEffectInstance *newEffect);
- virtual bool isInvertedHealAndHarm();
- void removeEffectNoUpdate(int effectId);
- void removeEffect(int effectId);
+ static int getEquipmentSlotForItem(shared_ptr<ItemInstance> item);
+ static Item *getEquipmentForSlot(int slot, int type);
protected:
- virtual void onEffectAdded(MobEffectInstance *effect);
- virtual void onEffectUpdated(MobEffectInstance *effect);
- virtual void onEffectRemoved(MobEffectInstance *effect);
+ virtual void populateDefaultEquipmentEnchantments();
public:
- virtual float getWalkingSpeedModifier();
+ /**
+ * Added this method so mobs can handle their own spawn settings instead of
+ * hacking MobSpawner.java
+ *
+ * @param groupData
+ * TODO
+ * @return TODO
+ */
+ virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param
+ virtual void finalizeSpawnEggSpawn(int extraData); // 4J Added
+ virtual bool canBeControlledByRider();
+ virtual wstring getAName();
+ virtual void setPersistenceRequired();
+ virtual void setCustomName(const wstring &name);
+ virtual wstring getCustomName();
+ virtual bool hasCustomName();
+ virtual void setCustomNameVisible(bool visible);
+ virtual bool isCustomNameVisible();
+ virtual bool shouldShowName();
+ virtual void setDropChance(int slot, float pct);
+ virtual bool canPickUpLoot();
+ virtual void setCanPickUpLoot(bool canPickUpLoot);
+ virtual bool isPersistenceRequired();
+ virtual bool interact(shared_ptr<Player> player);
- // 4J-Pb added (from 1.2.3)
- virtual void teleportTo(double x, double y, double z);
- virtual bool isBaby();
- virtual MobType getMobType();
- virtual void breakItem(shared_ptr<ItemInstance> itemInstance);
+protected:
+ virtual bool mobInteract(shared_ptr<Player> player);
- virtual bool isInvulnerable();
+ // roper / leash methods
- virtual void finalizeMobSpawn();
- virtual bool canBeControlledByRider();
+private:
+ bool _isLeashed;
+ shared_ptr<Entity> leashHolder;
+ CompoundTag *leashInfoTag;
+
+protected:
+ virtual void tickLeash();
+
+public:
+ virtual void dropLeash(bool synch, bool createItemDrop);
+ virtual bool canBeLeashed();
+ virtual bool isLeashed();
+ virtual shared_ptr<Entity> getLeashHolder();
+ virtual void setLeashedTo(shared_ptr<Entity> holder, bool synch);
+
+private:
+ virtual void restoreLeashFromSave();
+ virtual bool shouldRender(Vec3 *c);
+
+
+public:
// 4J Added override to update ai elements when loading entity from schematics
virtual void setLevel(Level *level);