summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2017-12-26 21:27:24 +0100
committerGitHub <noreply@github.com>2017-12-26 21:27:24 +0100
commit705deea20549ce21ffc31633a3e573f3784becbd (patch)
tree0c0b98a0f99d10d11e3eecb687b815f9553c4342 /src/Entities
parentProtocol: Fix potion metadata parsing (#4116) (diff)
downloadcuberite-705deea20549ce21ffc31633a3e573f3784becbd.tar
cuberite-705deea20549ce21ffc31633a3e573f3784becbd.tar.gz
cuberite-705deea20549ce21ffc31633a3e573f3784becbd.tar.bz2
cuberite-705deea20549ce21ffc31633a3e573f3784becbd.tar.lz
cuberite-705deea20549ce21ffc31633a3e573f3784becbd.tar.xz
cuberite-705deea20549ce21ffc31633a3e573f3784becbd.tar.zst
cuberite-705deea20549ce21ffc31633a3e573f3784becbd.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/EntityEffect.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index 0ae50be80..fcb1fdfdb 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -23,7 +23,7 @@ cEntityEffect::eType cEntityEffect::GetPotionEffectType(short a_ItemDamage)
{
// Lowest four bits
// Potion effect bits are different from entity effect values
- // For reference: https://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits
+ // For reference: https://minecraft.gamepedia.com/Java_Edition_data_values#.22Potion_effect.22_bits
switch (a_ItemDamage & 0x0f)
{
case 0x01: return cEntityEffect::effRegeneration;
@@ -112,9 +112,9 @@ int cEntityEffect::GetPotionEffectDuration(short a_ItemDamage)
SplashCoeff = IsPotionDrinkable(a_ItemDamage) ? 1 : 0.75;
// Ref.:
- // https://minecraft.gamepedia.com/Data_values#.22Tier.22_bit
- // https://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit
- // https://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit
+ // https://minecraft.gamepedia.com/Java_Edition_data_values#.22Tier.22_bit
+ // https://minecraft.gamepedia.com/Java_Edition_data_values#.22Extended_duration.22_bit
+ // https://minecraft.gamepedia.com/Java_Edition_data_values#.22Splash_potion.22_bit
return static_cast<int>(base * TierCoeff * ExtCoeff * SplashCoeff);
}
@@ -125,9 +125,10 @@ int cEntityEffect::GetPotionEffectDuration(short a_ItemDamage)
bool cEntityEffect::IsPotionDrinkable(short a_ItemDamage)
{
- // Drinkable potion if 13th lowest bit is set
- // Ref.: https://minecraft.gamepedia.com/Potions#Data_value_table
- return ((a_ItemDamage & 0x2000) != 0);
+ // Potions are drinkable if they are not splash potions.
+ // i.e. potions are drinkable if the 14th lowest bit is not set
+ // Ref.: https://minecraft.gamepedia.com/Java_Edition_data_values#.22Splash_potion.22_bit
+ return ((a_ItemDamage & 0x4000) == 0);
}
@@ -512,7 +513,3 @@ void cEntityEffectSaturation::OnTick(cPawn & a_Target)
Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level
}
}
-
-
-
-