From d7a52870003e46858bec65cc76880cecc5de7bb8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 Aug 2013 18:10:58 +0200 Subject: Basic support for thrown items - eggs, snowballs and ender pearls. They can be thrown, but they don't do anything on impact. Also they don't save to nor load from MCA. --- source/Entities/ProjectileEntity.h | 93 +++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) (limited to 'source/Entities/ProjectileEntity.h') diff --git a/source/Entities/ProjectileEntity.h b/source/Entities/ProjectileEntity.h index aa7ecc772..95dc00abc 100644 --- a/source/Entities/ProjectileEntity.h +++ b/source/Entities/ProjectileEntity.h @@ -78,6 +78,7 @@ protected: // cEntity overrides: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; + virtual void SpawnOn(cClientHandle & a_Client) override; // tolua_begin } ; @@ -105,7 +106,7 @@ public: CLASS_PROTODEF(cArrowEntity); /// Creates a new arrow with psNoPickup state and default damage modifier coeff - cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d a_Speed); + cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); /// Creates a new arrow as shot by a player, initializes it from the player object cArrowEntity(cPlayer & a_Player, double a_Force); @@ -137,12 +138,100 @@ protected: /// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow double m_DamageCoeff; - // cEntity overrides: + // cProjectileEntity overrides: virtual void SpawnOn(cClientHandle & a_Client) override; // tolua_begin } ; + + + + +class cThrownEggEntity : + public cProjectileEntity +{ + typedef cProjectileEntity super; + +public: + + // tolua_end + + CLASS_PROTODEF(cThrownEggEntity); + + cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + +protected: + + // tolua_end + + // cProjectileEntity overrides: + virtual void OnHitSolidBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override; + + // tolua_begin + +} ; + + + + + +class cThrownEnderPearlEntity : + public cProjectileEntity +{ + typedef cProjectileEntity super; + +public: + + // tolua_end + + CLASS_PROTODEF(cThrownEnderPearlEntity); + + cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + +protected: + + // tolua_end + + // cProjectileEntity overrides: + virtual void OnHitSolidBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override; + + // tolua_begin + +} ; + + + + + +class cThrownSnowballEntity : + public cProjectileEntity +{ + typedef cProjectileEntity super; + +public: + + // tolua_end + + CLASS_PROTODEF(cThrownSnowballEntity); + + cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + +protected: + + // tolua_end + + // cProjectileEntity overrides: + virtual void OnHitSolidBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override; + + // tolua_begin + +} ; + + + + + // tolua_end -- cgit v1.2.3