summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-06-08 06:56:01 +0200
committerarchshift <admin@archshift.com>2014-06-17 20:39:20 +0200
commit58f35af6e71f11844b9c6c1d1ebd2d7390439cca (patch)
treeba93d854c83bebfc32f691be795564c975a734cc /src/Items
parentEntity: only fire critical hit if damage type is physical (diff)
downloadcuberite-58f35af6e71f11844b9c6c1d1ebd2d7390439cca.tar
cuberite-58f35af6e71f11844b9c6c1d1ebd2d7390439cca.tar.gz
cuberite-58f35af6e71f11844b9c6c1d1ebd2d7390439cca.tar.bz2
cuberite-58f35af6e71f11844b9c6c1d1ebd2d7390439cca.tar.lz
cuberite-58f35af6e71f11844b9c6c1d1ebd2d7390439cca.tar.xz
cuberite-58f35af6e71f11844b9c6c1d1ebd2d7390439cca.tar.zst
cuberite-58f35af6e71f11844b9c6c1d1ebd2d7390439cca.zip
Diffstat (limited to 'src/Items')
-rw-r--r--src/Items/ItemPotion.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index e34b251aa..528268cfe 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -2,12 +2,18 @@
#pragma once
#include "../Entities/EntityEffects.h"
+#include "../Entities/SplashPotionEntity.h"
class cItemPotionHandler:
-public cItemHandler
+ public cItemHandler
{
typedef cItemHandler super;
+ int GetPotionName(short a_ItemDamage)
+ {
+ return a_ItemDamage & 63;
+ }
+
cEntityEffect::eType GetEntityEffectType(short a_ItemDamage)
{
// Potion effect bits are different from entity effect values
@@ -118,6 +124,34 @@ public:
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
{
+ Vector3d Speed = a_Player->GetLookVector() * 10;
+
+ short potion_damage = a_Item.m_ItemDamage;
+ cProjectileEntity * Projectile = new cSplashPotionEntity(a_Player,
+ (double)a_BlockX,
+ (double)a_BlockY,
+ (double)a_BlockZ,
+ &Speed,
+ GetEntityEffectType(potion_damage),
+ cEntityEffect(GetEntityEffectDuration(potion_damage),
+ GetEntityEffectIntensity(potion_damage),
+ a_Player),
+ GetPotionName(potion_damage));
+ if (Projectile == NULL)
+ {
+ return false;
+ }
+ if (!Projectile->Initialize(*a_World))
+ {
+ delete Projectile;
+ return false;
+ }
+
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
+
// Called when potion is a splash potion
return true;
}