Cuberite
A lightweight, fast and extensible game server for Minecraft
SplashPotionEntity.h
Go to the documentation of this file.
1 
2 // SplashPotionEntity.h
3 
4 // Declares the cSplashPotionEntity class representing a splash potion that has been thrown
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "ProjectileEntity.h"
13 #include "EntityEffect.h"
14 #include "../World.h"
15 
16 
17 
18 class cEntity;
19 
20 
21 
22 // tolua_begin
23 
25  public cProjectileEntity
26 {
27  // tolua_end
28 
30 
31 public: // tolua_export
32 
34 
36  cEntity * a_Creator,
37  Vector3d a_Pos,
38  Vector3d a_Speed,
39  const cItem & a_Item
40  );
41 
42  // tolua_begin
43  cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
44  int GetPotionColor(void) const { return m_PotionColor; }
45  const cItem & GetItem(void) const { return m_Item; }
46 
47  void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
48  void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
49 
50  // tolua_end
51 
53  void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
54 
55 protected:
56 
61 
62 
63  // cProjectileEntity overrides:
64  virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
65  virtual void OnHitEntity (cEntity & a_EntityHit, Vector3d a_HitPos) override;
66  virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override
67  {
68  if (m_DestroyTimer > 0)
69  {
71  if (m_DestroyTimer == 0)
72  {
73  Destroy();
74  return;
75  }
76  }
77  else
78  {
79  super::Tick(a_Dt, a_Chunk);
80  }
81  }
82 
85  void Splash(Vector3d a_HitPos);
86 
87  virtual void SpawnOn(cClientHandle & a_Client) override;
88 
89 private:
92 } ; // tolua_export
93 
94 
95 
96 
eType
All types of entity effects (numbers correspond to protocol / storage types)
Definition: EntityEffect.h:11
void SetEntityEffect(cEntityEffect a_EntityEffect)
cEntityEffect::eType m_EntityEffectType
void Splash(Vector3d a_HitPos)
Splashes the potion, fires its particle effects and sounds.
int m_DestroyTimer
Time in ticks to wait for the hit animation to begin before destroying.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Chunk.h:49
virtual void Destroy(bool a_ShouldBroadcast=true)
Destroys the entity and schedules it for memory freeing; if a_ShouldBroadcast is set to true...
Definition: Entity.cpp:219
cEntityEffect m_EntityEffect
void SetPotionColor(int a_PotionColor)
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos) override
Called by the physics blocktracer when the entity hits another entity.
cEntityEffect GetEntityEffect(void) const
const cItem & GetItem(void) const
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
Definition: Entity.h:73
int GetPotionColor(void) const
#define CLASS_PROTODEF(classname)
Definition: Entity.h:11
cEntityEffect::eType GetEntityEffectType(void) const
virtual void SpawnOn(cClientHandle &a_Client) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
cProjectileEntity(eKind a_Kind, cEntity *a_Creator, Vector3d a_Pos, double a_Width, double a_Height)
virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override
Called by the physics blocktracer when the entity hits a solid block, the hit position and the face h...
Definition: Item.h:36
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType)