aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Entity.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/Entity.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/Entity.h')
-rw-r--r--Minecraft.World/Entity.h80
1 files changed, 58 insertions, 22 deletions
diff --git a/Minecraft.World/Entity.h b/Minecraft.World/Entity.h
index bde83e30..e2a26290 100644
--- a/Minecraft.World/Entity.h
+++ b/Minecraft.World/Entity.h
@@ -6,7 +6,7 @@ using namespace std;
#include "Vec3.h"
#include "Definitions.h"
-class Mob;
+class LivingEntity;
class LightningBolt;
class ItemEntity;
class EntityPos;
@@ -17,6 +17,7 @@ class Random;
class Level;
class CompoundTag;
class DamageSource;
+class Explosion;
// 4J Stu Added this mainly to allow is to record telemetry for player deaths
enum EEntityDamageType
@@ -33,13 +34,16 @@ enum EEntityDamageType
class Entity : public enable_shared_from_this<Entity>
{
-friend class Gui; // 4J Stu - Added to be able to access the shared flag functions and constants, without making them publicly available to everything
+ friend class Gui; // 4J Stu - Added to be able to access the shared flag functions and constants, without making them publicly available to everything
public:
// 4J-PB - added to replace (e instanceof Type), avoiding dynamic casts
virtual eINSTANCEOF GetType() = 0;
-public:
+ inline bool instanceof(eINSTANCEOF super) { return eTYPE_DERIVED_FROM(super, GetType()); }
+ inline static bool instanceof(eINSTANCEOF type, eINSTANCEOF super) { return eTYPE_DERIVED_FROM(super, type); }
+public:
+ static const wstring RIDING_TAG;
static const short TOTAL_AIR_SUPPLY = 20 * 15;
private:
@@ -53,6 +57,7 @@ public:
bool blocksBuilding;
weak_ptr<Entity> rider; // Changed to weak to avoid circular dependency between rider/riding entity
shared_ptr<Entity> riding;
+ bool forcedLoading;
Level *level;
double xo, yo, zo;
@@ -79,6 +84,7 @@ public:
float walkDistO;
float walkDist;
+ float moveDist;
float fallDistance;
private:
@@ -110,10 +116,6 @@ public:
private:
bool firstTick;
-public:
- wstring customTextureUrl;
- wstring customTextureUrl2;
-
protected:
bool fireImmune;
@@ -125,7 +127,7 @@ private:
static const int DATA_SHARED_FLAGS_ID = 0;
static const int FLAG_ONFIRE = 0;
static const int FLAG_SNEAKING = 1;
- static const int FLAG_RIDING = 2;
+ //static const int FLAG_ = 2;
static const int FLAG_SPRINTING = 3;
static const int FLAG_USING_ITEM = 4;
static const int FLAG_INVISIBLE = 5;
@@ -138,22 +140,39 @@ private:
public:
bool inChunk;
- int xChunk, yChunk, zChunk;
- int xp, yp, zp, xRotp, yRotp;
- bool noCulling;
- bool hasImpulse;
+ int xChunk, yChunk, zChunk;
+ int xp, yp, zp, xRotp, yRotp;
+ bool noCulling;
+ bool hasImpulse;
+ int changingDimensionDelay;
+
+protected:
+ bool isInsidePortal;
+ int portalTime;
+
+public:
+ int dimension;
+
+protected:
+ int portalEntranceDir;
+
+private:
+ bool invulnerable;
+ wstring uuid;
protected:
// 4J Added so that client side simulations on the host are not affected by zero-lag
bool m_ignoreVerticalCollisions;
+ bool m_ignorePortal;
+
public:
Entity(Level *level, bool useSmallId = true); // 4J - added useSmallId parameter
virtual ~Entity();
protected:
// 4J - added for common ctor code
- void _init(bool useSmallId);
+ void _init(bool useSmallId, Level *level);
protected:
virtual void defineSynchedData() = 0;
@@ -191,6 +210,7 @@ public:
void interpolateTurn(float xo, float yo);
virtual void tick();
virtual void baseTick();
+ virtual int getPortalWaitTime();
protected:
void lavaHurt();
@@ -256,7 +276,7 @@ protected:
public:
// 4J Added damageSource param to enable telemetry on player deaths
- virtual bool hurt(DamageSource *source, int damage);
+ virtual bool hurt(DamageSource *source, float damage);
bool intersects(double x0, double y0, double z0, double x1, double y1, double z1);
virtual bool isPickable();
virtual bool isPushable();
@@ -264,18 +284,24 @@ public:
virtual void awardKillScore(shared_ptr<Entity> victim, int score);
virtual bool shouldRender(Vec3 *c);
virtual bool shouldRenderAtSqrDistance(double distance);
- virtual int getTexture(); // 4J - changed from wstring to int
virtual bool isCreativeModeAllowed();
+ bool saveAsMount(CompoundTag *entityTag);
bool save(CompoundTag *entityTag);
void saveWithoutId(CompoundTag *entityTag);
virtual void load(CompoundTag *tag);
protected:
+ virtual bool repositionEntityAfterLoad();
const wstring getEncodeId();
public:
virtual void readAdditionalSaveData(CompoundTag *tag) = 0;
virtual void addAdditonalSaveData(CompoundTag *tag) = 0;
+ /**
+ * Called after load() has finished and the entity has been added to the
+ * world
+ */
+ virtual void onLoadedFromSave();
protected:
ListTag<DoubleTag> *newDoubleList(unsigned int number, double firstValue, ...);
@@ -296,15 +322,14 @@ public:
virtual double getRidingHeight();
virtual double getRideHeight();
virtual void ride(shared_ptr<Entity> e);
- virtual void findStandUpPosition(shared_ptr<Entity> vehicle); // 4J Stu - Brought forward from 12w36 to fix #46282 - TU5: Gameplay: Exiting the minecart in a tight corridor damages the player
virtual void lerpTo(double x, double y, double z, float yRot, float xRot, int steps);
virtual float getPickRadius();
virtual Vec3 *getLookAngle();
virtual void handleInsidePortal();
+ virtual int getDimensionChangingDelay();
virtual void lerpMotion(double xd, double yd, double zd);
virtual void handleEntityEvent(byte eventId);
virtual void animateHurt();
- virtual void prepareCustomTextures();
virtual ItemInstanceArray getEquipmentSlots(); // ItemInstance[]
virtual void setEquippedSlot(int slot, shared_ptr<ItemInstance> item); // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
virtual bool isOnFire();
@@ -336,7 +361,7 @@ public:
void setAirSupply(int supply);
virtual void thunderHit(const LightningBolt *lightningBolt);
- virtual void killed(shared_ptr<Mob> mob);
+ virtual void killed(shared_ptr<LivingEntity> mob);
protected:
bool checkInTile(double x, double y, double z);
@@ -346,9 +371,6 @@ public:
virtual wstring getAName();
- // TU9
- bool skipAttackInteraction(shared_ptr<Entity> source) {return false;}
-
// 4J - added to manage allocation of small ids
private:
// Things also added here to be able to manage the concept of a number of extra "wandering" entities - normally path finding entities aren't allowed to
@@ -374,14 +396,28 @@ public:
void considerForExtraWandering(bool enable);
bool isExtraWanderingEnabled();
int getWanderingQuadrant();
-
+
virtual vector<shared_ptr<Entity> > *getSubEntities();
virtual bool is(shared_ptr<Entity> other);
virtual float getYHeadRot();
virtual void setYHeadRot(float yHeadRot);
virtual bool isAttackable();
+ virtual bool skipAttackInteraction(shared_ptr<Entity> source);
virtual bool isInvulnerable();
virtual void copyPosition(shared_ptr<Entity> target);
+ virtual void restoreFrom(shared_ptr<Entity> oldEntity, bool teleporting);
+ virtual void changeDimension(int i);
+ virtual float getTileExplosionResistance(Explosion *explosion, Level *level, int x, int y, int z, Tile *tile);
+ virtual bool shouldTileExplode(Explosion *explosion, Level *level, int x, int y, int z, int id, float power);
+ virtual int getMaxFallDistance();
+ virtual int getPortalEntranceDir();
+ virtual bool isIgnoringTileTriggers();
+ virtual bool displayFireAnimation();
+ virtual void setUUID(const wstring &UUID);
+ virtual wstring getUUID();
+ virtual bool isPushedByWater();
+ virtual wstring getDisplayName();
+ virtual wstring getNetworkName(); // 4J: Added
private:
unsigned int m_uiAnimOverrideBitmask;