summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-07-19 13:29:50 +0200
committerMattes D <github@xoft.cz>2014-07-19 13:29:50 +0200
commite9a9bbf02e563b9ea121aefe0f82ed5dd74d1686 (patch)
treeca52fbde3b744760e8dd9c1845d0ac7714a432ce
parentRenamed AllToLua_lua script. (diff)
parentSplash potions: Renamed PotionParticleType to PotionColor for clarity (diff)
downloadcuberite-e9a9bbf02e563b9ea121aefe0f82ed5dd74d1686.tar
cuberite-e9a9bbf02e563b9ea121aefe0f82ed5dd74d1686.tar.gz
cuberite-e9a9bbf02e563b9ea121aefe0f82ed5dd74d1686.tar.bz2
cuberite-e9a9bbf02e563b9ea121aefe0f82ed5dd74d1686.tar.lz
cuberite-e9a9bbf02e563b9ea121aefe0f82ed5dd74d1686.tar.xz
cuberite-e9a9bbf02e563b9ea121aefe0f82ed5dd74d1686.tar.zst
cuberite-e9a9bbf02e563b9ea121aefe0f82ed5dd74d1686.zip
-rw-r--r--src/Entities/SplashPotionEntity.cpp20
-rw-r--r--src/Entities/SplashPotionEntity.h14
-rw-r--r--src/Items/ItemPotion.h6
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp2
-rw-r--r--src/WorldStorage/WSSAnvil.cpp2
5 files changed, 30 insertions, 14 deletions
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 3efb1f25d..056700629 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -2,11 +2,15 @@
#include "SplashPotionEntity.h"
#include "Pawn.h"
+#include "../ClientHandle.h"
+/// Converts an angle in radians into a byte representation used by the network protocol
+#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360)
+
////////////////////////////////////////////////////////////////////////////////
// cSplashPotionEntityCallback:
@@ -72,12 +76,12 @@ cSplashPotionEntity::cSplashPotionEntity(
const Vector3d & a_Speed,
cEntityEffect::eType a_EntityEffectType,
cEntityEffect a_EntityEffect,
- int a_PotionParticleType
+ int a_PotionColor
) :
super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
m_EntityEffectType(a_EntityEffectType),
m_EntityEffect(a_EntityEffect),
- m_PotionParticleType(a_PotionParticleType)
+ m_PotionColor(a_PotionColor)
{
SetSpeed(a_Speed);
}
@@ -112,7 +116,17 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
m_World->ForEachEntity(Callback);
- m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionParticleType);
+ m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionColor);
+}
+
+
+
+
+
+void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client)
+{
+ a_Client.SendSpawnObject(*this, 73, m_PotionColor, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch()));
+ a_Client.SendEntityMetadata(*this);
}
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 2c78b55d2..a33b06990 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -31,22 +31,22 @@ public:
const Vector3d & a_Speed,
cEntityEffect::eType a_EntityEffectType,
cEntityEffect a_EntityEffect,
- int a_PotionParticleType
+ int a_PotionColor
);
- cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; }
- cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; }
- int GetPotionParticleType(void) const { return m_PotionParticleType; }
+ cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
+ cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
+ int GetPotionColor(void) const { return m_PotionColor; }
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
- void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; }
+ void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
protected:
cEntityEffect::eType m_EntityEffectType;
cEntityEffect m_EntityEffect;
- int m_PotionParticleType;
+ int m_PotionColor;
// cProjectileEntity overrides:
@@ -56,4 +56,6 @@ protected:
/** Splashes the potion, fires its particle effects and sounds
@param a_HitPos The position where the potion will splash */
void Splash(const Vector3d & a_HitPos);
+
+ virtual void SpawnOn(cClientHandle & a_Client) override;
} ; // tolua_export
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index f3afbf99b..f16d89b39 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -17,8 +17,8 @@ public:
}
- /** Returns the potion particle type (used by the client for visuals), based on the potion's damage value */
- static int GetPotionParticleType(short a_ItemDamage)
+ /** Returns the potion color (used by the client for visuals), based on the potion's damage value */
+ static int GetPotionColor(short a_ItemDamage)
{
// Lowest six bits
return (a_ItemDamage & 0x3f);
@@ -156,7 +156,7 @@ public:
cSplashPotionEntity * Projectile = new cSplashPotionEntity(
a_Player, Pos.x, Pos.y, Pos.z, Speed,
GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage),
- GetEntityEffectIntensity(PotionDamage)), GetPotionParticleType(PotionDamage)
+ GetEntityEffectIntensity(PotionDamage)), GetPotionColor(PotionDamage)
);
if (Projectile == NULL)
{
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index e68903b26..62db302ef 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -613,7 +613,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
- m_Writer.AddInt("PotionName", Potion->GetPotionParticleType());
+ m_Writer.AddInt("PotionName", Potion->GetPotionColor());
}
case cProjectileEntity::pkGhastFireball:
{
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index b4048b097..663d489bc 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1681,7 +1681,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
- SplashPotion->SetPotionParticleType(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
+ SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
// Store the new splash potion in the entities list:
a_Entities.push_back(SplashPotion.release());