summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Server/Plugins/APIDump/APIDesc.lua25
-rw-r--r--Server/Plugins/APIDump/Classes/World.lua73
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp4
-rw-r--r--src/BlockEntities/NoteEntity.cpp6
-rw-r--r--src/Blocks/BlockButton.h4
-rw-r--r--src/Blocks/BlockFence.h2
-rw-r--r--src/Blocks/BlockLever.h2
-rw-r--r--src/Blocks/BlockPiston.cpp8
-rw-r--r--src/Blocks/BroadcastInterface.h2
-rw-r--r--src/Chunk.cpp12
-rw-r--r--src/Chunk.h6
-rw-r--r--src/ChunkMap.cpp20
-rw-r--r--src/ChunkMap.h6
-rw-r--r--src/ClientHandle.cpp12
-rw-r--r--src/ClientHandle.h1
-rw-r--r--src/Entities/ArrowEntity.cpp6
-rw-r--r--src/Entities/ExpOrb.cpp2
-rw-r--r--src/Entities/Floater.cpp2
-rw-r--r--src/Entities/LeashKnot.cpp4
-rw-r--r--src/Entities/Pickup.cpp2
-rw-r--r--src/Entities/Player.cpp2
-rw-r--r--src/Items/ItemBow.h4
-rw-r--r--src/Items/ItemHoe.h2
-rw-r--r--src/Items/ItemLighter.h4
-rw-r--r--src/Items/ItemThrowable.h2
-rw-r--r--src/Mobs/Creeper.cpp4
-rw-r--r--src/Mobs/Horse.cpp4
-rw-r--r--src/Mobs/Monster.cpp4
-rw-r--r--src/Mobs/Sheep.cpp2
-rw-r--r--src/Simulator/FloodyFluidSimulator.cpp8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h2
-rw-r--r--src/Simulator/VaporizeFluidSimulator.cpp8
-rw-r--r--src/UI/ChestWindow.cpp20
-rw-r--r--src/UI/ChestWindow.h2
-rw-r--r--src/UI/EnderChestWindow.cpp16
-rw-r--r--src/UI/EnderChestWindow.h2
-rw-r--r--src/UI/MinecartWithChestWindow.h4
-rw-r--r--src/World.cpp48
-rw-r--r--src/World.h9
39 files changed, 232 insertions, 114 deletions
diff --git a/Server/Plugins/APIDump/APIDesc.lua b/Server/Plugins/APIDump/APIDesc.lua
index 334fed378..1548cf97d 100644
--- a/Server/Plugins/APIDump/APIDesc.lua
+++ b/Server/Plugins/APIDump/APIDesc.lua
@@ -1641,6 +1641,29 @@ end
Type = "string",
},
{
+ Name = "Position",
+ Type = "Vector3d",
+ },
+ {
+ Name = "Volume",
+ Type = "number",
+ },
+ {
+ Name = "Pitch",
+ Type = "number",
+ },
+ },
+ Notes = "Sends a sound effect request to the client. The sound is played at the specified coords, with the specified volume (a float, 1.0 is full volume, can be more) and pitch (0-255, 63 is 100%)",
+ },
+ SendSoundEffect =
+ {
+ Params =
+ {
+ {
+ Name = "SoundName",
+ Type = "string",
+ },
+ {
Name = "X",
Type = "number",
},
@@ -1661,7 +1684,7 @@ end
Type = "number",
},
},
- Notes = "Sends a sound effect request to the client. The sound is played at the specified coords, with the specified volume (a float, 1.0 is full volume, can be more) and pitch (0-255, 63 is 100%)",
+ Notes = "Sends a sound effect request to the client. The sound is played at the specified coords, with the specified volume (a float, 1.0 is full volume, can be more) and pitch (0-255, 63 is 100%) (DEPRECATED, use vector-parametered version instead)",
},
SendTitleTimes =
{
diff --git a/Server/Plugins/APIDump/Classes/World.lua b/Server/Plugins/APIDump/Classes/World.lua
index 82f31febe..648bf5aa4 100644
--- a/Server/Plugins/APIDump/Classes/World.lua
+++ b/Server/Plugins/APIDump/Classes/World.lua
@@ -51,6 +51,34 @@ return
Params =
{
{
+ Name = "BlockPos",
+ Type = "Vector3i",
+ },
+ {
+ Name = "ActionByte1",
+ Type = "number",
+ },
+ {
+ Name = "ActionByte2",
+ Type = "number",
+ },
+ {
+ Name = "BlockType",
+ Type = "number",
+ },
+ {
+ Name = "ExcludeClient",
+ Type = "cClientHandle",
+ IsOptional = true,
+ },
+ },
+ Notes = "Broadcasts the BlockAction packet to all clients who have the appropriate chunk loaded (except ExcludeClient). The contents of the packet are specified by the parameters for the call, the blocktype needn't match the actual block that is present in the world data at the specified location.",
+ },
+ BroadcastBlockAction =
+ {
+ Params =
+ {
+ {
Name = "BlockX",
Type = "number",
},
@@ -80,7 +108,7 @@ return
IsOptional = true,
},
},
- Notes = "Broadcasts the BlockAction packet to all clients who have the appropriate chunk loaded (except ExcludeClient). The contents of the packet are specified by the parameters for the call, the blocktype needn't match the actual block that is present in the world data at the specified location.",
+ Notes = "Broadcasts the BlockAction packet to all clients who have the appropriate chunk loaded (except ExcludeClient). The contents of the packet are specified by the parameters for the call, the blocktype needn't match the actual block that is present in the world data at the specified location. (DEPRECATED)",
},
BroadcastChat =
{
@@ -276,6 +304,34 @@ return
Type = "string",
},
{
+ Name = "Position",
+ Type = "Vector3d",
+ },
+ {
+ Name = "Volume",
+ Type = "number",
+ },
+ {
+ Name = "Pitch",
+ Type = "number",
+ },
+ {
+ Name = "ExcludeClient",
+ Type = "cClientHandle",
+ IsOptional = true,
+ },
+ },
+ Notes = "Sends the specified sound effect to all players in this world, except the optional ExceptClient",
+ },
+ BroadcastSoundEffect =
+ {
+ Params =
+ {
+ {
+ Name = "SoundName",
+ Type = "string",
+ },
+ {
Name = "X",
Type = "number",
},
@@ -301,7 +357,7 @@ return
IsOptional = true,
},
},
- Notes = "Sends the specified sound effect to all players in this world, except the optional ExceptClient",
+ Notes = "Sends the specified sound effect to all players in this world, except the optional ExceptClient (DEPRECATED, use vector-parametered version instead)",
},
BroadcastSoundParticleEffect =
{
@@ -340,6 +396,17 @@ return
Params =
{
{
+ Name = "Position",
+ Type = "Vector3d",
+ },
+ },
+ Notes = "Creates a thunderbolt at the specified coords",
+ },
+ CastThunderbolt =
+ {
+ Params =
+ {
+ {
Name = "X",
Type = "number",
},
@@ -352,7 +419,7 @@ return
Type = "number",
},
},
- Notes = "Creates a thunderbolt at the specified coords",
+ Notes = "Creates a thunderbolt at the specified coords (DEPRECATED, use vector-parametered version instead)",
},
ChangeWeather =
{
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index 34c7857b0..df825c995 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -75,7 +75,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
if (SlotsCnt == 0)
{
// Nothing in the dropspenser, play the click sound
- m_World->BroadcastSoundEffect("block.dispenser.fail", static_cast<double>(m_PosX), static_cast<double>(m_PosY), static_cast<double>(m_PosZ), 1.0f, 1.2f);
+ m_World->BroadcastSoundEffect("block.dispenser.fail", Vector3d(m_PosX, m_PosY, m_PosZ), 1.0f, 1.2f);
return;
}
@@ -97,7 +97,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
case E_META_DROPSPENSER_FACING_ZP: SmokeDir = static_cast<int>(SmokeDirection::NORTH); break;
}
m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, m_PosX, m_PosY, m_PosZ, SmokeDir);
- m_World->BroadcastSoundEffect("block.dispenser.dispense", static_cast<double>(m_PosX), static_cast<double>(m_PosY), static_cast<double>(m_PosZ), 1.0f, 1.0f);
+ m_World->BroadcastSoundEffect("block.dispenser.dispense", Vector3d(m_PosX, m_PosY, m_PosZ), 1.0f, 1.0f);
}
diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp
index a3638164d..ca8c2c03d 100644
--- a/src/BlockEntities/NoteEntity.cpp
+++ b/src/BlockEntities/NoteEntity.cpp
@@ -243,15 +243,13 @@ void cNoteEntity::MakeSound(void)
}
}
- m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, static_cast<Byte>(instrument), static_cast<Byte>(m_Pitch), E_BLOCK_NOTE_BLOCK);
+ m_World->BroadcastBlockAction({m_PosX, m_PosY, m_PosZ}, static_cast<Byte>(instrument), static_cast<Byte>(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 = static_cast<float>(pow(2.0f, static_cast<float>(m_Pitch - 12.0f) / 12.0f));
m_World->BroadcastSoundEffect(
sampleName,
- static_cast<double>(m_PosX),
- static_cast<double>(m_PosY),
- static_cast<double>(m_PosZ),
+ Vector3d(m_PosX, m_PosY, m_PosZ),
3.0f,
calcPitch
);
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 808c271b3..079f461ab 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -35,7 +35,7 @@ public:
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta, false);
a_WorldInterface.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.stone_button.click_on", x, y, z, 0.5f, 0.6f);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.stone_button.click_on", {x, y, z}, 0.5f, 0.6f);
// Queue a button reset (unpress)
auto TickDelay = (m_BlockType == E_BLOCK_STONE_BUTTON) ? 20 : 30;
@@ -46,7 +46,7 @@ public:
// Block hasn't change in the meantime; set its meta
a_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07, false);
a_World.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
- a_World.BroadcastSoundEffect("block.stone_button.click_off", x, y, z, 0.5f, 0.5f);
+ a_World.BroadcastSoundEffect("block.stone_button.click_off", {x, y, z}, 0.5f, 0.5f);
}
}
);
diff --git a/src/Blocks/BlockFence.h b/src/Blocks/BlockFence.h
index 63390cd37..1cccaa710 100644
--- a/src/Blocks/BlockFence.h
+++ b/src/Blocks/BlockFence.h
@@ -101,7 +101,7 @@ public:
{
return false;
}
- a_Player.GetWorld()->BroadcastSoundEffect("entity.leashknot.place", a_Player.GetPosX(), a_Player.GetPosY(), a_Player.GetPosZ(), 1, 1);
+ a_Player.GetWorld()->BroadcastSoundEffect("entity.leashknot.place", a_Player.GetPosition(), 1, 1);
}
else
{
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 7d6a1bc8b..1ec58c534 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -24,7 +24,7 @@ public:
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.lever.click", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.lever.click", Vector3d(a_BlockX, a_BlockY, a_BlockZ), 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
return true;
}
diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp
index 56d335044..c88263d9c 100644
--- a/src/Blocks/BlockPiston.cpp
+++ b/src/Blocks/BlockPiston.cpp
@@ -233,8 +233,8 @@ void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld & a_World)
return;
}
- a_World.BroadcastBlockAction(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 0, pistonMeta, pistonBlock);
- a_World.BroadcastSoundEffect("block.piston.extend", a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 0.5f, 0.7f);
+ a_World.BroadcastBlockAction(a_BlockPos, 0, pistonMeta, pistonBlock);
+ a_World.BroadcastSoundEffect("block.piston.extend", a_BlockPos, 0.5f, 0.7f);
PushBlocks(blocksPushed, a_World, pushDir);
@@ -277,8 +277,8 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World)
a_World.SetBlock(extensionPos.x, extensionPos.y, extensionPos.z, E_BLOCK_AIR, 0);
a_World.SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta & ~(8));
- a_World.BroadcastBlockAction(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 1, pistonMeta & ~(8), pistonBlock);
- a_World.BroadcastSoundEffect("block.piston.contract", a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 0.5f, 0.7f);
+ a_World.BroadcastBlockAction(a_BlockPos, 1, pistonMeta & ~(8), pistonBlock);
+ a_World.BroadcastSoundEffect("block.piston.contract", a_BlockPos, 0.5f, 0.7f);
if (!IsSticky(pistonBlock))
{
diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h
index e813be2a5..6943d5030 100644
--- a/src/Blocks/BroadcastInterface.h
+++ b/src/Blocks/BroadcastInterface.h
@@ -13,7 +13,7 @@ public:
virtual ~cBroadcastInterface() {}
virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
- virtual 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) = 0;
+ virtual void BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr) = 0;
};
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 8289d2a77..c29d9917e 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -2697,7 +2697,7 @@ void cChunk::BroadcastUnleashEntity(const cEntity & a_Entity)
-void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
+void cChunk::BroadcastBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@@ -2705,7 +2705,7 @@ void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char
{
continue;
}
- (*itr)->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
+ (*itr)->SendBlockAction(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Byte1, a_Byte2, a_BlockType);
} // for itr - LoadedByClient[]
}
@@ -2987,7 +2987,7 @@ void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI
-void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunk::BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@@ -2995,7 +2995,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, doubl
{
continue;
}
- (*itr)->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
+ (*itr)->SendSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch);
} // for itr - LoadedByClient[]
}
@@ -3035,7 +3035,7 @@ void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Ex
-void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cChunk::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
{
for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@@ -3043,7 +3043,7 @@ void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, cons
{
continue;
}
- (*itr)->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
+ (*itr)->SendThunderbolt(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
} // for itr - LoadedByClient[]
}
diff --git a/src/Chunk.h b/src/Chunk.h
index d1ce690a5..da5acffe7 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -340,7 +340,7 @@ public:
// Broadcast various packets to all clients of this chunk:
// (Please keep these alpha-sorted)
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle);
- void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
+ void BroadcastBlockAction (Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr);
@@ -359,10 +359,10 @@ public:
void BroadcastLeashEntity (const cEntity & a_Entity, const cEntity & a_EntityLeashedTo);
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 BroadcastSoundEffect (const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, 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 BroadcastThunderbolt (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr);
void BroadcastUnleashEntity (const cEntity & a_Entity);
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 8b98254c4..dff62f69d 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -305,12 +305,12 @@ void cChunkMap::BroadcastUnleashEntity(const cEntity & a_Entity)
-void cChunkMap::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSChunks);
int x, z, ChunkX, ChunkZ;
- x = a_BlockX;
- z = a_BlockZ;
+ x = a_BlockPos.x;
+ z = a_BlockPos.z;
cChunkDef::BlockToChunk(x, z, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
if (Chunk == nullptr)
@@ -318,7 +318,7 @@ void cChunkMap::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, c
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType, a_Exclude);
+ Chunk->BroadcastBlockAction(a_BlockPos, a_Byte1, a_Byte2, a_BlockType, a_Exclude);
}
@@ -605,19 +605,19 @@ void cChunkMap::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_Effe
-void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSChunks);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(FloorC(std::floor(a_X)), FloorC(std::floor(a_Z)), ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(FloorC(std::floor(a_Position.x)), FloorC(std::floor(a_Position.z)), ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
if (Chunk == nullptr)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude);
+ Chunk->BroadcastSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch, a_Exclude);
}
@@ -659,18 +659,18 @@ void cChunkMap::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a
-void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSChunks);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(a_BlockPos.x, a_BlockPos.z, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
if (Chunk == nullptr)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastThunderbolt(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
+ Chunk->BroadcastThunderbolt(a_BlockPos, a_Exclude);
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index ea542fb45..122e26ac1 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -71,7 +71,7 @@ public:
// Broadcast respective packets to all clients of the chunk where the event is taking place
// (Please keep these alpha-sorted)
void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle);
- void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
+ void BroadcastBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr);
@@ -90,10 +90,10 @@ public:
void BroadcastLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo);
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 BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, 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 BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr);
void BroadcastUnleashEntity(const cEntity & a_Entity);
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 e3bba6b08..967e90226 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2944,7 +2944,17 @@ void cClientHandle::SendSetRawTitle(const AString & a_Title)
void cClientHandle::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
- m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
+ LOG("SendSoundEffect with double args is deprecated, use version with vector position parameter.");
+ SendSoundEffect(a_SoundName, {a_X, a_Y, a_Z}, a_Volume, a_Pitch);
+}
+
+
+
+
+
+void cClientHandle::SendSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch)
+{
+ m_Protocol->SendSoundEffect(a_SoundName, a_Position.x, a_Position.y, a_Position.z, a_Volume, a_Pitch);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 630994c2e..8ded5a5ad 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -205,6 +205,7 @@ public: // tolua_export
void SendSetTitle (const cCompositeChat & a_Title); // tolua_export
void SendSetRawTitle (const AString & a_Title); // tolua_export
void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch); // tolua_export
+ void SendSoundEffect (const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch); // tolua_export
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);
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 2c1a1f005..4d104bd26 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -88,7 +88,7 @@ void cArrowEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
- m_World->BroadcastSoundEffect("entity.arrow.hit", static_cast<double>(X), static_cast<double>(Y), static_cast<double>(Z), 0.5f, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("entity.arrow.hit", BlockHit, 0.5f, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && IsOnFire())
{
@@ -129,7 +129,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
}
// Broadcast successful hit sound
- GetWorld()->BroadcastSoundEffect("entity.arrow.hit_player", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ GetWorld()->BroadcastSoundEffect("entity.arrow.hit_player", GetPosition(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
Destroy();
}
@@ -154,7 +154,7 @@ void cArrowEntity::CollectedBy(cPlayer & a_Dest)
}
GetWorld()->BroadcastCollectEntity(*this, a_Dest, 1);
- GetWorld()->BroadcastSoundEffect("entity.item.pickup", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ GetWorld()->BroadcastSoundEffect("entity.item.pickup", GetPosition(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
m_bIsCollected = true;
}
}
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 2d59206c2..4ae847bf8 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -61,7 +61,7 @@ void cExpOrb::Tick(std::chrono::milliseconds 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);
- m_World->BroadcastSoundEffect("entity.experience_orb.pickup", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("entity.experience_orb.pickup", GetPosition(), 0.5f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
Destroy(true);
return;
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index de5824068..4dc64cf53 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -112,7 +112,7 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if (m_CountDownTime <= 0)
{
m_BitePos = GetPosition();
- m_World->BroadcastSoundEffect("entity.bobber.splash", GetPosX(), GetPosY(), GetPosZ(), 1, 1);
+ m_World->BroadcastSoundEffect("entity.bobber.splash", GetPosition(), 1, 1);
SetPosY(GetPosY() - 1);
m_CanPickupItem = true;
m_PickupCountDown = 20;
diff --git a/src/Entities/LeashKnot.cpp b/src/Entities/LeashKnot.cpp
index c251f9e9d..971032329 100644
--- a/src/Entities/LeashKnot.cpp
+++ b/src/Entities/LeashKnot.cpp
@@ -84,7 +84,7 @@ void cLeashKnot::TiePlayersLeashedMobs(cPlayer & a_Player, bool a_ShouldBroadcas
void cLeashKnot::KilledBy(TakeDamageInfo & a_TDI)
{
super::KilledBy(a_TDI);
- m_World->BroadcastSoundEffect("entity.leashknot.break", GetPosX(), GetPosY(), GetPosZ(), 1, 1);
+ m_World->BroadcastSoundEffect("entity.leashknot.break", GetPosition(), 1, 1);
Destroy();
return;
}
@@ -131,7 +131,7 @@ void cLeashKnot::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if (m_TicksToSelfDestroy <= 0)
{
Destroy();
- m_World->BroadcastSoundEffect("entity.leashknot.break", GetPosX(), GetPosY(), GetPosZ(), 1, 1);
+ m_World->BroadcastSoundEffect("entity.leashknot.break", GetPosition(), 1, 1);
}
}
}
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index fcae586f6..26fe58252 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -248,7 +248,7 @@ bool cPickup::CollectedBy(cPlayer & a_Dest)
m_World->BroadcastCollectEntity(*this, a_Dest, NumAdded);
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
- m_World->BroadcastSoundEffect("entity.item.pickup", GetPosX(), GetPosY(), GetPosZ(), 0.5, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("entity.item.pickup", GetPosition(), 0.5, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
if (m_Item.m_ItemCount <= 0)
{
// All of the pickup has been collected, schedule the pickup for destroying
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 8ce577b8f..0769499b1 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2330,7 +2330,7 @@ void cPlayer::UseEquippedItem(int a_Amount)
if (GetInventory().DamageEquippedItem(static_cast<Int16>(a_Amount)))
{
- m_World->BroadcastSoundEffect("entity.item.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("entity.item.break", GetPosition(), 0.5f, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
}
}
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index 71f5bc378..241df0c3c 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -77,9 +77,7 @@ public:
}
a_Player->GetWorld()->BroadcastSoundEffect(
"entity.arrow.shoot",
- a_Player->GetPosX(),
- a_Player->GetPosY(),
- a_Player->GetPosZ(),
+ a_Player->GetPosition(),
0.5,
static_cast<float>(Force)
);
diff --git a/src/Items/ItemHoe.h b/src/Items/ItemHoe.h
index 9a9a2cc64..0bf2d4c4b 100644
--- a/src/Items/ItemHoe.h
+++ b/src/Items/ItemHoe.h
@@ -58,7 +58,7 @@ public:
}
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, NewBlock, 0);
- a_World->BroadcastSoundEffect("item.hoe.till", a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, 1.0f, 0.8f);
+ a_World->BroadcastSoundEffect("item.hoe.till", {a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5}, 1.0f, 0.8f);
a_Player->UseEquippedItem();
return true;
}
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 8b46ba011..5acc5551e 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -56,7 +56,7 @@ public:
case E_BLOCK_TNT:
{
// Activate the TNT:
- a_World->BroadcastSoundEffect("entity.tnt.primed", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0f, 1.0f);
+ a_World->BroadcastSoundEffect("entity.tnt.primed", Vector3d(a_BlockX, a_BlockY, a_BlockZ), 1.0f, 1.0f);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
a_World->SpawnPrimedTNT({a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5}); // 80 ticks to boom
break;
@@ -72,7 +72,7 @@ public:
if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- a_World->BroadcastSoundEffect("item.flintandsteel.use", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0F, 1.04F);
+ a_World->BroadcastSoundEffect("item.flintandsteel.use", Vector3d(a_BlockX, a_BlockY, a_BlockZ), 1.0F, 1.04F);
break;
}
}
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index 7bdba17cc..18dd9e801 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -36,7 +36,7 @@ public:
Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
// Play sound
- a_World->BroadcastSoundEffect("entity.arrow.shoot", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / GetRandomProvider().RandReal(0.8f, 1.2f));
+ a_World->BroadcastSoundEffect("entity.arrow.shoot", a_Player->GetPosition() - Vector3d(0, a_Player->GetHeight(), 0), 0.5f, 0.4f / GetRandomProvider().RandReal(0.8f, 1.2f));
if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) == cEntity::INVALID_ID)
{
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index adab8c5aa..aaf241dfb 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -127,7 +127,7 @@ bool cCreeper::Attack(std::chrono::milliseconds a_Dt)
if (!m_bIsBlowing)
{
- m_World->BroadcastSoundEffect("entity.creeper.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("entity.creeper.primed", GetPosition(), 1.f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
@@ -150,7 +150,7 @@ void cCreeper::OnRightClicked(cPlayer & a_Player)
{
a_Player.UseEquippedItem();
}
- m_World->BroadcastSoundEffect("entity.creeper.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("entity.creeper.primed", GetPosition(), 1.f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
m_BurnedWithFlintAndSteel = true;
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index 13630b0e3..c55acf572 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -70,7 +70,7 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
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_World->BroadcastSoundEffect("entity.horse.angry", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f);
+ m_World->BroadcastSoundEffect("entity.horse.angry", GetPosition(), 1.0f, 1.0f);
m_Attachee->Detach();
m_bIsRearing = true;
}
@@ -159,7 +159,7 @@ void cHorse::OnRightClicked(cPlayer & a_Player)
{
m_bIsRearing = true;
m_RearTickCount = 0;
- m_World->BroadcastSoundEffect("entity.horse.angry", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
+ m_World->BroadcastSoundEffect("entity.horse.angry", GetPosition(), 1.0f, 0.8f);
}
}
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 2ff1f74d8..db1150f67 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -557,7 +557,7 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
if (!m_SoundHurt.empty() && (m_Health > 0))
{
- m_World->BroadcastSoundEffect(m_SoundHurt, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
+ m_World->BroadcastSoundEffect(m_SoundHurt, GetPosition(), 1.0f, 0.8f);
}
if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPawn())
@@ -583,7 +583,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
super::KilledBy(a_TDI);
if (m_SoundHurt != "")
{
- m_World->BroadcastSoundEffect(m_SoundDeath, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
+ m_World->BroadcastSoundEffect(m_SoundDeath, GetPosition(), 1.0f, 0.8f);
}
int Reward;
switch (m_MobType)
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index fef1adac6..814c87f5d 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -67,7 +67,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
char NumDrops = GetRandomProvider().RandInt<char>(1, 3);
Drops.emplace_back(E_BLOCK_WOOL, NumDrops, static_cast<short>(m_WoolColor));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
- m_World->BroadcastSoundEffect("entity.sheep.shear", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f);
+ m_World->BroadcastSoundEffect("entity.sheep.shear", GetPosition(), 1.0f, 1.0f);
}
else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage))
{
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index d24b6aa9b..05b00c639 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -260,9 +260,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
a_NearChunk->BroadcastSoundEffect(
"block.lava.extinguish",
- static_cast<double>(BlockX),
- static_cast<double>(a_RelY),
- static_cast<double>(BlockZ),
+ Vector3d(BlockX, a_RelY, BlockZ),
0.5f,
1.5f
);
@@ -282,9 +280,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
a_NearChunk->BroadcastSoundEffect(
"block.lava.extinguish",
- static_cast<double>(BlockX),
- static_cast<double>(a_RelY),
- static_cast<double>(BlockZ),
+ Vector3d(BlockX, a_RelY, BlockZ),
0.5f,
1.5f
);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
index 6cea4501f..220d2537e 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
@@ -37,7 +37,7 @@ public:
// LOGD("Evaluating explodinator the trinitrotoluene (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
if (a_PoweringData.PowerLevel != 0)
{
- a_World.BroadcastSoundEffect("entity.tnt.primed", static_cast<double>(a_Position.x), static_cast<double>(a_Position.y), static_cast<double>(a_Position.z), 0.5f, 0.6f);
+ a_World.BroadcastSoundEffect("entity.tnt.primed", a_Position, 0.5f, 0.6f);
a_World.SetBlock(a_Position.x, a_Position.y, a_Position.z, E_BLOCK_AIR, 0);
a_World.SpawnPrimedTNT(a_Position + Vector3d(0.5, 0.5, 0.5)); // 80 ticks to boom
}
diff --git a/src/Simulator/VaporizeFluidSimulator.cpp b/src/Simulator/VaporizeFluidSimulator.cpp
index c023f88c9..873dbe177 100644
--- a/src/Simulator/VaporizeFluidSimulator.cpp
+++ b/src/Simulator/VaporizeFluidSimulator.cpp
@@ -37,9 +37,11 @@ void cVaporizeFluidSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk)
a_Chunk->SetBlock(RelX, a_Block.y, RelZ, E_BLOCK_AIR, 0);
a_Chunk->BroadcastSoundEffect(
"block.fire.extinguish",
- static_cast<double>(a_Block.x),
- static_cast<double>(a_Block.y),
- static_cast<double>(a_Block.z),
+ {
+ static_cast<double>(a_Block.x),
+ static_cast<double>(a_Block.y),
+ static_cast<double>(a_Block.z)
+ },
1.0f,
0.6f
);
diff --git a/src/UI/ChestWindow.cpp b/src/UI/ChestWindow.cpp
index 7b3fe15af..67582b786 100644
--- a/src/UI/ChestWindow.cpp
+++ b/src/UI/ChestWindow.cpp
@@ -16,9 +16,7 @@
cChestWindow::cChestWindow(cChestEntity * a_Chest) :
cWindow(wtChest, (a_Chest->GetBlockType() == E_BLOCK_CHEST) ? "Chest" : "Trapped Chest"),
m_World(a_Chest->GetWorld()),
- m_BlockX(a_Chest->GetPosX()),
- m_BlockY(a_Chest->GetPosY()),
- m_BlockZ(a_Chest->GetPosZ()),
+ m_BlockPos(a_Chest->GetPos()),
m_PrimaryChest(a_Chest),
m_SecondaryChest(nullptr)
{
@@ -27,10 +25,10 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("block.chest.open", static_cast<double>(m_BlockX), static_cast<double>(m_BlockY), static_cast<double>(m_BlockZ), 1, 1);
+ m_World->BroadcastSoundEffect("block.chest.open", m_BlockPos, 1, 1);
// Send out the chest-open packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType());
+ m_World->BroadcastBlockAction(m_BlockPos, 1, 1, a_Chest->GetBlockType());
}
@@ -40,9 +38,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) :
cWindow(wtChest, (a_PrimaryChest->GetBlockType() == E_BLOCK_CHEST) ? "Double Chest" : "Double Trapped Chest"),
m_World(a_PrimaryChest->GetWorld()),
- m_BlockX(a_PrimaryChest->GetPosX()),
- m_BlockY(a_PrimaryChest->GetPosY()),
- m_BlockZ(a_PrimaryChest->GetPosZ()),
+ m_BlockPos(a_PrimaryChest->GetPos()),
m_PrimaryChest(a_PrimaryChest),
m_SecondaryChest(a_SecondaryChest)
{
@@ -51,10 +47,10 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("block.chest.open", static_cast<double>(m_BlockX), static_cast<double>(m_BlockY), static_cast<double>(m_BlockZ), 1, 1);
+ m_World->BroadcastSoundEffect("block.chest.open", m_BlockPos, 1, 1);
// Send out the chest-open packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType());
+ m_World->BroadcastBlockAction(m_BlockPos, 1, 1, a_PrimaryChest->GetBlockType());
}
@@ -64,9 +60,9 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
cChestWindow::~cChestWindow()
{
// Send out the chest-close packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType());
+ m_World->BroadcastBlockAction(m_BlockPos, 1, 0, m_PrimaryChest->GetBlockType());
- m_World->BroadcastSoundEffect("block.chest.close", static_cast<double>(m_BlockX), static_cast<double>(m_BlockY), static_cast<double>(m_BlockZ), 1, 1);
+ m_World->BroadcastSoundEffect("block.chest.close", m_BlockPos, 1, 1);
}
diff --git a/src/UI/ChestWindow.h b/src/UI/ChestWindow.h
index 8fe165920..932f7a2ec 100644
--- a/src/UI/ChestWindow.h
+++ b/src/UI/ChestWindow.h
@@ -35,7 +35,7 @@ public:
protected:
cWorld * m_World;
- int m_BlockX, m_BlockY, m_BlockZ; // Position of the chest, for the window-close packet
+ Vector3i m_BlockPos; // Position of the chest, for the window-close packet
cChestEntity * m_PrimaryChest;
cChestEntity * m_SecondaryChest;
};
diff --git a/src/UI/EnderChestWindow.cpp b/src/UI/EnderChestWindow.cpp
index ed0fb499f..6c3bcff50 100644
--- a/src/UI/EnderChestWindow.cpp
+++ b/src/UI/EnderChestWindow.cpp
@@ -15,9 +15,7 @@
cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
cWindow(wtChest, "Ender Chest"),
m_World(a_EnderChest->GetWorld()),
- m_BlockX(a_EnderChest->GetPosX()),
- m_BlockY(a_EnderChest->GetPosY()),
- m_BlockZ(a_EnderChest->GetPosZ())
+ m_BlockPos(a_EnderChest->GetPos())
{
m_SlotAreas.push_back(new cSlotAreaEnderChest(a_EnderChest, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
@@ -26,15 +24,13 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
// Play the opening sound:
m_World->BroadcastSoundEffect(
"block.enderchest.open",
- static_cast<double>(m_BlockX),
- static_cast<double>(m_BlockY),
- static_cast<double>(m_BlockZ),
+ m_BlockPos,
1,
1
);
// Send out the chest-open packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST);
+ m_World->BroadcastBlockAction(m_BlockPos, 1, 1, E_BLOCK_ENDER_CHEST);
}
@@ -44,14 +40,12 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
cEnderChestWindow::~cEnderChestWindow()
{
// Send out the chest-close packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST);
+ m_World->BroadcastBlockAction(m_BlockPos, 1, 0, E_BLOCK_ENDER_CHEST);
// Play the closing sound
m_World->BroadcastSoundEffect(
"block.enderchest.close",
- static_cast<double>(m_BlockX),
- static_cast<double>(m_BlockY),
- static_cast<double>(m_BlockZ),
+ m_BlockPos,
1, 1
);
}
diff --git a/src/UI/EnderChestWindow.h b/src/UI/EnderChestWindow.h
index 05f8ca49f..b14c760e1 100644
--- a/src/UI/EnderChestWindow.h
+++ b/src/UI/EnderChestWindow.h
@@ -30,7 +30,7 @@ public:
protected:
cWorld * m_World;
- int m_BlockX, m_BlockY, m_BlockZ; // Position of the enderchest, for the window-close packet
+ Vector3i m_BlockPos; // Position of the enderchest, for the window-close packet
};
diff --git a/src/UI/MinecartWithChestWindow.h b/src/UI/MinecartWithChestWindow.h
index 2ce728399..80d1ebfce 100644
--- a/src/UI/MinecartWithChestWindow.h
+++ b/src/UI/MinecartWithChestWindow.h
@@ -30,7 +30,7 @@ public:
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
- a_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.open", a_ChestCart->GetPosX(), a_ChestCart->GetPosY(), a_ChestCart->GetPosZ(), 1, 1);
+ a_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.open", a_ChestCart->GetPosition(), 1, 1);
}
virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override
@@ -55,7 +55,7 @@ public:
virtual ~cMinecartWithChestWindow() override
{
- m_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.close", m_ChestCart->GetPosX(), m_ChestCart->GetPosY(), m_ChestCart->GetPosZ(), 1, 1);
+ m_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.close", m_ChestCart->GetPosition(), 1, 1);
}
private:
diff --git a/src/World.cpp b/src/World.cpp
index 11c6d28a3..c6bbf548a 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -233,10 +233,20 @@ cWorld::~cWorld()
-void cWorld::CastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ)
+void cWorld::CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
{
- BroadcastThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
- BroadcastSoundEffect("entity.lightning.thunder", a_BlockX, a_BlockY, a_BlockZ, 50, 1);
+ LOG("CastThunderbolt(int, int, int) is deprecated, use CastThunderbolt(Vector3i) instead");
+ CastThunderbolt({a_BlockX, a_BlockY, a_BlockZ});
+}
+
+
+
+
+
+void cWorld::CastThunderbolt(Vector3i a_Block)
+{
+ BroadcastThunderbolt(a_Block);
+ BroadcastSoundEffect("entity.lightning.thunder", a_Block, 50, 1);
}
@@ -1078,7 +1088,7 @@ void cWorld::TickWeather(float a_Dt)
// 0.5% chance per tick of thunderbolt
if (GetRandomProvider().RandBool(0.005))
{
- CastThunderbolt(0, 0, 0); // TODO: find random positions near players to cast thunderbolts.
+ CastThunderbolt({0, 0, 0}); // TODO: find random positions near players to cast thunderbolts.
}
}
}
@@ -1393,7 +1403,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo
Vector3d explosion_pos = Vector3d(a_BlockX, a_BlockY, a_BlockZ);
cVector3iArray BlocksAffected;
m_ChunkMap->DoExplosionAt(a_ExplosionSize, a_BlockX, a_BlockY, a_BlockZ, BlocksAffected);
- BroadcastSoundEffect("entity.generic.explode", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0f, 0.6f);
+ BroadcastSoundEffect("entity.generic.explode", Vector3d(a_BlockX, a_BlockY, a_BlockZ), 1.0f, 0.6f);
{
cCSLock Lock(m_CSPlayers);
@@ -2391,9 +2401,19 @@ void cWorld::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_V
+void cWorld::BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
+{
+ m_ChunkMap->BroadcastBlockAction(a_BlockPos, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType, a_Exclude);
+}
+
+
+
+
+
void cWorld::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType, a_Exclude);
+ LOG("BroadcastBlockAction with integer position is deprecated, use vector-parametered version instead.");
+ m_ChunkMap->BroadcastBlockAction({a_BlockX, a_BlockY, a_BlockZ}, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType, a_Exclude);
}
@@ -2742,9 +2762,19 @@ void cWorld::BroadcastDisplayObjective(const AString & a_Objective, cScoreboard:
+void cWorld::BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+{
+ m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch, a_Exclude);
+}
+
+
+
+
+
void cWorld::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude);
+ LOG("BroadcastSoundEffect with double position arguments is deprecated, use vector-parametered version instead.");
+ BroadcastSoundEffect(a_SoundName, {a_X, a_Y, a_Z}, a_Volume, a_Pitch, a_Exclude);
}
@@ -2787,9 +2817,9 @@ void cWorld::BroadcastTeleportEntity(const cEntity & a_Entity, const cClientHand
-void cWorld::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cWorld::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastThunderbolt(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
+ m_ChunkMap->BroadcastThunderbolt(a_BlockPos, a_Exclude);
}
diff --git a/src/World.h b/src/World.h
index f6fb32005..b5702a6dc 100644
--- a/src/World.h
+++ b/src/World.h
@@ -161,6 +161,7 @@ public:
// Broadcast respective packets to all clients of the chunk where the event is taking place
// (Please keep these alpha-sorted)
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle);
+ void BroadcastBlockAction (Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
@@ -199,11 +200,12 @@ public:
void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
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 BroadcastSoundEffect (const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) override; // tolua_export
+ 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); // tolua_export
virtual void BroadcastSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr) override; // 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);
+ void BroadcastThunderbolt (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr);
void BroadcastTimeUpdate (const cClientHandle * a_Exclude = nullptr);
void BroadcastUnleashEntity (const cEntity & a_Entity);
virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override;
@@ -753,7 +755,8 @@ public:
// tolua_begin
/** Casts a thunderbolt at the specified coords */
- void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void CastThunderbolt(Vector3i a_Block);
+ void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ); // DEPRECATED, use vector-parametered version instead
/** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */
void SetWeather(eWeather a_NewWeather);