summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-06-07 06:48:20 +0200
committerarchshift <admin@archshift.com>2014-06-17 20:39:19 +0200
commit481f05b011230cba42901df939306b803bd670b6 (patch)
treeeaea1ab673ade4a85fc51ea3be9c3ceaf34999e7 /src/Entities/Player.cpp
parentAdded iterator on tick to manage entity effect duration (diff)
downloadcuberite-481f05b011230cba42901df939306b803bd670b6.tar
cuberite-481f05b011230cba42901df939306b803bd670b6.tar.gz
cuberite-481f05b011230cba42901df939306b803bd670b6.tar.bz2
cuberite-481f05b011230cba42901df939306b803bd670b6.tar.lz
cuberite-481f05b011230cba42901df939306b803bd670b6.tar.xz
cuberite-481f05b011230cba42901df939306b803bd670b6.tar.zst
cuberite-481f05b011230cba42901df939306b803bd670b6.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 035973a16..95ee8b39d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -584,12 +584,11 @@ void cPlayer::FoodPoison(int a_NumTicks)
m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
if (!HasBeenFoodPoisoned)
{
- m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger);
SendHealth();
}
else
{
- m_World->BroadcastEntityEffect(*this, cEntityEffect::efHunger, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
+ AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, 400)); // Give the player the "Hunger" effect for 20 seconds.
}
}
@@ -1887,6 +1886,43 @@ void cPlayer::TickBurning(cChunk & a_Chunk)
+void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+{
+ switch (a_EffectType)
+ {
+ // Effects whose behaviors are overridden
+ case cEntityEffect::efMiningFatigue:
+ {
+ // TODO: Implement me!
+ return;
+ }
+ case cEntityEffect::efHunger:
+ {
+ m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
+ return;
+ }
+ case cEntityEffect::efSaturation:
+ {
+ // Increase saturation 1 per tick, adds 1 for every increase in level
+ m_FoodSaturationLevel += (1 + a_Effect.GetIntensity());
+ return;
+ }
+
+ // Client-side-only effects
+ case cEntityEffect::efNausia:
+ case cEntityEffect::efNightVision:
+ {
+ return;
+ }
+ }
+
+ super::HandleEntityEffects(a_EffectType, a_Effect);
+}
+
+
+
+
+
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
@@ -1921,17 +1957,6 @@ void cPlayer::HandleFood(void)
}
}
}
-
- // Apply food poisoning food exhaustion:
- if (m_FoodPoisonedTicksRemaining > 0)
- {
- m_FoodPoisonedTicksRemaining--;
- m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
- }
- else
- {
- m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); // Remove the "Hunger" effect.
- }
// Apply food exhaustion that has accumulated:
if (m_FoodExhaustionLevel >= 4)