summaryrefslogtreecommitdiffstats
path: root/source/cNoteEntity.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-11 14:01:34 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-11 14:01:34 +0200
commit9eed83c33ae8c2bbb1781a01f05326dba667f4e3 (patch)
tree339ae563c07ba06b55a7f127dbd8c52f83e4dd66 /source/cNoteEntity.cpp
parentCore's Web Chat should work on FireFox again. Apparently it appends "charset=utf-8" to the content type which was not properly handled. (diff)
downloadcuberite-9eed83c33ae8c2bbb1781a01f05326dba667f4e3.tar
cuberite-9eed83c33ae8c2bbb1781a01f05326dba667f4e3.tar.gz
cuberite-9eed83c33ae8c2bbb1781a01f05326dba667f4e3.tar.bz2
cuberite-9eed83c33ae8c2bbb1781a01f05326dba667f4e3.tar.lz
cuberite-9eed83c33ae8c2bbb1781a01f05326dba667f4e3.tar.xz
cuberite-9eed83c33ae8c2bbb1781a01f05326dba667f4e3.tar.zst
cuberite-9eed83c33ae8c2bbb1781a01f05326dba667f4e3.zip
Diffstat (limited to 'source/cNoteEntity.cpp')
-rw-r--r--source/cNoteEntity.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/cNoteEntity.cpp b/source/cNoteEntity.cpp
index 44f911dc4..f007433fc 100644
--- a/source/cNoteEntity.cpp
+++ b/source/cNoteEntity.cpp
@@ -37,6 +37,8 @@ void cNoteEntity::UsedBy( cPlayer * a_Player )
void cNoteEntity::MakeSound( void )
{
char instrument;
+ AString sampleName;
+
switch (m_World->GetBlock(m_PosX, m_PosY - 1, m_PosZ))
{
case E_BLOCK_PLANKS:
@@ -45,6 +47,7 @@ void cNoteEntity::MakeSound( void )
{
// TODO: add other wood-based blocks if needed
instrument = E_INST_DOUBLE_BASS;
+ sampleName = "note.db";
break;
}
@@ -53,6 +56,7 @@ void cNoteEntity::MakeSound( void )
case E_BLOCK_SOULSAND:
{
instrument = E_INST_SNARE_DRUM;
+ sampleName = "note.snare";
break;
}
@@ -61,6 +65,7 @@ void cNoteEntity::MakeSound( void )
case E_BLOCK_GLOWSTONE:
{
instrument = E_INST_CLICKS;
+ sampleName = "note.hat";
break;
}
@@ -74,17 +79,23 @@ void cNoteEntity::MakeSound( void )
{
// TODO: add other stone-based blocks if needed
instrument = E_INST_BASS_DRUM;
+ sampleName = "note.bassattack";
break;
}
default:
{
instrument = E_INST_HARP_PIANO;
+ sampleName = "note.harp";
break;
}
}
m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, instrument, m_Pitch, E_BLOCK_NOTE_BLOCK);
+
+ // TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all
+ float calcPitch = pow(2.0f, ((float)m_Pitch - 12.0f) / 12.0f);
+ m_World->BroadcastSoundEffect(sampleName, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 3.0f, calcPitch);
}