summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2014-02-16 08:05:11 +0100
committerAlexander Harkness <bearbin@gmail.com>2014-02-16 08:05:11 +0100
commit233f0add2930f316c5fafce9e29a12f2e4f007bc (patch)
tree8007f9a88f30eb7b209c68e9ab2a88bb290d382b /src
parentRemoved the unnecessary LoopPlayersAndBroadcastChat() functions. (diff)
parentReplace random Float Generation and broadcast the Exp Pickup Sound (diff)
downloadcuberite-233f0add2930f316c5fafce9e29a12f2e4f007bc.tar
cuberite-233f0add2930f316c5fafce9e29a12f2e4f007bc.tar.gz
cuberite-233f0add2930f316c5fafce9e29a12f2e4f007bc.tar.bz2
cuberite-233f0add2930f316c5fafce9e29a12f2e4f007bc.tar.lz
cuberite-233f0add2930f316c5fafce9e29a12f2e4f007bc.tar.xz
cuberite-233f0add2930f316c5fafce9e29a12f2e4f007bc.tar.zst
cuberite-233f0add2930f316c5fafce9e29a12f2e4f007bc.zip
Diffstat (limited to 'src')
-rw-r--r--src/Entities/ExpOrb.cpp7
-rw-r--r--src/Entities/Player.cpp17
-rw-r--r--src/Entities/Player.h2
-rw-r--r--src/Entities/ProjectileEntity.cpp1
-rw-r--r--src/Protocol/Protocol17x.cpp2
5 files changed, 26 insertions, 3 deletions
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 04ee85823..41b60cc3b 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -51,6 +51,11 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
{
LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward);
a_ClosestPlayer->DeltaExperience(m_Reward);
+
+ float r1 = (float) (0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64); // Random Float Value
+ float r2 = (float) (0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64); // Random Float Value
+ m_World->BroadcastSoundEffect("random.orb", (int) (GetPosX() * 8.0F), (int) (GetPosY() * 8.0F), (int) (GetPosZ() * 8.0F), 0.1F, 0.5F * ((r1 - r2) * 0.7F + 1.8F));
+
Destroy(true);
}
a_Distance.Normalize();
@@ -61,4 +66,4 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
BroadcastMovementUpdate();
}
HandlePhysics(a_Dt, a_Chunk);
-} \ No newline at end of file
+}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index d568e068d..be26e4f6e 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1059,6 +1059,15 @@ void cPlayer::CloseWindowIfID(char a_WindowID, bool a_CanRefuse)
+void cPlayer::PlaySoundEffect(const AString & a_SoundName, float a_Volume, float a_Pitch)
+{
+ m_ClientHandle->SendSoundEffect(a_SoundName, (int) (GetPosX() * 8.0), (int) (GetPosY() * 8.0), (int) (GetPosZ() * 8.0), a_Volume, a_Pitch);
+}
+
+
+
+
+
void cPlayer::SetLastBlockActionTime()
{
if (m_World != NULL)
@@ -1764,6 +1773,12 @@ void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
+ if (IsGameModeCreative())
+ {
+ // Hunger is disabled for Creative
+ return;
+ }
+
// Remember the food level before processing, for later comparison
int LastFoodLevel = m_FoodLevel;
@@ -1781,7 +1796,7 @@ void cPlayer::HandleFood(void)
Heal(1);
m_FoodExhaustionLevel += 3;
}
- else if (m_FoodLevel <= 0)
+ else if (m_FoodLevel <= 0 && m_Health > 1)
{
// Damage from starving
TakeDamage(dtStarving, NULL, 1, 1, 0);
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 53e4b56db..838f0301d 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -208,6 +208,8 @@ public:
const AString & GetName(void) const { return m_PlayerName; }
void SetName(const AString & a_Name) { m_PlayerName = a_Name; }
+ void PlaySoundEffect(const AString & a_SoundName, float a_Volume, float a_Pitch);
+
// tolua_end
typedef std::list< cGroup* > GroupList;
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index a3fa9d557..ef82c6e94 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -680,6 +680,7 @@ super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
// Spawn an experience orb with a reward between 3 and 11.
+ m_World->BroadcastSoundParticleEffect(2002, POSX_TOINT, POSY_TOINT, POSZ_TOINT, 0);
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), 3 + m_World->GetTickRandomNumber(8));
Destroy();
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 5aa18300c..1dfa5ec90 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -550,7 +550,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (cRoot::Get()->GetServer()->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
Pkt.WriteChar((char)a_World.GetDimension());
Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteByte(cRoot::Get()->GetServer()->GetMaxPlayers());
+ Pkt.WriteByte(std::min(cRoot::Get()->GetServer()->GetMaxPlayers(), 60));
Pkt.WriteString("default"); // Level type - wtf?
}