summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2015-10-31 23:18:27 +0100
committerAlexander Harkness <me@bearbin.net>2015-10-31 23:18:27 +0100
commitb13fd00ec44cc3fc4ad0395b3b9df04de00617b5 (patch)
tree671987e9a48544fd0fc37135732feebdca697caa /src
parentMerge pull request #2549 from cuberite/TouchGround (diff)
parentImplemented the FireResistence potion effects. (diff)
downloadcuberite-b13fd00ec44cc3fc4ad0395b3b9df04de00617b5.tar
cuberite-b13fd00ec44cc3fc4ad0395b3b9df04de00617b5.tar.gz
cuberite-b13fd00ec44cc3fc4ad0395b3b9df04de00617b5.tar.bz2
cuberite-b13fd00ec44cc3fc4ad0395b3b9df04de00617b5.tar.lz
cuberite-b13fd00ec44cc3fc4ad0395b3b9df04de00617b5.tar.xz
cuberite-b13fd00ec44cc3fc4ad0395b3b9df04de00617b5.tar.zst
cuberite-b13fd00ec44cc3fc4ad0395b3b9df04de00617b5.zip
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Entity.cpp6
-rw-r--r--src/Entities/Entity.h2
-rw-r--r--src/Entities/FireChargeEntity.cpp7
-rw-r--r--src/Entities/Pawn.cpp18
-rw-r--r--src/Entities/Pawn.h7
5 files changed, 34 insertions, 6 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index a70ac6d1a..68e2cb1df 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1104,7 +1104,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
m_TicksSinceLastBurnDamage++;
if (m_TicksSinceLastBurnDamage >= BURN_TICKS_PER_DAMAGE)
{
- if (!m_IsFireproof)
+ if (!IsFireproof())
{
TakeDamage(dtOnFire, nullptr, BURN_DAMAGE, 0);
}
@@ -1175,7 +1175,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
m_TicksSinceLastLavaDamage++;
if (m_TicksSinceLastLavaDamage >= LAVA_TICKS_PER_DAMAGE)
{
- if (!m_IsFireproof)
+ if (!IsFireproof())
{
TakeDamage(dtLavaContact, nullptr, LAVA_DAMAGE, 0);
}
@@ -1196,7 +1196,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
m_TicksSinceLastFireDamage++;
if (m_TicksSinceLastFireDamage >= FIRE_TICKS_PER_DAMAGE)
{
- if (!m_IsFireproof)
+ if (!IsFireproof())
{
TakeDamage(dtFireContact, nullptr, FIRE_DAMAGE, 0);
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 0161db387..0f8297d73 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -367,7 +367,7 @@ public:
/** Sets whether the entity is fireproof */
void SetIsFireproof(bool a_IsFireproof);
- bool IsFireproof(void) const { return m_IsFireproof; }
+ virtual bool IsFireproof(void) const { return m_IsFireproof; }
/** Puts the entity on fire for the specified amount of ticks */
void StartBurning(int a_TicksLeftBurning);
diff --git a/src/Entities/FireChargeEntity.cpp b/src/Entities/FireChargeEntity.cpp
index 10d83b8dd..0db4b66d3 100644
--- a/src/Entities/FireChargeEntity.cpp
+++ b/src/Entities/FireChargeEntity.cpp
@@ -46,6 +46,9 @@ void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hi
Destroy();
Explode(a_HitPos.Floor());
- // TODO: Some entities are immune to hits
- a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
+ if (!a_EntityHit.IsFireproof())
+ {
+ // TODO Damage Entity with 5 damage(from http://minecraft.gamepedia.com/Blaze#Blaze_fireball)
+ a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
+ }
}
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 2cd0f2f0e..9045f8595 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -61,6 +61,15 @@ void cPawn::KilledBy(TakeDamageInfo & a_TDI)
+bool cPawn::IsFireproof(void) const
+{
+ return super::IsFireproof() || HasEntityEffect(cEntityEffect::effFireResistance);
+}
+
+
+
+
+
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
{
// Check if the plugins allow the addition:
@@ -98,6 +107,15 @@ void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
+bool cPawn::HasEntityEffect(cEntityEffect::eType a_EffectType) const
+{
+ return m_EntityEffects.find(a_EffectType) != m_EntityEffects.end();
+}
+
+
+
+
+
void cPawn::ClearEntityEffects()
{
// Iterate through this entity's applied effects
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index e3e99651d..40ce9b2dd 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -23,6 +23,8 @@ public:
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+ virtual bool IsFireproof(void) const override;
+
// tolua_begin
/** Applies an entity effect
@@ -39,6 +41,11 @@ public:
*/
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
+ /** Returns true, if the entity effect is currently applied
+ @param a_EffectType The entity effect to check
+ */
+ bool HasEntityEffect(cEntityEffect::eType a_EffectType) const;
+
/** Removes all currently applied entity effects (used when drinking milk) */
void ClearEntityEffects(void);