diff options
author | Julian Laubstein <julianlaubstein@yahoo.de> | 2015-11-24 15:43:05 +0100 |
---|---|---|
committer | Julian Laubstein <julianlaubstein@yahoo.de> | 2015-11-24 15:43:05 +0100 |
commit | 412e5155a24339aa2a86f36e0ae5a9c5a0ff758d (patch) | |
tree | d63858a16962f83d68620bc55c8efeed126874a6 /src | |
parent | Merge pull request #2645 from Gargaj/followedarray (diff) | |
parent | Add enum for Sound and Particle Effects (diff) | |
download | cuberite-412e5155a24339aa2a86f36e0ae5a9c5a0ff758d.tar cuberite-412e5155a24339aa2a86f36e0ae5a9c5a0ff758d.tar.gz cuberite-412e5155a24339aa2a86f36e0ae5a9c5a0ff758d.tar.bz2 cuberite-412e5155a24339aa2a86f36e0ae5a9c5a0ff758d.tar.lz cuberite-412e5155a24339aa2a86f36e0ae5a9c5a0ff758d.tar.xz cuberite-412e5155a24339aa2a86f36e0ae5a9c5a0ff758d.tar.zst cuberite-412e5155a24339aa2a86f36e0ae5a9c5a0ff758d.zip |
Diffstat (limited to '')
31 files changed, 124 insertions, 56 deletions
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 3a93e85a1..211bf8662 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -6,6 +6,7 @@ #include "Globals.h" #include "DropSpenserEntity.h" +#include "../EffectID.h" #include "../Entities/Player.h" #include "../Chunk.h" #include "../UI/DropSpenserWindow.h" @@ -89,14 +90,14 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) int SmokeDir = 0; switch (Meta) { - case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) - case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break; - case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break; - case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break; - case E_META_DROPSPENSER_FACING_ZM: SmokeDir = 1; break; - case E_META_DROPSPENSER_FACING_ZP: SmokeDir = 7; break; + case E_META_DROPSPENSER_FACING_YP: SmokeDir = static_cast<int>(SmokeDirection::CENTRE); break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) + case E_META_DROPSPENSER_FACING_YM: SmokeDir = static_cast<int>(SmokeDirection::CENTRE); break; + case E_META_DROPSPENSER_FACING_XM: SmokeDir = static_cast<int>(SmokeDirection::EAST); break; + case E_META_DROPSPENSER_FACING_XP: SmokeDir = static_cast<int>(SmokeDirection::WEST); break; + case E_META_DROPSPENSER_FACING_ZM: SmokeDir = static_cast<int>(SmokeDirection::SOUTH); break; + case E_META_DROPSPENSER_FACING_ZP: SmokeDir = static_cast<int>(SmokeDirection::NORTH); break; } - m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir); + m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, m_PosX, m_PosY, m_PosZ, SmokeDir); m_World->BroadcastSoundEffect("random.click", static_cast<double>(m_PosX), static_cast<double>(m_PosY), static_cast<double>(m_PosZ), 1.0f, 1.0f); } diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp index 3a2d9f37c..1f3f4f324 100644 --- a/src/BlockEntities/JukeboxEntity.cpp +++ b/src/BlockEntities/JukeboxEntity.cpp @@ -3,6 +3,7 @@ #include "JukeboxEntity.h" #include "../World.h" +#include "../EffectID.h" #include "json/value.h" #include "Entities/Player.h" @@ -60,7 +61,7 @@ bool cJukeboxEntity::PlayRecord(int a_Record) EjectRecord(); } m_Record = a_Record; - m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, m_Record); + m_World->BroadcastSoundParticleEffect(EffectID::SFX_PLAY_MUSIC_DISC, m_PosX, m_PosY, m_PosZ, m_Record); m_World->SetBlockMeta(m_PosX, m_PosY, m_PosZ, E_META_JUKEBOX_ON); return true; } @@ -81,7 +82,7 @@ bool cJukeboxEntity::EjectRecord(void) Drops.push_back(cItem(static_cast<short>(m_Record), 1, 0)); m_Record = 0; m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8); - m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0); + m_World->BroadcastSoundParticleEffect(EffectID::SFX_PLAY_MUSIC_DISC, m_PosX, m_PosY, m_PosZ, 0); m_World->SetBlockMeta(m_PosX, m_PosY, m_PosZ, E_META_JUKEBOX_OFF); return true; } diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp index 1a0ce5b22..4418dca15 100644 --- a/src/BlockEntities/MobSpawnerEntity.cpp +++ b/src/BlockEntities/MobSpawnerEntity.cpp @@ -173,7 +173,7 @@ void cMobSpawnerEntity::SpawnEntity(void) { EntitiesSpawned = true; Chunk->BroadcastSoundParticleEffect( - 2004, + EffectID::PARTICLE_MOBSPAWN, static_cast<int>(PosX * 8.0), static_cast<int>(RelY * 8.0), static_cast<int>(PosZ * 8.0), diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index af50834ef..30a8b8386 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -1,6 +1,7 @@ #include "Globals.h" #include "BlockDoor.h" +#include "../EffectID.h" #include "../Entities/Player.h" @@ -64,7 +65,7 @@ void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterfac case E_BLOCK_OAK_DOOR: { ChangeDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); + a_Player->GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); break; } // Prevent iron door from opening on player click diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h index 81e93fa50..241771a90 100644 --- a/src/Blocks/BlockFenceGate.h +++ b/src/Blocks/BlockFenceGate.h @@ -3,6 +3,7 @@ #include "BlockHandler.h" #include "MetaRotator.h" +#include "../EffectID.h" @@ -49,7 +50,7 @@ public: // Standing aside - use last direction a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, OldMetaData); } - a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); + a_Player->GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); } virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h index f7f83a61d..4c5cb410b 100644 --- a/src/Blocks/BlockTrapdoor.h +++ b/src/Blocks/BlockTrapdoor.h @@ -3,6 +3,7 @@ #include "BlockHandler.h" #include "MetaRotator.h" +#include "../EffectID.h" @@ -40,7 +41,7 @@ public: a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); cWorld * World = static_cast<cWorld *>(&a_WorldInterface); - World->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); + World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); } virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9bc756eef..53f207a54 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -107,6 +107,7 @@ SET (HDRS Cuboid.h DeadlockDetect.h Defines.h + EffectID.h Enchantments.h Endianness.h FastRandom.h diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 71e9fb76c..e1edc0167 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -3138,7 +3138,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, doubl -void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) +void cChunk::BroadcastSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) { for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { diff --git a/src/Chunk.h b/src/Chunk.h index 60fbafa94..ca818a378 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -342,7 +342,7 @@ public: void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = nullptr); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = nullptr); void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr); - void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr); + void BroadcastSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr); void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 2c9831e08..435a53595 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -656,7 +656,7 @@ void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, do -void cChunkMap::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) +void cChunkMap::BroadcastSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) { cCSLock Lock(m_CSLayers); int ChunkX, ChunkZ; diff --git a/src/ChunkMap.h b/src/ChunkMap.h index e229d108c..6148d0a82 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -7,6 +7,7 @@ #include "ChunkDataCallback.h" +#include "EffectID.h" @@ -91,7 +92,7 @@ public: void BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = nullptr); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = nullptr); void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr); - void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr); + void BroadcastSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr); void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr); void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 8897063a0..28fc6756b 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -7,6 +7,7 @@ #include "Bindings/PluginManager.h" #include "Entities/Player.h" #include "Inventory.h" +#include "EffectID.h" #include "BlockEntities/BeaconEntity.h" #include "BlockEntities/ChestEntity.h" #include "BlockEntities/CommandBlockEntity.h" @@ -1236,7 +1237,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo // The ItemHandler is also responsible for spawning the pickups cChunkInterface ChunkInterface(World->GetChunkMap()); BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ); - World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); + World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta); @@ -2696,7 +2697,7 @@ void cClientHandle::SendSoundEffect(const AString & a_SoundName, double a_X, dou -void cClientHandle::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) +void cClientHandle::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) { m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 32e894d41..d7468d345 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -20,6 +20,7 @@ #include "UI/SlotArea.h" #include "json/json.h" #include "ChunkSender.h" +#include "EffectID.h" #include <array> @@ -204,7 +205,7 @@ public: // tolua_export void SendSetTitle (const cCompositeChat & a_Title); void SendSetRawTitle (const AString & a_Title); void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch); // tolua_export - void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data); + void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data); void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock); void SendSpawnMob (const cMonster & a_Mob); void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch); diff --git a/src/EffectID.h b/src/EffectID.h new file mode 100644 index 000000000..2050a9d49 --- /dev/null +++ b/src/EffectID.h @@ -0,0 +1,49 @@ +#pragma once + +enum class EffectID : Int32 +{ + SFX_RANDOM_CLICK_1 = 1000, + SFX_RANDOM_CLICK_2 = 1001, + SFX_RANDOM_BOW = 1002, + SFX_RANDOM_DOOR_OPEN_CLOSE = 1003, + SFX_RANDOM_FIZZ = 1004, + SFX_PLAY_MUSIC_DISC = 1005, + // NOT ASSIGNED = 1006 + SFX_MOB_GHAST_CHARGE = 1007, + SFX_MOB_GHAST_FIREBALL = 1008, + SFX_MOB_GHAST_FIREBALL_LOW = 1009, + SFX_MOB_ZOMBIE_WOOD = 1010, + SFX_MOB_ZOMBIE_METAL = 1011, + SFX_MOB_ZOMBIE_WOOD_BREAK = 1012, + SFX_MOB_WITHER_SPAWN = 1013, + SFX_MOB_WITHER_SHOOT = 1014, + SFX_MOB_BAT_TAKEOFF = 1015, + SFX_MOB_ZOMBIE_INFECT = 1016, + SFX_MOB_ZOMBIE_UNFECT = 1017, + SFX_MOB_ENDERDRAGON_END = 1018, + // NOT ASSIGNED = 1019 + SFX_RANDOM_ANVIL_BREAK = 1020, + SFX_RANDOM_ANVIL_USE = 1021, + SFX_RANDOM_ANVIL_LAND = 1022, + + PARTICLE_SMOKE = 2000, + PARTICLE_BLOCK_BREAK = 2001, + PARTICLE_SPLASH_POTION = 2002, + PARTICLE_EYE_OF_ENDER = 2003, + PARTICLE_MOBSPAWN = 2004, + PARTICLE_HAPPY_VILLAGER = 2005, + PARTICLE_FALL_PARTICLES = 2006, +}; + +enum class SmokeDirection : Int32 +{ + SOUTH_EAST = 0, + SOUTH = 1, + SOUTH_WEST = 2, + EAST = 3, + CENTRE = 4, + WEST = 5, + NORTH_EAST = 6, + NORTH = 7, + NORTH_WEST = 8, +}; diff --git a/src/Entities/ExpBottleEntity.cpp b/src/Entities/ExpBottleEntity.cpp index ee142a5a2..b76df923a 100644 --- a/src/Entities/ExpBottleEntity.cpp +++ b/src/Entities/ExpBottleEntity.cpp @@ -2,6 +2,7 @@ #include "ExpBottleEntity.h" #include "../World.h" +#include "../EffectID.h" @@ -38,7 +39,7 @@ void cExpBottleEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit void cExpBottleEntity::Break(const Vector3d &a_HitPos) { // Spawn an experience orb with a reward between 3 and 11. - m_World->BroadcastSoundParticleEffect(2002, POSX_TOINT, POSY_TOINT, POSZ_TOINT, 0); + m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SPLASH_POTION, POSX_TOINT, POSY_TOINT, POSZ_TOINT, 0); m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), 3 + m_World->GetTickRandomNumber(8)); Destroy(); } diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 9d855dfa6..ba806e50e 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -3,6 +3,7 @@ #include "SplashPotionEntity.h" #include "Pawn.h" #include "../ClientHandle.h" +#include "../EffectID.h" @@ -121,7 +122,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) m_World->ForEachEntity(Callback); m_World->BroadcastSoundParticleEffect( - 2002, + EffectID::PARTICLE_SPLASH_POTION, FloorC(a_HitPos.x), FloorC(a_HitPos.y), FloorC(a_HitPos.z), diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index ce3bd65eb..8b76d7c50 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -2,6 +2,7 @@ #include "Horse.h" #include "../World.h" +#include "../EffectID.h" #include "../Entities/Player.h" @@ -55,10 +56,10 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { if (m_World->GetTickRandomNumber(50) == 25) { - m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 0); - m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 2); - m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 6); - m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 8); + m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), int(SmokeDirection::SOUTH_EAST)); + m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), int(SmokeDirection::SOUTH_WEST)); + m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), int(SmokeDirection::NORTH_EAST)); + m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), int(SmokeDirection::NORTH_WEST)); m_Attachee->Detach(); m_bIsRearing = true; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 99909aa66..060b934ec 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -6,6 +6,7 @@ #include "../Server.h" #include "../ClientHandle.h" #include "../World.h" +#include "../EffectID.h" #include "../Entities/Player.h" #include "../Entities/ExpOrb.h" #include "../MonsterConfig.h" @@ -573,7 +574,7 @@ void cMonster::HandleFalling() TakeDamage(dtFalling, nullptr, Damage, Damage, 0); // Fall particles - GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */); + GetWorld()->BroadcastSoundParticleEffect(EffectID::PARTICLE_FALL_PARTICLES, POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */); } m_LastGroundHeight = POSY_TOINT; diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index dcfef8135..5f763508b 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -5,6 +5,7 @@ #include "../BlockID.h" #include "../Entities/Player.h" #include "../World.h" +#include "../EffectID.h" #include "FastRandom.h" @@ -107,7 +108,7 @@ void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { // The sheep ate the grass so we change it to dirt m_World->SetBlock(PosX, PosY, PosZ, E_BLOCK_DIRT, 0); - GetWorld()->BroadcastSoundParticleEffect(2001, PosX, PosY, PosX, E_BLOCK_GRASS); + GetWorld()->BroadcastSoundParticleEffect(EffectID::PARTICLE_BLOCK_BREAK, PosX, PosY, PosX, E_BLOCK_GRASS); m_IsSheared = false; m_World->BroadcastEntityMetadata(*this); } diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 4581da6a9..af0485a78 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -15,6 +15,7 @@ #include "../Scoreboard.h" #include "../Map.h" #include "../ByteBuffer.h" +#include "../EffectID.h" #include <array> @@ -123,7 +124,7 @@ public: virtual void SendSetTitle (const cCompositeChat & a_Title) = 0; virtual void SendSetRawTitle (const AString & a_Title) = 0; virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) = 0; - virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0; + virtual void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0; virtual void SendSpawnMob (const cMonster & a_Mob) = 0; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 08ff4b268..010e1a8ba 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1163,13 +1163,13 @@ void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, doub -void cProtocol172::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) +void cProtocol172::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) { ASSERT(m_State == 3); // In game mode? ASSERT((a_SrcY >= 0) && (a_SrcY < 256)); cPacketizer Pkt(*this, 0x28); // Effect packet - Pkt.WriteBEInt32(a_EffectID); + Pkt.WriteBEInt32(static_cast<int>(a_EffectID)); Pkt.WriteBEInt32(a_SrcX); Pkt.WriteBEUInt8(static_cast<Byte>(a_SrcY)); Pkt.WriteBEInt32(a_SrcZ); diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index cc201f840..747ffe186 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -121,7 +121,7 @@ public: virtual void SendSetTitle (const cCompositeChat & a_Title) override; virtual void SendSetRawTitle (const AString & a_Title) override; virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; - virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; + virtual void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 15dd085be..17b4dc6fd 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -19,6 +19,7 @@ Implements the 1.8.x protocol classes: #include "../Root.h" #include "../Server.h" #include "../World.h" +#include "../EffectID.h" #include "../StringCompression.h" #include "../CompositeChat.h" #include "../Statistics.h" @@ -1234,12 +1235,12 @@ void cProtocol180::SendSoundEffect(const AString & a_SoundName, double a_X, doub -void cProtocol180::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) +void cProtocol180::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) { ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x28); // Effect packet - Pkt.WriteBEInt32(a_EffectID); + Pkt.WriteBEInt32(static_cast<int>(a_EffectID)); Pkt.WritePosition64(a_SrcX, a_SrcY, a_SrcZ); Pkt.WriteBEInt32(a_Data); Pkt.WriteBool(false); diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h index aa73a4a6a..8b5b7ffa2 100644 --- a/src/Protocol/Protocol18x.h +++ b/src/Protocol/Protocol18x.h @@ -120,7 +120,7 @@ public: virtual void SendSetRawSubTitle (const AString & a_SubTitle) override; virtual void SendSetTitle (const cCompositeChat & a_Title) override; virtual void SendSetRawTitle (const AString & a_Title) override; - virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; + virtual void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 845e7b56d..c88bd8639 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -709,7 +709,7 @@ void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, double a_ -void cProtocolRecognizer::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) +void cProtocolRecognizer::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) { ASSERT(m_Protocol != nullptr); m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 7b5952bea..c548ad5ba 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -108,7 +108,7 @@ public: virtual void SendSetTitle (const cCompositeChat & a_Title) override; virtual void SendSetRawTitle (const AString & a_Title) override; virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; - virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; + virtual void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 43f38584e..fc3dc0a73 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -444,7 +444,7 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBl if ((MetaData & 0x4) == 0) { m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData | 0x4); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + m_Chunk->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, BlockX, a_RelBlockY, BlockZ, 0); } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } @@ -456,7 +456,7 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBl if ((MetaData & 0x4) != 0) { m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData & ~0x04); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + m_Chunk->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, BlockX, a_RelBlockY, BlockZ, 0); } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } @@ -973,7 +973,7 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, if (!DoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ)) { DoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, true); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + m_Chunk->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, BlockX, a_RelBlockY, BlockZ, 0); } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } @@ -986,7 +986,7 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, if (DoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ)) { DoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, false); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + m_Chunk->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, BlockX, a_RelBlockY, BlockZ, 0); } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index 70dde8cc0..2ced0cb83 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -8,6 +8,7 @@ #include "../Entities/FallingBlock.h" #include "../Chunk.h" #include "../IniFile.h" +#include "../EffectID.h" @@ -258,7 +259,7 @@ void cSandSimulator::FinishFalling( a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FallingBlockType, a_FallingBlockMeta); if (a_FallingBlockType == E_BLOCK_ANVIL) { - a_World->BroadcastSoundParticleEffect(1022, a_BlockX, a_BlockY, a_BlockZ, 0); + a_World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_ANVIL_LAND, a_BlockX, a_BlockY, a_BlockZ, 0); } return; } diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 2c0dfbe40..c7b8d0987 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -20,6 +20,7 @@ #include "../Root.h" #include "../FastRandom.h" #include "../BlockArea.h" +#include "../EffectID.h" @@ -1004,18 +1005,18 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) { // Anvil will break a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0); - a_Player.GetWorld()->BroadcastSoundParticleEffect(1020, PosX, PosY, PosZ, 0); + a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_ANVIL_BREAK, PosX, PosY, PosZ, 0); a_Player.CloseWindow(false); } else { a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, static_cast<NIBBLETYPE>(Orientation | (AnvilDamage << 2))); - a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0); + a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_ANVIL_USE, PosX, PosY, PosZ, 0); } } else { - a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0); + a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_ANVIL_USE, PosX, PosY, PosZ, 0); } } diff --git a/src/World.cpp b/src/World.cpp index 8629050b1..e21b79371 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1648,7 +1648,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX, a_BlockY, a_BlockZ, 0); } return BlockMeta == 7; } @@ -1662,7 +1662,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy { GrowState++; FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, static_cast<NIBBLETYPE>(GrowState << 2 | TypeMeta)); - BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX, a_BlockY, a_BlockZ, 0); } return GrowState == 2; } @@ -1685,7 +1685,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX, a_BlockY, a_BlockZ, 0); } return BlockMeta == 7; } @@ -1709,7 +1709,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX, a_BlockY, a_BlockZ, 0); } else { @@ -1740,7 +1740,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX, a_BlockY, a_BlockZ, 0); } return BlockMeta == 7; } @@ -1764,7 +1764,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX, a_BlockY, a_BlockZ, 0); } else { @@ -1799,7 +1799,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, static_cast<NIBBLETYPE>(GrowState << 3 | TypeMeta)); - BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX, a_BlockY, a_BlockZ, 0); } else if (random.NextInt(99) < 45) { @@ -1846,7 +1846,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy } } // switch (random spawn block type) FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, SpawnType, SpawnMeta); - BroadcastSoundParticleEffect(2005, a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, 0); + BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, 0); } // for i - 50 times return true; } @@ -2530,7 +2530,7 @@ void cWorld::BroadcastSoundEffect(const AString & a_SoundName, double a_X, doubl -void cWorld::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) +void cWorld::BroadcastSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) { m_ChunkMap->BroadcastSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data, a_Exclude); } @@ -3231,7 +3231,7 @@ bool cWorld::SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Op if (a_Open != IsOpen) { SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta ^ 0x4); - BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0); + BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, a_BlockX, a_BlockY, a_BlockZ, 0); return true; } return false; diff --git a/src/World.h b/src/World.h index 512654ab8..5f1ce393b 100644 --- a/src/World.h +++ b/src/World.h @@ -27,6 +27,7 @@ #include "Blocks/BroadcastInterface.h" #include "FastRandom.h" #include "ClientHandle.h" +#include "EffectID.h" #include <functional> @@ -210,7 +211,7 @@ public: void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode); void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display); void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) override; // tolua_export - void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr); // tolua_export + void BroadcastSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr); // tolua_export void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr); void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); |