summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorx12xx12x <44411062+12xx12@users.noreply.github.com>2022-04-19 20:30:12 +0200
committerAlexander Harkness <me@bearbin.net>2022-04-20 09:41:02 +0200
commit5ea7675eca4fe50feed7fc4b871075f8c937d8b1 (patch)
tree440c01c9c6b783b27155c631273c60d32092c38f
parentCheck height is within world for pistons and digging (#5396) (diff)
downloadcuberite-5ea7675eca4fe50feed7fc4b871075f8c937d8b1.tar
cuberite-5ea7675eca4fe50feed7fc4b871075f8c937d8b1.tar.gz
cuberite-5ea7675eca4fe50feed7fc4b871075f8c937d8b1.tar.bz2
cuberite-5ea7675eca4fe50feed7fc4b871075f8c937d8b1.tar.lz
cuberite-5ea7675eca4fe50feed7fc4b871075f8c937d8b1.tar.xz
cuberite-5ea7675eca4fe50feed7fc4b871075f8c937d8b1.tar.zst
cuberite-5ea7675eca4fe50feed7fc4b871075f8c937d8b1.zip
-rw-r--r--src/Bindings/PluginManager.cpp48
-rw-r--r--src/Bindings/PluginManager.h24
-rw-r--r--src/BlockEntities/BannerEntity.cpp2
-rw-r--r--src/BlockEntities/EnderChestEntity.cpp2
-rw-r--r--src/BlockEntities/MobHeadEntity.cpp2
-rw-r--r--src/BlockEntities/SignEntity.cpp2
-rw-r--r--src/BlockInServerPluginInterface.h12
-rw-r--r--src/Blocks/BlockCauldron.h5
-rw-r--r--src/Blocks/BlockGrass.h2
-rw-r--r--src/Blocks/BlockPluginInterface.h6
-rw-r--r--src/Blocks/BlockVines.h2
-rw-r--r--src/Broadcaster.cpp10
-rw-r--r--src/ByteBuffer.cpp18
-rw-r--r--src/ByteBuffer.h2
-rw-r--r--src/Chunk.cpp2
-rw-r--r--src/ChunkDef.h5
-rw-r--r--src/ClientHandle.cpp189
-rw-r--r--src/ClientHandle.h36
-rw-r--r--src/Entities/Player.cpp8
-rw-r--r--src/Entities/Player.h2
-rw-r--r--src/Entities/ProjectileEntity.cpp2
-rw-r--r--src/Items/ItemBucket.h4
-rw-r--r--src/Items/ItemHandler.cpp2
-rw-r--r--src/Items/ItemPumpkin.h2
-rw-r--r--src/Items/ItemSign.h2
-rw-r--r--src/Items/ItemSlab.h4
-rw-r--r--src/Protocol/Protocol.h18
-rw-r--r--src/Protocol/Protocol_1_10.cpp8
-rw-r--r--src/Protocol/Protocol_1_10.h2
-rw-r--r--src/Protocol/Protocol_1_11.cpp8
-rw-r--r--src/Protocol/Protocol_1_13.cpp4
-rw-r--r--src/Protocol/Protocol_1_13.h2
-rw-r--r--src/Protocol/Protocol_1_14.cpp10
-rw-r--r--src/Protocol/Protocol_1_14.h10
-rw-r--r--src/Protocol/Protocol_1_8.cpp74
-rw-r--r--src/Protocol/Protocol_1_8.h18
-rw-r--r--src/Protocol/Protocol_1_9.cpp46
-rw-r--r--src/Protocol/Protocol_1_9.h6
-rw-r--r--src/Simulator/FireSimulator.cpp4
-rw-r--r--src/World.cpp8
-rw-r--r--src/World.h11
41 files changed, 317 insertions, 307 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index b4f9baa4a..d7d09ed5a 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -254,11 +254,11 @@ bool cPluginManager::GenericCallHook(PluginHook a_HookName, HookFunction a_HookF
-bool cPluginManager::CallHookBlockSpread(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
+bool cPluginManager::CallHookBlockSpread(cWorld & a_World, Vector3i a_BlockPos, eSpreadSource a_Source)
{
return GenericCallHook(HOOK_BLOCK_SPREAD, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source);
+ return a_Plugin->OnBlockSpread(a_World, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Source);
}
);
}
@@ -710,11 +710,11 @@ bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation
-bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return GenericCallHook(HOOK_PLAYER_BREAKING_BLOCK, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerBreakingBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_BlockType, a_BlockMeta);
}
);
}
@@ -723,11 +723,11 @@ bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_Block
-bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return GenericCallHook(HOOK_PLAYER_BROKEN_BLOCK, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerBrokenBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_BlockType, a_BlockMeta);
}
);
}
@@ -814,11 +814,11 @@ bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
-bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status)
+bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, char a_Status)
{
return GenericCallHook(HOOK_PLAYER_LEFT_CLICK, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status);
+ return a_Plugin->OnPlayerLeftClick(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_Status);
}
);
}
@@ -892,11 +892,11 @@ bool cPluginManager::CallHookPlayerCrouched(cPlayer & a_Player)
-bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
{
return GenericCallHook(HOOK_PLAYER_RIGHT_CLICK, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
+ return a_Plugin->OnPlayerRightClick(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z);
}
);
}
@@ -957,11 +957,11 @@ bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
-bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return GenericCallHook(HOOK_PLAYER_USED_BLOCK, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerUsedBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z, a_BlockType, a_BlockMeta);
}
);
}
@@ -970,11 +970,11 @@ bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, i
-bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
{
return GenericCallHook(HOOK_PLAYER_USED_ITEM, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsedItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
+ return a_Plugin->OnPlayerUsedItem(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z);
}
);
}
@@ -983,11 +983,11 @@ bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, in
-bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return GenericCallHook(HOOK_PLAYER_USING_BLOCK, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerUsingBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z, a_BlockType, a_BlockMeta);
}
);
}
@@ -996,11 +996,11 @@ bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX,
-bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
{
return GenericCallHook(HOOK_PLAYER_USING_ITEM, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsingItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
+ return a_Plugin->OnPlayerUsingItem(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z);
}
);
}
@@ -1071,11 +1071,11 @@ bool cPluginManager::CallHookPreCrafting(cPlayer & a_Player, cCraftingGrid & a_G
-bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos)
+bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, Vector3i a_BlockPos, eBlockFace a_Face, const Vector3d & a_BlockHitPos)
{
return GenericCallHook(HOOK_PROJECTILE_HIT_BLOCK, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos);
+ return a_Plugin->OnProjectileHitBlock(a_Projectile, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Face, a_BlockHitPos);
}
);
}
@@ -1175,11 +1175,11 @@ bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a
-bool cPluginManager::CallHookUpdatingSign(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
+bool cPluginManager::CallHookUpdatingSign(cWorld & a_World, Vector3i a_BlockPos, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
{
return GenericCallHook(HOOK_UPDATING_SIGN, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnUpdatingSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
+ return a_Plugin->OnUpdatingSign(a_World, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
}
);
}
@@ -1188,11 +1188,11 @@ bool cPluginManager::CallHookUpdatingSign(cWorld & a_World, int a_BlockX, int a_
-bool cPluginManager::CallHookUpdatedSign(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
+bool cPluginManager::CallHookUpdatedSign(cWorld & a_World, Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
{
return GenericCallHook(HOOK_UPDATED_SIGN, [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnUpdatedSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
+ return a_Plugin->OnUpdatedSign(a_World, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
}
);
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 55f3c72ee..86957000b 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -236,7 +236,7 @@ public:
size_t GetNumLoadedPlugins(void) const; // tolua_export
// Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
- bool CallHookBlockSpread (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);
+ bool CallHookBlockSpread (cWorld & a_World, Vector3i a_BlockPos, eSpreadSource a_Source);
bool CallHookBlockToPickups (cWorld & a_World, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool, cItems & a_Pickups);
bool CallHookBrewingCompleting (cWorld & a_World, cBrewingstandEntity & a_Brewingstand);
bool CallHookBrewingCompleted (cWorld & a_World, cBrewingstandEntity & a_Brewingstand);
@@ -265,34 +265,34 @@ public:
bool CallHookLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username);
bool CallHookLoginForge (cClientHandle & a_Client, AStringMap & a_Mods);
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
- bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
- bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ bool CallHookPlayerBreakingBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ bool CallHookPlayerBrokenBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
bool CallHookPlayerDestroyed (cPlayer & a_Player);
bool CallHookPlayerEating (cPlayer & a_Player);
bool CallHookPlayerFished (cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount);
bool CallHookPlayerFishing (cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount);
bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
bool CallHookPlayerJoined (cPlayer & a_Player);
- bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status);
+ bool CallHookPlayerLeftClick (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, char a_Status);
bool CallHookPlayerMoving (cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition, bool a_PreviousIsOnGround);
bool CallHookPlayerOpeningWindow (cPlayer & a_Player, cWindow & a_Window);
bool CallHookPlayerPlacedBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange);
bool CallHookPlayerPlacingBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange);
bool CallHookPlayerCrouched (cPlayer & a_Player);
- bool CallHookPlayerRightClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
+ bool CallHookPlayerRightClick (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos);
bool CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity);
bool CallHookPlayerShooting (cPlayer & a_Player);
bool CallHookPlayerSpawned (cPlayer & a_Player);
bool CallHookPlayerTossingItem (cPlayer & a_Player);
- bool CallHookPlayerUsedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
- bool CallHookPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
- bool CallHookPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
- bool CallHookPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
+ bool CallHookPlayerUsedBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ bool CallHookPlayerUsedItem (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos);
+ bool CallHookPlayerUsingBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ bool CallHookPlayerUsingItem (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos);
bool CallHookPluginMessage (cClientHandle & a_Client, const AString & a_Channel, ContiguousByteBufferView a_Message);
bool CallHookPluginsLoaded (void);
bool CallHookPostCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
bool CallHookPreCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
- bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos);
+ bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, Vector3i a_BlockPos, eBlockFace a_Face, const Vector3d & a_BlockHitPos);
bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
bool CallHookServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon);
bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity);
@@ -300,8 +300,8 @@ public:
bool CallHookSpawningEntity (cWorld & a_World, cEntity & a_Entity);
bool CallHookSpawningMonster (cWorld & a_World, cMonster & a_Monster);
bool CallHookTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TDI);
- bool CallHookUpdatedSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player);
- bool CallHookUpdatingSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player);
+ bool CallHookUpdatedSign (cWorld & a_World, Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player);
+ bool CallHookUpdatingSign (cWorld & a_World, Vector3i a_BlockPos, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player);
bool CallHookWeatherChanged (cWorld & a_World);
bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
bool CallHookWorldStarted (cWorld & a_World);
diff --git a/src/BlockEntities/BannerEntity.cpp b/src/BlockEntities/BannerEntity.cpp
index e7be2065e..f39263ac4 100644
--- a/src/BlockEntities/BannerEntity.cpp
+++ b/src/BlockEntities/BannerEntity.cpp
@@ -73,7 +73,7 @@ void cBannerEntity::CopyFrom(const cBlockEntity & a_Src)
void cBannerEntity::SendTo(cClientHandle & a_Client)
{
- a_Client.SendBlockChange(m_Pos.x, m_Pos.y, m_Pos.z, m_BlockType, m_BlockMeta);
+ a_Client.SendBlockChange(m_Pos, m_BlockType, m_BlockMeta);
a_Client.SendUpdateBlockEntity(*this);
}
diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp
index ba9ca5609..07cc8aa18 100644
--- a/src/BlockEntities/EnderChestEntity.cpp
+++ b/src/BlockEntities/EnderChestEntity.cpp
@@ -28,7 +28,7 @@ cEnderChestEntity::cEnderChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMe
void cEnderChestEntity::SendTo(cClientHandle & a_Client)
{
// Send a dummy "number of players with chest open" packet to make the chest visible:
- a_Client.SendBlockAction(m_Pos.x, m_Pos.y, m_Pos.z, 1, 0, m_BlockType);
+ a_Client.SendBlockAction(m_Pos, 1, 0, m_BlockType);
}
diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp
index 72d039e7e..ef717513d 100644
--- a/src/BlockEntities/MobHeadEntity.cpp
+++ b/src/BlockEntities/MobHeadEntity.cpp
@@ -119,7 +119,7 @@ void cMobHeadEntity::CopyFrom(const cBlockEntity & a_Src)
void cMobHeadEntity::SendTo(cClientHandle & a_Client)
{
cWorld * World = a_Client.GetPlayer()->GetWorld();
- a_Client.SendBlockChange(m_Pos.x, m_Pos.y, m_Pos.z, m_BlockType, World->GetBlockMeta(GetPos()));
+ a_Client.SendBlockChange(m_Pos, m_BlockType, World->GetBlockMeta(GetPos()));
a_Client.SendUpdateBlockEntity(*this);
}
diff --git a/src/BlockEntities/SignEntity.cpp b/src/BlockEntities/SignEntity.cpp
index 30adcb9f9..b9b0cbb44 100644
--- a/src/BlockEntities/SignEntity.cpp
+++ b/src/BlockEntities/SignEntity.cpp
@@ -89,5 +89,5 @@ AString cSignEntity::GetLine(int a_Index) const
void cSignEntity::SendTo(cClientHandle & a_Client)
{
- a_Client.SendUpdateSign(m_Pos.x, m_Pos.y, m_Pos.z, m_Line[0], m_Line[1], m_Line[2], m_Line[3]);
+ a_Client.SendUpdateSign(m_Pos, m_Line[0], m_Line[1], m_Line[2], m_Line[3]);
}
diff --git a/src/BlockInServerPluginInterface.h b/src/BlockInServerPluginInterface.h
index f3ed774f7..78e934cea 100644
--- a/src/BlockInServerPluginInterface.h
+++ b/src/BlockInServerPluginInterface.h
@@ -22,19 +22,19 @@ class cBlockInServerPluginInterface :
public:
cBlockInServerPluginInterface(cWorld & a_World) : m_World(a_World) {}
- virtual bool CallHookBlockSpread(int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) override
+ virtual bool CallHookBlockSpread(Vector3i a_BlockPos, eSpreadSource a_Source) override
{
- return cPluginManager::Get()->CallHookBlockSpread(m_World, a_BlockX, a_BlockY, a_BlockZ, a_Source);
+ return cPluginManager::Get()->CallHookBlockSpread(m_World, a_BlockPos, a_Source);
}
- virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
+ virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
{
- return cPluginManager::Get()->CallHookPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta);
+ return cPluginManager::Get()->CallHookPlayerBreakingBlock(a_Player, a_BlockPos, a_BlockFace, a_BlockType, a_BlockMeta);
}
- virtual bool CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
+ virtual bool CallHookPlayerBrokenBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
{
- return cPluginManager::Get()->CallHookPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta);
+ return cPluginManager::Get()->CallHookPlayerBrokenBlock(a_Player, a_BlockPos, a_BlockFace, a_BlockType, a_BlockMeta);
}
private:
diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h
index cbd17a849..82247944c 100644
--- a/src/Blocks/BlockCauldron.h
+++ b/src/Blocks/BlockCauldron.h
@@ -156,8 +156,9 @@ private:
// Using cauldrons with blocks was added in 1.13 as part of shulker cleaning.
const auto ResendPosition = AddFaceDirection(a_BlockPos, a_BlockFace);
a_Player.GetClientHandle()->SendBlockChange(
- ResendPosition.x, ResendPosition.y, ResendPosition.z,
- a_ChunkInterface.GetBlock(ResendPosition), a_ChunkInterface.GetBlockMeta(ResendPosition)
+ ResendPosition,
+ a_ChunkInterface.GetBlock(ResendPosition),
+ a_ChunkInterface.GetBlockMeta(ResendPosition)
);
return true;
diff --git a/src/Blocks/BlockGrass.h b/src/Blocks/BlockGrass.h
index 8309a4bd5..09af250c3 100644
--- a/src/Blocks/BlockGrass.h
+++ b/src/Blocks/BlockGrass.h
@@ -161,7 +161,7 @@ private:
)
{
const auto AbsPos = Chunk->RelativeToAbsolute(a_RelPos);
- if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*Chunk->GetWorld(), AbsPos.x, AbsPos.y, AbsPos.z, ssGrassSpread))
+ if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*Chunk->GetWorld(), AbsPos, ssGrassSpread))
{
Chunk->FastSetBlock(a_RelPos, E_BLOCK_GRASS, 0);
}
diff --git a/src/Blocks/BlockPluginInterface.h b/src/Blocks/BlockPluginInterface.h
index 087e86412..0cf3ef0e3 100644
--- a/src/Blocks/BlockPluginInterface.h
+++ b/src/Blocks/BlockPluginInterface.h
@@ -29,9 +29,9 @@ class cBlockPluginInterface
public:
virtual ~cBlockPluginInterface() {}
- virtual bool CallHookBlockSpread(int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
- virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
- virtual bool CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
+ virtual bool CallHookBlockSpread(Vector3i a_BlockPos, eSpreadSource a_Source) = 0;
+ virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
+ virtual bool CallHookPlayerBrokenBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
};
diff --git a/src/Blocks/BlockVines.h b/src/Blocks/BlockVines.h
index d6eccd552..0ab0441a8 100644
--- a/src/Blocks/BlockVines.h
+++ b/src/Blocks/BlockVines.h
@@ -210,7 +210,7 @@ private:
if (Block == E_BLOCK_AIR)
{
auto WorldPos = a_Chunk.RelativeToAbsolute(GrowPos);
- if (!a_PluginInterface.CallHookBlockSpread(WorldPos.x, WorldPos.y, WorldPos.z, ssVineSpread))
+ if (!a_PluginInterface.CallHookBlockSpread(WorldPos, ssVineSpread))
{
a_Chunk.UnboundedRelSetBlock(GrowPos, E_BLOCK_VINES, a_Chunk.GetMeta(a_RelPos));
}
diff --git a/src/Broadcaster.cpp b/src/Broadcaster.cpp
index 0a8f17930..9369b8062 100644
--- a/src/Broadcaster.cpp
+++ b/src/Broadcaster.cpp
@@ -123,7 +123,7 @@ void cWorld::BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte
{
ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
{
- a_Client.SendBlockAction(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType);
+ a_Client.SendBlockAction(a_BlockPos, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType);
}
);
}
@@ -136,7 +136,7 @@ void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos
{
ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
{
- a_Client.SendBlockBreakAnim(a_EntityID, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Stage);
+ a_Client.SendBlockBreakAnim(a_EntityID, a_BlockPos, a_Stage);
}
);
}
@@ -401,7 +401,7 @@ void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vecto
{
ForClientsWithChunkAtPos(a_Src, *this, a_Exclude, [&](cClientHandle & a_Client)
{
- a_Client.SendParticleEffect(a_ParticleName, a_Src.x, a_Src.y, a_Src.z, a_Offset.x, a_Offset.y, a_Offset.z, a_ParticleData, a_ParticleAmount);
+ a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount);
}
);
}
@@ -557,7 +557,7 @@ void cWorld::BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_
{
ForClientsWithChunkAtPos(a_SrcPos, *this, a_Exclude, [&](cClientHandle & a_Client)
{
- a_Client.SendSoundParticleEffect(a_EffectID, a_SrcPos.x, a_SrcPos.y, a_SrcPos.z, a_Data);
+ a_Client.SendSoundParticleEffect(a_EffectID, a_SrcPos, a_Data);
}
);
}
@@ -583,7 +583,7 @@ void cWorld::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_E
{
ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
{
- a_Client.SendThunderbolt(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
+ a_Client.SendThunderbolt(a_BlockPos);
}
);
}
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index ce9df77cc..af619f26f 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -509,6 +509,15 @@ bool cByteBuffer::ReadXYZPosition64(int & a_BlockX, int & a_BlockY, int & a_Bloc
+bool cByteBuffer::ReadXYZPosition64(Vector3i & a_Position)
+{
+ return ReadXYZPosition64(a_Position.x, a_Position.y, a_Position.z);
+}
+
+
+
+
+
bool cByteBuffer::ReadXZYPosition64(int & a_BlockX, int & a_BlockY, int & a_BlockZ)
{
CHECK_THREAD
@@ -534,6 +543,15 @@ bool cByteBuffer::ReadXZYPosition64(int & a_BlockX, int & a_BlockY, int & a_Bloc
+bool cByteBuffer::ReadXZYPosition64(Vector3i & a_Position)
+{
+ return ReadXZYPosition64(a_Position.x, a_Position.y, a_Position.z);
+}
+
+
+
+
+
bool cByteBuffer::ReadUUID(cUUID & a_Value)
{
CHECK_THREAD
diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h
index 7b589f341..1d108fca2 100644
--- a/src/ByteBuffer.h
+++ b/src/ByteBuffer.h
@@ -72,7 +72,9 @@ public:
bool ReadVarUTF8String (AString & a_Value); // string length as VarInt, then string as UTF-8
bool ReadLEInt (int & a_Value);
bool ReadXYZPosition64 (int & a_BlockX, int & a_BlockY, int & a_BlockZ);
+ bool ReadXYZPosition64 (Vector3i & a_Position);
bool ReadXZYPosition64 (int & a_BlockX, int & a_BlockY, int & a_BlockZ);
+ bool ReadXZYPosition64 (Vector3i & a_Position);
bool ReadUUID (cUUID & a_Value);
/** Reads VarInt, assigns it to anything that can be assigned from an UInt64 (unsigned short, char, Byte, double, ...) */
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 462323308..db09facd9 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1401,7 +1401,7 @@ void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_C
}
const auto Position = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ);
- a_Client->SendBlockChange(Position.x, Position.y, Position.z, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ));
+ a_Client->SendBlockChange(Position, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ));
// FS #268 - if a BlockEntity digging is cancelled by a plugin, the entire block entity must be re-sent to the client:
if (BlockEntity != nullptr)
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index 12036cdbe..2f619f83b 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -170,6 +170,11 @@ public:
return ((a_Height >= 0) && (a_Height < Height));
}
+ inline static bool IsValidHeight(Vector3i a_BlockPosition)
+ {
+ return IsValidHeight(a_BlockPosition.y);
+ }
+
/** Validates a width-coordinate. Returns false if width-coordiante is out of width bounds */
inline static bool IsValidWidth(int a_Width)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 24f1b3800..4872cb402 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -81,13 +81,9 @@ cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) :
m_PingID(1),
m_BlockDigAnimStage(-1),
m_BlockDigAnimSpeed(0),
- m_BlockDigAnimX(0),
- m_BlockDigAnimY(cChunkDef::Height + 1), // Invalid Y, so that the coords don't get picked up
- m_BlockDigAnimZ(0),
+ m_BlockDigAnimPos(),
m_HasStartedDigging(false),
- m_LastDigBlockX(0),
- m_LastDigBlockY(cChunkDef::Height + 1), // Invalid Y, so that the coords don't get picked up
- m_LastDigBlockZ(0),
+ m_LastDigBlockPos(),
m_State(csConnected),
m_NumExplosionsThisTick(0),
m_NumBlockChangeInteractionsThisTick(0),
@@ -1038,7 +1034,7 @@ void cClientHandle::HandleBeaconSelection(unsigned a_PrimaryEffect, unsigned a_S
-void cClientHandle::HandleCommandBlockBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_NewCommand)
+void cClientHandle::HandleCommandBlockBlockChange(Vector3i a_BlockPos, const AString & a_NewCommand)
{
if (a_NewCommand.empty())
{
@@ -1055,7 +1051,7 @@ void cClientHandle::HandleCommandBlockBlockChange(int a_BlockX, int a_BlockY, in
cWorld * World = m_Player->GetWorld();
if (World->AreCommandBlocksEnabled())
{
- World->SetCommandBlockCommand(a_BlockX, a_BlockY, a_BlockZ, a_NewCommand);
+ World->SetCommandBlockCommand(a_BlockPos, a_NewCommand);
SendChat("Successfully set command block command", mtSuccess);
}
else
@@ -1095,10 +1091,10 @@ void cClientHandle::HandleAnvilItemName(const AString & a_ItemName)
-void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, UInt8 a_Status)
+void cClientHandle::HandleLeftClick(Vector3i a_BlockPos, eBlockFace a_BlockFace, UInt8 a_Status)
{
FLOGD("HandleLeftClick: {0}; Face: {1}; Stat: {2}",
- Vector3i{a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace, a_Status
+ a_BlockPos, a_BlockFace, a_Status
);
m_NumBlockChangeInteractionsThisTick++;
@@ -1120,34 +1116,30 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
When the user breaks a fire block, the client send the wrong block location.
We must find the right block with the face direction. */
- int BlockX = a_BlockX;
- int BlockY = a_BlockY;
- int BlockZ = a_BlockZ;
- AddFaceDirection(BlockX, BlockY, BlockZ, a_BlockFace);
+ Vector3i BlockPos = a_BlockPos;
+ AddFaceDirection(BlockPos, a_BlockFace);
- if (cChunkDef::IsValidHeight(BlockY) && cBlockInfo::IsClickedThrough(m_Player->GetWorld()->GetBlock({ BlockX, BlockY, BlockZ })))
+ if (cChunkDef::IsValidHeight(BlockPos.y) && cBlockInfo::IsClickedThrough(m_Player->GetWorld()->GetBlock(BlockPos)))
{
- a_BlockX = BlockX;
- a_BlockY = BlockY;
- a_BlockZ = BlockZ;
+ a_BlockPos = BlockPos;
}
if (
- (Diff(m_Player->GetPosX(), static_cast<double>(a_BlockX)) > 6) ||
- (Diff(m_Player->GetPosY(), static_cast<double>(a_BlockY)) > 6) ||
- (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6)
+ (Diff(m_Player->GetPosX(), static_cast<double>(a_BlockPos.x)) > 6) ||
+ (Diff(m_Player->GetPosY(), static_cast<double>(a_BlockPos.y)) > 6) ||
+ (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockPos.z)) > 6)
)
{
- m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2);
+ m_Player->SendBlocksAround(a_BlockPos, 2);
return;
}
}
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
- if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, static_cast<char>(a_Status)))
+ if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockPos, a_BlockFace, static_cast<char>(a_Status)))
{
// A plugin doesn't agree with the action, replace the block on the client and quit:
- m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2);
+ m_Player->SendBlocksAround(a_BlockPos, 2);
SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side.
return;
}
@@ -1184,11 +1176,11 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
// When bow is in off-hand / shield slot
if (m_Player->GetInventory().GetShieldSlot().m_ItemType == E_ITEM_BOW)
{
- m_Player->GetInventory().GetShieldSlot().GetHandler().OnItemShoot(m_Player, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace);
+ m_Player->GetInventory().GetShieldSlot().GetHandler().OnItemShoot(m_Player, {a_BlockPos}, a_BlockFace);
}
else
{
- ItemHandler.OnItemShoot(m_Player, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace);
+ ItemHandler.OnItemShoot(m_Player, {a_BlockPos}, a_BlockFace);
}
}
return;
@@ -1196,13 +1188,13 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_STARTED:
{
- HandleBlockDigStarted(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ HandleBlockDigStarted(a_BlockPos, a_BlockFace);
return;
}
case DIG_STATUS_FINISHED:
{
- HandleBlockDigFinished(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ HandleBlockDigFinished(a_BlockPos, a_BlockFace);
return;
}
@@ -1249,7 +1241,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
-void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
+void cClientHandle::HandleBlockDigStarted(Vector3i a_BlockPos, eBlockFace a_BlockFace)
{
if (m_Player->IsGameModeAdventure())
{
@@ -1258,10 +1250,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
}
if (
- m_HasStartedDigging &&
- (a_BlockX == m_LastDigBlockX) &&
- (a_BlockY == m_LastDigBlockY) &&
- (a_BlockZ == m_LastDigBlockZ)
+ m_HasStartedDigging && (a_BlockPos == m_LastDigBlockPos)
)
{
// It is a duplicate packet, drop it right away
@@ -1270,7 +1259,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
BLOCKTYPE DiggingBlock;
NIBBLETYPE DiggingMeta;
- m_Player->GetWorld()->GetBlockTypeMeta({ a_BlockX, a_BlockY, a_BlockZ }, DiggingBlock, DiggingMeta);
+ m_Player->GetWorld()->GetBlockTypeMeta(a_BlockPos, DiggingBlock, DiggingMeta);
if (
m_Player->IsGameModeCreative() &&
@@ -1283,20 +1272,18 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
}
if (
- (Diff(m_Player->GetPosX(), static_cast<double>(a_BlockX)) > 6) ||
- (Diff(m_Player->GetPosY(), static_cast<double>(a_BlockY)) > 6) ||
- (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6)
+ (Diff(m_Player->GetPosX(), static_cast<double>(a_BlockPos.x)) > 6) ||
+ (Diff(m_Player->GetPosY(), static_cast<double>(a_BlockPos.y)) > 6) ||
+ (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockPos.z)) > 6)
)
{
- m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2);
+ m_Player->SendBlocksAround(a_BlockPos, 2);
return;
}
// Set the last digging coords to the block being dug, so that they can be checked in DIG_FINISHED to avoid dig / aim bug in the client:
m_HasStartedDigging = true;
- m_LastDigBlockX = a_BlockX;
- m_LastDigBlockY = a_BlockY;
- m_LastDigBlockZ = a_BlockZ;
+ m_LastDigBlockPos = a_BlockPos;
if (
m_Player->IsGameModeCreative() || // In creative mode, digging is done immediately
@@ -1306,7 +1293,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
// Immediately done:
m_BreakProgress = 1;
- HandleBlockDigFinished(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ HandleBlockDigFinished(a_BlockPos, a_BlockFace);
return;
}
@@ -1316,35 +1303,31 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
// TODO: calculate real animation speed
// TODO: Send animation packets even without receiving any other packets
m_BlockDigAnimSpeed = 10;
- m_BlockDigAnimX = a_BlockX;
- m_BlockDigAnimY = a_BlockY;
- m_BlockDigAnimZ = a_BlockZ;
+ m_BlockDigAnimPos = a_BlockPos;
m_BlockDigAnimStage = 0;
- m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), {m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ}, 0, this);
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), m_BlockDigAnimPos, 0, this);
cWorld * World = m_Player->GetWorld();
cChunkInterface ChunkInterface(World->GetChunkMap());
- cBlockHandler::For(DiggingBlock).OnDigging(ChunkInterface, *World, *m_Player, {a_BlockX, a_BlockY, a_BlockZ});
+ cBlockHandler::For(DiggingBlock).OnDigging(ChunkInterface, *World, *m_Player, {a_BlockPos});
- m_Player->GetEquippedItem().GetHandler().OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace);
+ m_Player->GetEquippedItem().GetHandler().OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), {a_BlockPos}, a_BlockFace);
}
-void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
+void cClientHandle::HandleBlockDigFinished(Vector3i a_BlockPos, eBlockFace a_BlockFace)
{
if (
!m_HasStartedDigging || // Hasn't received the DIG_STARTED packet
- (m_LastDigBlockX != a_BlockX) || // DIG_STARTED has had different pos
- (m_LastDigBlockY != a_BlockY) ||
- (m_LastDigBlockZ != a_BlockZ)
+ (m_LastDigBlockPos != a_BlockPos) // DIG_STARTED has had different pos
)
{
FLOGD("Prevented a dig / aim bug in the client (finish {0} vs start {1}, HSD: {2})",
- Vector3i{a_BlockX, a_BlockY, a_BlockZ},
- Vector3i{m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ},
+ a_BlockPos,
+ m_LastDigBlockPos,
(m_HasStartedDigging ? "True" : "False")
);
return;
@@ -1354,7 +1337,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
BLOCKTYPE DugBlock;
NIBBLETYPE DugMeta;
- m_Player->GetWorld()->GetBlockTypeMeta({ a_BlockX, a_BlockY, a_BlockZ }, DugBlock, DugMeta);
+ m_Player->GetWorld()->GetBlockTypeMeta({ a_BlockPos }, DugBlock, DugMeta);
if (!m_Player->IsGameModeCreative())
{
@@ -1365,7 +1348,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
{
LOGD("Break progress of player %s was less than expected: %f < %f\n", m_Player->GetName().c_str(), m_BreakProgress * 100, FASTBREAK_PERCENTAGE * 100);
// AntiFastBreak doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
- m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2);
+ m_Player->SendBlocksAround(a_BlockPos, 2);
SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side.
m_Player->SendMessage("FastBreak?"); // TODO Anticheat hook
return;
@@ -1374,10 +1357,10 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
cWorld * World = m_Player->GetWorld();
- if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, DugBlock, DugMeta))
+ if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockPos, a_BlockFace, DugBlock, DugMeta))
{
// A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
- m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2);
+ m_Player->SendBlocksAround(a_BlockPos, 2);
SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side.
return;
}
@@ -1394,7 +1377,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
m_Player->UseEquippedItem(cBlockInfo::IsOneHitDig(DugBlock) ? cItemHandler::dlaBreakBlockInstant : cItemHandler::dlaBreakBlock);
cChunkInterface ChunkInterface(World->GetChunkMap());
- Vector3i absPos(a_BlockX, a_BlockY, a_BlockZ);
+ Vector3i absPos(a_BlockPos);
if (m_Player->IsGameModeSurvival())
{
World->DropBlockAsPickups(absPos, m_Player, &m_Player->GetEquippedItem());
@@ -1405,7 +1388,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
}
World->BroadcastSoundParticleEffect(EffectID::PARTICLE_BLOCK_BREAK, absPos, DugBlock, this);
- cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, DugBlock, DugMeta);
+ cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockPos, a_BlockFace, DugBlock, DugMeta);
}
@@ -1425,19 +1408,17 @@ void cClientHandle::FinishDigAnimation()
// End dig animation
m_BlockDigAnimStage = -1;
// It seems that 10 ends block animation
- m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), {m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ}, 10, this);
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), m_LastDigBlockPos, 10, this);
}
- m_BlockDigAnimX = -1;
- m_BlockDigAnimY = -1;
- m_BlockDigAnimZ = -1;
+ m_LastDigBlockPos = {-1, -1, -1};
}
-void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, bool a_UsedMainHand)
+void cClientHandle::HandleRightClick(Vector3i a_BlockPos, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, bool a_UsedMainHand)
{
/* This function handles three actions:
(1) Place a block;
@@ -1453,7 +1434,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
Actions rejected by plugin will not lead to other attempts.
E.g., when opening a chest with a dirt in hand, if the plugin rejects opening the chest, the dirt will not be placed. */
- if ((a_BlockFace == BLOCK_FACE_NONE) || !cChunkDef::IsValidHeight(a_BlockY))
+ if ((a_BlockFace == BLOCK_FACE_NONE) || !cChunkDef::IsValidHeight(a_BlockPos))
{
LOGD("Player \"%s\" sent an invalid click - hacked client?", m_Username.c_str());
return;
@@ -1462,7 +1443,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
// TODO: We are still consuming the items in main hand. Remove this override when the off-hand consumption is handled correctly.
a_UsedMainHand = true;
- const Vector3i ClickedPosition(a_BlockX, a_BlockY, a_BlockZ);
+ const Vector3i ClickedPosition(a_BlockPos);
const Vector3i CursorPosition(a_CursorX, a_CursorY, a_CursorZ);
const cItem & HeldItem = a_UsedMainHand ? m_Player->GetEquippedItem() : m_Player->GetInventory().GetShieldSlot();
@@ -1482,7 +1463,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (
- !PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ) &&
+ !PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockPos, a_BlockFace, CursorPosition) &&
IsWithinReach && !m_Player->IsFrozen()
)
{
@@ -1503,12 +1484,12 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
if (BlockUsable)
{
cChunkInterface ChunkInterface(World->GetChunkMap());
- if (!PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
+ if (!PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockPos, a_BlockFace, CursorPosition, BlockType, BlockMeta))
{
// Use a block:
if (BlockHandler.OnUse(ChunkInterface, *World, *m_Player, ClickedPosition, a_BlockFace, CursorPosition))
{
- PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
+ PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockPos, a_BlockFace, CursorPosition, BlockType, BlockMeta);
return; // Block use was successful, we're done.
}
@@ -1538,14 +1519,14 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
}
else if (ItemUseable)
{
- if (!PlgMgr->CallHookPlayerUsingItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
+ if (!PlgMgr->CallHookPlayerUsingItem(*m_Player, a_BlockPos, a_BlockFace, CursorPosition))
{
// All plugins agree with using the item.
// Use an item in hand with a target block.
cBlockInServerPluginInterface PluginInterface(*World);
ItemHandler.OnItemUse(World, m_Player, PluginInterface, HeldItem, ClickedPosition, a_BlockFace);
- PlgMgr->CallHookPlayerUsedItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
+ PlgMgr->CallHookPlayerUsedItem(*m_Player, a_BlockPos, a_BlockFace, CursorPosition);
return;
}
}
@@ -1559,7 +1540,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
// TODO: delete OnItemUse bool return, delete onCancelRightClick
// Update the target block including the block above and below for 2 block high things:
- m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2);
+ m_Player->SendBlocksAround(a_BlockPos, 2);
// TODO: Send corresponding slot based on hand
m_Player->GetInventory().SendEquippedSlot();
@@ -1782,15 +1763,15 @@ void cClientHandle::HandleWindowClick(UInt8 a_WindowID, Int16 a_SlotNum, eClickA
void cClientHandle::HandleUpdateSign(
- int a_BlockX, int a_BlockY, int a_BlockZ,
+ Vector3i a_BlockPos,
const AString & a_Line1, const AString & a_Line2,
const AString & a_Line3, const AString & a_Line4
)
{
- if (m_LastPlacedSign.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (m_LastPlacedSign.Equals(Vector3i(a_BlockPos)))
{
m_LastPlacedSign.Set(0, -1, 0);
- m_Player->GetWorld()->SetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, m_Player);
+ m_Player->GetWorld()->SetSignLines(a_BlockPos, a_Line1, a_Line2, a_Line3, a_Line4, m_Player);
}
}
@@ -1884,7 +1865,7 @@ void cClientHandle::HandleUseItem(bool a_UsedMainHand)
LOGD("HandleUseItem: Hand: %d; HeldItem: %s", a_UsedMainHand, ItemToFullString(HeldItem).c_str());
- if (PlgMgr->CallHookPlayerRightClick(*m_Player, -1, 255, -1, BLOCK_FACE_NONE, 0, 0, 0))
+ if (PlgMgr->CallHookPlayerRightClick(*m_Player, {-1, 255, -1}, BLOCK_FACE_NONE, {0, 0, 0}))
{
return; // Plugin denied click action
}
@@ -1916,12 +1897,12 @@ void cClientHandle::HandleUseItem(bool a_UsedMainHand)
else
{
// Use an item in hand without a target block
- if (!PlgMgr->CallHookPlayerUsingItem(*m_Player, -1, 255, -1, BLOCK_FACE_NONE, 0, 0, 0))
+ if (!PlgMgr->CallHookPlayerUsingItem(*m_Player, {-1, 255, -1}, BLOCK_FACE_NONE, {0, 0, 0}))
{
// All plugins agree with using the item
cBlockInServerPluginInterface PluginInterface(*World);
ItemHandler.OnItemUse(World, m_Player, PluginInterface, HeldItem, {-1, 255, -1}, BLOCK_FACE_NONE);
- PlgMgr->CallHookPlayerUsedItem(*m_Player, -1, 255, -1, BLOCK_FACE_NONE, 0, 0, 0);
+ PlgMgr->CallHookPlayerUsedItem(*m_Player, {-1, 255, -1}, BLOCK_FACE_NONE, {0, 0, 0});
}
}
}
@@ -2209,7 +2190,7 @@ void cClientHandle::Tick(std::chrono::milliseconds a_Dt)
// anticheat fastbreak
if (m_HasStartedDigging)
{
- BLOCKTYPE Block = m_Player->GetWorld()->GetBlock({ m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ });
+ BLOCKTYPE Block = m_Player->GetWorld()->GetBlock(m_LastDigBlockPos);
m_BreakProgress += m_Player->GetMiningProgressPerTick(Block);
}
@@ -2224,7 +2205,7 @@ void cClientHandle::Tick(std::chrono::milliseconds a_Dt)
}
if (m_BlockDigAnimStage / 1000 != lastAnimVal / 1000)
{
- m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), {m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ}, static_cast<char>(m_BlockDigAnimStage / 1000), this);
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), m_BlockDigAnimPos, static_cast<char>(m_BlockDigAnimStage / 1000), this);
}
}
@@ -2280,36 +2261,34 @@ void cClientHandle::SendUnleashEntity(const cEntity & a_Entity)
-void cClientHandle::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
+void cClientHandle::SendBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
- m_Protocol->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
+ m_Protocol->SendBlockAction(a_BlockPos, a_Byte1, a_Byte2, a_BlockType);
}
-void cClientHandle::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
+void cClientHandle::SendBlockBreakAnim(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage)
{
- m_Protocol->SendBlockBreakAnim(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage);
+ m_Protocol->SendBlockBreakAnim(a_EntityID, a_BlockPos, a_Stage);
}
-void cClientHandle::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cClientHandle::SendBlockChange(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- int ChunkX, ChunkZ = 0;
- cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, ChunkX, ChunkZ);
- cChunkCoords ChunkCoords = cChunkCoords(ChunkX, ChunkZ);
+ auto ChunkCoords = cChunkDef::BlockToChunk(a_BlockPos);
// Do not send block changes in chunks that weren't sent to the client yet:
cCSLock Lock(m_CSChunkLists);
if (std::find(m_SentChunks.begin(), m_SentChunks.end(), ChunkCoords) != m_SentChunks.end())
{
Lock.Unlock();
- m_Protocol->SendBlockChange(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
+ m_Protocol->SendBlockChange(a_BlockPos, a_BlockType, a_BlockMeta);
}
}
@@ -2334,7 +2313,7 @@ void cClientHandle::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlock
if (a_Changes.size() == 1)
{
const auto & Change = a_Changes[0];
- m_Protocol->SendBlockChange(Change.GetX(), Change.GetY(), Change.GetZ(), Change.m_BlockType, Change.m_BlockMeta);
+ m_Protocol->SendBlockChange(Change.GetAbsolutePos(), Change.m_BlockType, Change.m_BlockMeta);
return;
}
@@ -2600,10 +2579,10 @@ void cClientHandle::SendDisconnect(const AString & a_Reason)
-void cClientHandle::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cClientHandle::SendEditSign(Vector3i a_BlockPos)
{
- m_LastPlacedSign.Set(a_BlockX, a_BlockY, a_BlockZ);
- m_Protocol->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
+ m_LastPlacedSign = a_BlockPos;
+ m_Protocol->SendEditSign(a_BlockPos);
}
@@ -2708,13 +2687,13 @@ void cClientHandle::SendExplosion(const Vector3f a_Position, const float a_Power
auto ParticleCount = std::min(static_cast<int>(ParticleFormula * 125), 600);
// Dark smoke particles:
- SendParticleEffect("largesmoke", a_Position.x, a_Position.y, a_Position.z, 0, 0, 0, Spread, static_cast<int>(ParticleCount));
+ SendParticleEffect("largesmoke", a_Position, Vector3f(), Spread, static_cast<int>(ParticleCount));
Spread = ParticleFormula * 0.35f;
ParticleCount = std::min(static_cast<int>(ParticleFormula * 550), 1800);
// Light smoke particles:
- SendParticleEffect("explode", a_Position.x, a_Position.y, a_Position.z, 0, 0, 0, Spread, static_cast<int>(ParticleCount));
+ SendParticleEffect("explode", a_Position, Vector3f(), Spread, static_cast<int>(ParticleCount));
// Shockwave effect:
m_Protocol->SendExplosion(a_Position, a_Power);
@@ -2778,9 +2757,9 @@ void cClientHandle::SendMapData(const cMap & a_Map, int a_DataStartX, int a_Data
-void cClientHandle::SendParticleEffect(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)
+void cClientHandle::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Source, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount)
{
- m_Protocol->SendParticleEffect(a_ParticleName, a_SrcX, a_SrcY, a_SrcZ, a_OffsetX, a_OffsetY, a_OffsetZ, a_ParticleData, a_ParticleAmount);
+ m_Protocol->SendParticleEffect(a_ParticleName, a_Source, a_Offset, a_ParticleData, a_ParticleAmount);
}
@@ -3086,16 +3065,16 @@ void cClientHandle::SendSoundEffect(const AString & a_SoundName, double a_X, dou
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);
+ m_Protocol->SendSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch);
}
-void cClientHandle::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+void cClientHandle::SendSoundParticleEffect(const EffectID a_EffectID, Vector3i a_Source, int a_Data)
{
- m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
+ m_Protocol->SendSoundParticleEffect(a_EffectID, a_Source, a_Data);
}
@@ -3138,9 +3117,9 @@ void cClientHandle::SendTabCompletionResults(const AStringVector & a_Results)
-void cClientHandle::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cClientHandle::SendThunderbolt(Vector3i a_BlockPos)
{
- m_Protocol->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
+ m_Protocol->SendThunderbolt(a_BlockPos);
}
@@ -3190,12 +3169,12 @@ void cClientHandle::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
void cClientHandle::SendUpdateSign(
- int a_BlockX, int a_BlockY, int a_BlockZ,
+ Vector3i a_BlockPos,
const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4
)
{
m_Protocol->SendUpdateSign(
- a_BlockX, a_BlockY, a_BlockZ,
+ a_BlockPos,
a_Line1, a_Line2, a_Line3, a_Line4
);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 612883e46..927f0bfc8 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -150,9 +150,9 @@ public: // tolua_export
// The following functions send the various packets:
// (Please keep these alpha-sorted)
void SendAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle);
- void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType);
- void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage); // tolua_export
- void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export
+ void SendBlockAction (Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType);
+ void SendBlockBreakAnim (UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage); // tolua_export
+ void SendBlockChange (Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export
void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes);
void SendBossBarAdd (UInt32 a_UniqueID, const cCompositeChat & a_Title, float a_FractionFilled, BossBarColor a_Color, BossBarDivisionType a_DivisionType, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog); // tolua_export
void SendBossBarUpdateFlags (UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog); // tolua_export
@@ -174,7 +174,7 @@ public: // tolua_export
void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle); // tolua_export
void SendDisconnect (const AString & a_Reason);
void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display);
- void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
+ void SendEditSign (Vector3i a_BlockPos); // tolua_export
void SendEntityAnimation (const cEntity & a_Entity, EntityAnimation a_Animation); // tolua_export
void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration);
void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item);
@@ -195,7 +195,7 @@ public: // tolua_export
void SendLeashEntity (const cEntity & a_Entity, const cEntity & a_EntityLeashedTo); // tolua_export
void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY);
void SendPaintingSpawn (const cPainting & a_Painting);
- void SendParticleEffect (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);
+ void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Source, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount);
void SendParticleEffect (const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data);
void SendPlayerAbilities (void);
void SendPlayerListAddPlayer (const cPlayer & a_Player);
@@ -222,18 +222,18 @@ public: // 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 SendSoundParticleEffect (const EffectID a_EffectID, Vector3i a_Source, int a_Data);
void SendSpawnEntity (const cEntity & a_Entity);
void SendSpawnMob (const cMonster & a_Mob);
void SendStatistics (const StatisticsManager & a_Manager);
void SendTabCompletionResults (const AStringVector & a_Results);
- void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
+ void SendThunderbolt (Vector3i a_BlockPos); // tolua_export
void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks); // tolua_export
void SendTimeUpdate (cTickTimeLong a_WorldAge, cTickTimeLong a_WorldDate, bool a_DoDaylightCycle);
void SendUnleashEntity (const cEntity & a_Entity); // tolua_export
void SendUnloadChunk (int a_ChunkX, int a_ChunkZ);
void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity);
- void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
+ void SendUpdateSign (Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
/** Send a newly discovered recipe to show the notification and unlock in the recipe book */
void SendUnlockRecipe (UInt32 a_RecipeId);
@@ -324,7 +324,7 @@ public: // tolua_export
/** Called when the protocol receives a message, indicating that the player set a new
command in the command block UI, for a block-based commandblock. */
- void HandleCommandBlockBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_NewCommand);
+ void HandleCommandBlockBlockChange(Vector3i a_BlockPos, const AString & a_NewCommand);
/** Called when the protocol receives a message, indicating that the player set a new
command in the command block UI, for an entity-based commandblock (minecart?). */
@@ -354,7 +354,7 @@ public: // tolua_export
void HandleLeaveBed();
void HandleKeepAlive (UInt32 a_KeepAliveID);
- void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, UInt8 a_Status);
+ void HandleLeftClick (Vector3i a_BlockPos, eBlockFace a_BlockFace, UInt8 a_Status);
/** Called when the protocol receives a MC|TrSel packet, indicating that the player used a trade in
the NPC UI. */
@@ -377,7 +377,7 @@ public: // tolua_export
void HandlePluginMessage (const AString & a_Channel, ContiguousByteBufferView a_Message);
void HandleRespawn (void);
- void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, bool a_UsedMainHand);
+ void HandleRightClick (Vector3i a_BlockPos, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, bool a_UsedMainHand);
void HandleSlotSelected (Int16 a_SlotNum);
void HandleSpectate (const cUUID & a_PlayerUUID);
@@ -390,7 +390,7 @@ public: // tolua_export
void HandleSteerVehicle (float Forward, float Sideways);
void HandleTabCompletion (const AString & a_Text);
void HandleUpdateSign (
- int a_BlockX, int a_BlockY, int a_BlockZ,
+ Vector3i a_BlockPos,
const AString & a_Line1, const AString & a_Line2,
const AString & a_Line3, const AString & a_Line4
);
@@ -507,15 +507,11 @@ private:
// Values required for block dig animation
int m_BlockDigAnimStage; // Current stage of the animation; -1 if not digging
int m_BlockDigAnimSpeed; // Current speed of the animation (units ???)
- int m_BlockDigAnimX;
- int m_BlockDigAnimY;
- int m_BlockDigAnimZ;
+ Vector3i m_BlockDigAnimPos;
// To avoid dig / aim bug in the client, store the last position given in a DIG_START packet and compare to that when processing the DIG_FINISH packet:
bool m_HasStartedDigging;
- int m_LastDigBlockX;
- int m_LastDigBlockY;
- int m_LastDigBlockZ;
+ Vector3i m_LastDigBlockPos;
enum eState
{
@@ -586,10 +582,10 @@ private:
void StreamChunk(int a_ChunkX, int a_ChunkZ, cChunkSender::Priority a_Priority);
/** Handles the DIG_STARTED dig packet: */
- void HandleBlockDigStarted (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
+ void HandleBlockDigStarted (Vector3i a_BlockPos, eBlockFace a_BlockFace);
/** Handles the DIG_FINISHED dig packet: */
- void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
+ void HandleBlockDigFinished(Vector3i a_BlockPos, eBlockFace a_BlockFace);
/** The clients will receive a finished dig animation */
void FinishDigAnimation();
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 07460fe98..376f431eb 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2322,15 +2322,15 @@ void cPlayer::LoadRank(void)
-void cPlayer::SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Range)
+void cPlayer::SendBlocksAround(Vector3i a_BlockPos, int a_Range)
{
// Collect the coords of all the blocks to send:
sSetBlockVector blks;
- for (int y = a_BlockY - a_Range + 1; y < a_BlockY + a_Range; y++)
+ for (int y = a_BlockPos.y - a_Range + 1; y < a_BlockPos.y + a_Range; y++)
{
- for (int z = a_BlockZ - a_Range + 1; z < a_BlockZ + a_Range; z++)
+ for (int z = a_BlockPos.z - a_Range + 1; z < a_BlockPos.z + a_Range; z++)
{
- for (int x = a_BlockX - a_Range + 1; x < a_BlockX + a_Range; x++)
+ for (int x = a_BlockPos.x - a_Range + 1; x < a_BlockPos.x + a_Range; x++)
{
blks.emplace_back(x, y, z, E_BLOCK_AIR, static_cast<NIBBLETYPE>(0)); // Use fake blocktype, it will get set later on.
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 2f2b9d62e..87b3accda 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -554,7 +554,7 @@ public:
/** Sends the block in the specified range around the specified coord to the client
as a block change packet.
The blocks in range (a_BlockX - a_Range, a_BlockX + a_Range) are sent (NY-metric). */
- void SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Range = 1);
+ void SendBlocksAround(Vector3i a_BlockPos, int a_Range = 1);
bool HasSkinPart(eSkinPart a_Part) const { return (m_SkinParts & a_Part) != 0; }
int GetSkinParts(void) const { return m_SkinParts; }
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 745f7de13..ea59c9c46 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -75,7 +75,7 @@ protected:
{
Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block
- if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, Face, Intersection))
+ if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockPos, Face, Intersection))
{
return false;
}
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 639661b24..e7fa0fe38 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -165,13 +165,13 @@ public:
// Wash away anything that was there prior to placing:
if (cFluidSimulator::CanWashAway(CurrentBlockType))
{
- if (a_PluginInterface.CallHookPlayerBreakingBlock(*a_Player, BlockPos.x, BlockPos.y, BlockPos.z, EntryFace, CurrentBlockType, CurrentBlockMeta))
+ if (a_PluginInterface.CallHookPlayerBreakingBlock(*a_Player, BlockPos, EntryFace, CurrentBlockType, CurrentBlockMeta))
{
// Plugin disagrees with the washing-away
return false;
}
a_World->DropBlockAsPickups(BlockPos, a_Player, nullptr);
- a_PluginInterface.CallHookPlayerBrokenBlock(*a_Player, BlockPos.x, BlockPos.y, BlockPos.z, EntryFace, CurrentBlockType, CurrentBlockMeta);
+ a_PluginInterface.CallHookPlayerBrokenBlock(*a_Player, BlockPos, EntryFace, CurrentBlockType, CurrentBlockMeta);
}
// Place the actual fluid block:
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 73065bb14..67d4b2a43 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -1075,7 +1075,7 @@ void cItemHandler::OnPlayerPlace(cPlayer & a_Player, const cItem & a_HeldItem, c
{
// Tried to place a block into another?
// Happens when you place a block aiming at side of block with a torch on it or stem beside it.
- a_Player.SendBlocksAround(PlacePosition.x, PlacePosition.y, PlacePosition.z, 2);
+ a_Player.SendBlocksAround(PlacePosition, 2);
a_Player.GetInventory().SendEquippedSlot();
return;
}
diff --git a/src/Items/ItemPumpkin.h b/src/Items/ItemPumpkin.h
index d467cd94f..2effb4989 100644
--- a/src/Items/ItemPumpkin.h
+++ b/src/Items/ItemPumpkin.h
@@ -25,7 +25,7 @@ private:
if (TrySpawnGolem(a_Player, a_PlacePosition))
{
// The client thinks that they placed the pumpkin, let them know it's been replaced:
- a_Player.SendBlocksAround(a_PlacePosition.x, a_PlacePosition.y, a_PlacePosition.z);
+ a_Player.SendBlocksAround(a_PlacePosition);
return true;
}
diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h
index 5d521bb3b..8cda673dd 100644
--- a/src/Items/ItemSign.h
+++ b/src/Items/ItemSign.h
@@ -55,7 +55,7 @@ private:
}
// After successfully placing the sign, open the sign editor for the player:
- a_Player.GetClientHandle()->SendEditSign(a_PlacePosition.x, a_PlacePosition.y, a_PlacePosition.z);
+ a_Player.GetClientHandle()->SendEditSign(a_PlacePosition);
return true;
}
diff --git a/src/Items/ItemSlab.h b/src/Items/ItemSlab.h
index 88dbef1e4..e0a405fe0 100644
--- a/src/Items/ItemSlab.h
+++ b/src/Items/ItemSlab.h
@@ -30,7 +30,7 @@ private:
return false;
}
- a_Player.SendBlocksAround(a_PlacePosition.x, a_PlacePosition.y, a_PlacePosition.z, 2); // (see below)
+ a_Player.SendBlocksAround(a_PlacePosition, 2); // (see below)
return true;
}
@@ -44,7 +44,7 @@ private:
direction of the clicked block face of a block ignoring build collision, rather than replacing said block.
Resend blocks to the client to fix the bug.
Ref.: https://forum.cuberite.org/thread-434-post-17388.html#pid17388 */
- a_Player.SendBlocksAround(a_PlacePosition.x, a_PlacePosition.y, a_PlacePosition.z, 2);
+ a_Player.SendBlocksAround(a_PlacePosition, 2);
return true;
}
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 4acc0546a..df6bd2bee 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -357,9 +357,9 @@ public:
// Sending stuff to clients (alphabetically sorted):
virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) = 0;
- virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) = 0;
- virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) = 0;
- virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
+ virtual void SendBlockAction (Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) = 0;
+ virtual void SendBlockBreakAnim (UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage) = 0;
+ virtual void SendBlockChange (Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) = 0;
virtual void SendBossBarAdd (UInt32 a_UniqueID, const cCompositeChat & a_Title, float a_FractionFilled, BossBarColor a_Color, BossBarDivisionType a_DivisionType, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) = 0;
virtual void SendBossBarRemove (UInt32 a_UniqueID) = 0;
@@ -376,7 +376,7 @@ public:
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) = 0;
virtual void SendDisconnect (const AString & a_Reason) = 0;
- virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; ///< Request the client to open up the sign editor for the sign (1.6+)
+ virtual void SendEditSign (Vector3i a_BlockPos) = 0; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration) = 0;
virtual void SendEntityAnimation (const cEntity & a_Entity, EntityAnimation a_Animation) = 0;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
@@ -399,7 +399,7 @@ public:
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) = 0;
virtual void SendPaintingSpawn (const cPainting & a_Painting) = 0;
virtual void SendPlayerAbilities (void) = 0;
- virtual void SendParticleEffect (const AString & a_SoundName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) = 0;
+ virtual void SendParticleEffect (const AString & a_SoundName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount) = 0;
virtual void SendParticleEffect (const AString & a_SoundName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) = 0;
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) = 0;
virtual void SendPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) = 0;
@@ -425,19 +425,19 @@ public:
virtual void SendSetRawSubTitle (const AString & a_SubTitle) = 0;
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 (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
+ virtual void SendSoundEffect (const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch) = 0;
+ virtual void SendSoundParticleEffect (const EffectID a_EffectID, Vector3i a_Origin, int a_Data) = 0;
virtual void SendSpawnEntity (const cEntity & a_Entity) = 0;
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
virtual void SendStatistics (const StatisticsManager & a_Manager) = 0;
virtual void SendTabCompletionResults (const AStringVector & a_Results) = 0;
- virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
+ virtual void SendThunderbolt (Vector3i a_Origin) = 0;
virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) = 0;
virtual void SendTimeUpdate (cTickTimeLong a_WorldAge, cTickTimeLong a_WorldDate, bool a_DoDaylightCycle) = 0;
virtual void SendUnleashEntity (const cEntity & a_Entity) = 0;
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) = 0;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) = 0;
- virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) = 0;
+ virtual void SendUpdateSign (Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) = 0;
virtual void SendUnlockRecipe (UInt32 a_RecipeID) = 0;
virtual void SendInitRecipes (UInt32 a_RecipeID) = 0;
virtual void SendWeather (eWeather a_Weather) = 0;
diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp
index 4f3e1a52b..beca6db24 100644
--- a/src/Protocol/Protocol_1_10.cpp
+++ b/src/Protocol/Protocol_1_10.cpp
@@ -311,16 +311,16 @@ namespace Metadata
////////////////////////////////////////////////////////////////////////////////
// cProtocol_1_10_0:
-void cProtocol_1_10_0::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
+void cProtocol_1_10_0::SendSoundEffect(const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktSoundEffect);
Pkt.WriteString(a_SoundName);
Pkt.WriteVarInt32(0); // Master sound category (may want to be changed to a parameter later)
- Pkt.WriteBEInt32(FloorC(a_X * 8.0));
- Pkt.WriteBEInt32(FloorC(a_Y * 8.0));
- Pkt.WriteBEInt32(FloorC(a_Z * 8.0));
+ Pkt.WriteBEInt32(FloorC(a_Origin.x * 8.0));
+ Pkt.WriteBEInt32(FloorC(a_Origin.y * 8.0));
+ Pkt.WriteBEInt32(FloorC(a_Origin.z * 8.0));
Pkt.WriteBEFloat(a_Volume);
Pkt.WriteBEFloat(a_Pitch);
}
diff --git a/src/Protocol/Protocol_1_10.h b/src/Protocol/Protocol_1_10.h
index f4ede2949..48bc4d7f6 100644
--- a/src/Protocol/Protocol_1_10.h
+++ b/src/Protocol/Protocol_1_10.h
@@ -30,7 +30,7 @@ public:
protected:
- 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 SendSoundEffect(const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch) override;
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override;
virtual Version GetProtocolVersion() const override;
diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp
index 2ccc4483a..cde4b38e3 100644
--- a/src/Protocol/Protocol_1_11.cpp
+++ b/src/Protocol/Protocol_1_11.cpp
@@ -368,7 +368,7 @@ void cProtocol_1_11_0::SendEntityAnimation(const cEntity & a_Entity, const Entit
const auto Position = a_Entity.GetPosition();
// 1.11 dropped the automatic particle effect + sound on item break. Emulate at least some of it:
- SendSoundEffect("entity.item.break", Position.x, Position.y, Position.z, 1, 0.75f + ((a_Entity.GetUniqueID() * 23) % 32) / 64.f);
+ SendSoundEffect("entity.item.break", Position, 1, 0.75f + ((a_Entity.GetUniqueID() * 23) % 32) / 64.f);
break;
}
default: break;
@@ -588,8 +588,8 @@ cProtocol::Version cProtocol_1_11_0::GetProtocolVersion() const
void cProtocol_1_11_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
{
- int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadXYZPosition64(BlockX, BlockY, BlockZ))
+ Vector3i Position;
+ if (!a_ByteBuffer.ReadXYZPosition64(Position))
{
return;
}
@@ -600,7 +600,7 @@ void cProtocol_1_11_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorY);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorZ);
- m_Client->HandleRightClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), FloorC(CursorX * 16), FloorC(CursorY * 16), FloorC(CursorZ * 16), Hand == 0);
+ m_Client->HandleRightClick(Position, FaceIntToBlockFace(Face), FloorC(CursorX * 16), FloorC(CursorY * 16), FloorC(CursorZ * 16), Hand == 0);
}
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp
index bee1a49bb..d6d25dc3e 100644
--- a/src/Protocol/Protocol_1_13.cpp
+++ b/src/Protocol/Protocol_1_13.cpp
@@ -74,10 +74,10 @@ Implements the 1.13 protocol classes:
////////////////////////////////////////////////////////////////////////////////
// cProtocol_1_13:
-void cProtocol_1_13::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cProtocol_1_13::SendBlockChange(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
cPacketizer Pkt(*this, pktBlockChange);
- Pkt.WriteXYZPosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteXYZPosition64(a_BlockPos);
Pkt.WriteVarInt32(GetProtocolBlockType(a_BlockType, a_BlockMeta));
}
diff --git a/src/Protocol/Protocol_1_13.h b/src/Protocol/Protocol_1_13.h
index 88d21c1db..63f1281b6 100644
--- a/src/Protocol/Protocol_1_13.h
+++ b/src/Protocol/Protocol_1_13.h
@@ -36,7 +36,7 @@ public:
protected:
- virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
+ virtual void SendBlockChange (Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
diff --git a/src/Protocol/Protocol_1_14.cpp b/src/Protocol/Protocol_1_14.cpp
index f38227edd..2c6451e56 100644
--- a/src/Protocol/Protocol_1_14.cpp
+++ b/src/Protocol/Protocol_1_14.cpp
@@ -24,7 +24,7 @@ Implements the 1.14 protocol classes:
////////////////////////////////////////////////////////////////////////////////
// cProtocol_1_14:
-void cProtocol_1_14::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
+void cProtocol_1_14::SendBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
}
@@ -32,7 +32,7 @@ void cProtocol_1_14::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, c
-void cProtocol_1_14::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
+void cProtocol_1_14::SendBlockBreakAnim(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage)
{
}
@@ -40,7 +40,7 @@ void cProtocol_1_14::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_B
-void cProtocol_1_14::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cProtocol_1_14::SendEditSign(Vector3i a_BlockPos)
{
}
@@ -104,7 +104,7 @@ void cProtocol_1_14::SendPaintingSpawn(const cPainting & a_Painting)
-void cProtocol_1_14::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+void cProtocol_1_14::SendSoundParticleEffect(const EffectID a_EffectID, Vector3i a_Origin, int a_Data)
{
}
@@ -120,7 +120,7 @@ void cProtocol_1_14::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
-void cProtocol_1_14::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
+void cProtocol_1_14::SendUpdateSign(Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
}
diff --git a/src/Protocol/Protocol_1_14.h b/src/Protocol/Protocol_1_14.h
index f4907a7d0..2effea504 100644
--- a/src/Protocol/Protocol_1_14.h
+++ b/src/Protocol/Protocol_1_14.h
@@ -30,15 +30,15 @@ public:
protected:
- virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
- virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
- virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
+ virtual void SendBlockAction (Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
+ virtual void SendBlockBreakAnim (UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage) override;
+ virtual void SendEditSign (Vector3i a_BlockPos) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityAnimation (const cEntity & a_Entity, EntityAnimation a_Animation) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
- virtual void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
+ virtual void SendSoundParticleEffect (const EffectID a_EffectID, Vector3i a_Origin, int a_Data) override;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override;
- virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
+ virtual void SendUpdateSign (Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual UInt32 GetPacketID(ePacketType a_PacketType) const override;
virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID) const override;
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index a84dadf53..41217ec9c 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -212,12 +212,12 @@ void cProtocol_1_8_0::SendAttachEntity(const cEntity & a_Entity, const cEntity &
-void cProtocol_1_8_0::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
+void cProtocol_1_8_0::SendBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktBlockAction);
- Pkt.WriteXYZPosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteXYZPosition64(a_BlockPos);
Pkt.WriteBEInt8(a_Byte1);
Pkt.WriteBEInt8(a_Byte2);
Pkt.WriteVarInt32(a_BlockType);
@@ -227,13 +227,13 @@ void cProtocol_1_8_0::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ,
-void cProtocol_1_8_0::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
+void cProtocol_1_8_0::SendBlockBreakAnim(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktBlockBreakAnim);
Pkt.WriteVarInt32(a_EntityID);
- Pkt.WriteXYZPosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteXYZPosition64(a_BlockPos);
Pkt.WriteBEInt8(a_Stage);
}
@@ -241,12 +241,12 @@ void cProtocol_1_8_0::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_
-void cProtocol_1_8_0::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cProtocol_1_8_0::SendBlockChange(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktBlockChange);
- Pkt.WriteXYZPosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteXYZPosition64(a_BlockPos);
Pkt.WriteVarInt32((static_cast<UInt32>(a_BlockType) << 4) | (static_cast<UInt32>(a_BlockMeta) & 15));
}
@@ -486,12 +486,12 @@ void cProtocol_1_8_0::SendDisconnect(const AString & a_Reason)
-void cProtocol_1_8_0::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cProtocol_1_8_0::SendEditSign(Vector3i a_BlockPos)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktEditSign);
- Pkt.WriteXYZPosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteXYZPosition64(a_BlockPos);
}
@@ -979,19 +979,19 @@ void cProtocol_1_8_0::SendPlayerAbilities(void)
-void cProtocol_1_8_0::SendParticleEffect(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)
+void cProtocol_1_8_0::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktParticleEffect);
Pkt.WriteBEInt32(GetProtocolParticleID(a_ParticleName));
Pkt.WriteBool(false);
- Pkt.WriteBEFloat(a_SrcX);
- Pkt.WriteBEFloat(a_SrcY);
- Pkt.WriteBEFloat(a_SrcZ);
- Pkt.WriteBEFloat(a_OffsetX);
- Pkt.WriteBEFloat(a_OffsetY);
- Pkt.WriteBEFloat(a_OffsetZ);
+ Pkt.WriteBEFloat(a_Src.x);
+ Pkt.WriteBEFloat(a_Src.y);
+ Pkt.WriteBEFloat(a_Src.z);
+ Pkt.WriteBEFloat(a_Offset.x);
+ Pkt.WriteBEFloat(a_Offset.y);
+ Pkt.WriteBEFloat(a_Offset.z);
Pkt.WriteBEFloat(a_ParticleData);
Pkt.WriteBEInt32(a_ParticleAmount);
}
@@ -1389,15 +1389,15 @@ void cProtocol_1_8_0::SendSetRawTitle(const AString & a_Title)
-void cProtocol_1_8_0::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
+void cProtocol_1_8_0::SendSoundEffect(const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktSoundEffect);
Pkt.WriteString(a_SoundName);
- Pkt.WriteBEInt32(static_cast<Int32>(a_X * 8.0));
- Pkt.WriteBEInt32(static_cast<Int32>(a_Y * 8.0));
- Pkt.WriteBEInt32(static_cast<Int32>(a_Z * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Origin.x * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Origin.y * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Origin.z * 8.0));
Pkt.WriteBEFloat(a_Volume);
Pkt.WriteBEUInt8(static_cast<Byte>(a_Pitch * 63));
}
@@ -1406,13 +1406,13 @@ void cProtocol_1_8_0::SendSoundEffect(const AString & a_SoundName, double a_X, d
-void cProtocol_1_8_0::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+void cProtocol_1_8_0::SendSoundParticleEffect(const EffectID a_EffectID, Vector3i a_Origin, int a_Data)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktSoundParticleEffect);
Pkt.WriteBEInt32(static_cast<int>(a_EffectID));
- Pkt.WriteXYZPosition64(a_SrcX, a_SrcY, a_SrcZ);
+ Pkt.WriteXYZPosition64(a_Origin);
Pkt.WriteBEInt32(a_Data);
Pkt.WriteBool(false);
}
@@ -1536,16 +1536,16 @@ void cProtocol_1_8_0::SendTabCompletionResults(const AStringVector & a_Results)
-void cProtocol_1_8_0::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cProtocol_1_8_0::SendThunderbolt(Vector3i a_Origin)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktSpawnGlobalEntity);
Pkt.WriteVarInt32(0); // EntityID = 0, always
Pkt.WriteBEUInt8(1); // Type = Thunderbolt
- Pkt.WriteFPInt(a_BlockX);
- Pkt.WriteFPInt(a_BlockY);
- Pkt.WriteFPInt(a_BlockZ);
+ Pkt.WriteFPInt(a_Origin.x);
+ Pkt.WriteFPInt(a_Origin.y);
+ Pkt.WriteFPInt(a_Origin.z);
}
@@ -1649,12 +1649,12 @@ void cProtocol_1_8_0::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
-void cProtocol_1_8_0::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
+void cProtocol_1_8_0::SendUpdateSign(Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktUpdateSign);
- Pkt.WriteXYZPosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteXYZPosition64(a_BlockPos);
AString Lines[] = { a_Line1, a_Line2, a_Line3, a_Line4 };
for (size_t i = 0; i < ARRAYCOUNT(Lines); i++)
@@ -2342,15 +2342,15 @@ void cProtocol_1_8_0::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status);
- int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadXYZPosition64(BlockX, BlockY, BlockZ))
+ Vector3i Position;
+ if (!a_ByteBuffer.ReadXYZPosition64(Position))
{
return;
}
HANDLE_READ(a_ByteBuffer, ReadBEInt8, Int8, Face);
- m_Client->HandleLeftClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), Status);
+ m_Client->HandleLeftClick(Position, FaceIntToBlockFace(Face), Status);
}
@@ -2359,8 +2359,8 @@ void cProtocol_1_8_0::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
void cProtocol_1_8_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
{
- int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadXYZPosition64(BlockX, BlockY, BlockZ))
+ Vector3i BlockPos;
+ if (!a_ByteBuffer.ReadXYZPosition64(BlockPos))
{
return;
}
@@ -2381,7 +2381,7 @@ void cProtocol_1_8_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
}
else
{
- m_Client->HandleRightClick(BlockX, BlockY, BlockZ, blockFace, CursorX, CursorY, CursorZ, true);
+ m_Client->HandleRightClick(BlockPos, blockFace, CursorX, CursorY, CursorZ, true);
}
}
@@ -2681,8 +2681,8 @@ void cProtocol_1_8_0::HandlePacketTabComplete(cByteBuffer & a_ByteBuffer)
void cProtocol_1_8_0::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer)
{
- int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadXYZPosition64(BlockX, BlockY, BlockZ))
+ Vector3i Position;
+ if (!a_ByteBuffer.ReadXYZPosition64(Position))
{
return;
}
@@ -2699,7 +2699,7 @@ void cProtocol_1_8_0::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer)
}
}
- m_Client->HandleUpdateSign(BlockX, BlockY, BlockZ, Lines[0], Lines[1], Lines[2], Lines[3]);
+ m_Client->HandleUpdateSign(Position, Lines[0], Lines[1], Lines[2], Lines[3]);
}
@@ -2843,7 +2843,7 @@ void cProtocol_1_8_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, con
HANDLE_READ(a_ByteBuffer, ReadBool, bool, TrackOutput);
// Editing a command-block:
- m_Client->HandleCommandBlockBlockChange(BlockX, BlockY, BlockZ, Command);
+ m_Client->HandleCommandBlockBlockChange({BlockX, BlockY, BlockZ}, Command);
return;
}
case 0x01:
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index 6ee1fdcaf..f32754d87 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -41,9 +41,9 @@ public:
// Sending stuff to clients (alphabetically sorted):
virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) override;
- virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
- virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
- virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
+ virtual void SendBlockAction (Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
+ virtual void SendBlockBreakAnim (UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage) override;
+ virtual void SendBlockChange (Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
virtual void SendBossBarAdd (UInt32 a_UniqueID, const cCompositeChat & a_Title, float a_FractionFilled, BossBarColor a_Color, BossBarDivisionType a_DivisionType, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override;
virtual void SendBossBarRemove (UInt32 a_UniqueID) override;
@@ -60,7 +60,7 @@ public:
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
virtual void SendDisconnect (const AString & a_Reason) override;
- virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
+ virtual void SendEditSign (Vector3i a_BlockPos) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityAnimation (const cEntity & a_Entity, EntityAnimation a_Animation) override;
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
@@ -85,7 +85,7 @@ public:
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
virtual void SendPlayerAbilities (void) override;
- virtual void SendParticleEffect (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) override;
+ virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) override;
@@ -102,7 +102,7 @@ public:
virtual void SendResetTitle (void) override;
virtual void SendResourcePack (const AString & a_ResourcePackUrl) override;
virtual void SendRespawn (eDimension a_Dimension) 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 SendSoundEffect (const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch) override;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override;
virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override;
@@ -110,18 +110,18 @@ 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 (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
+ virtual void SendSoundParticleEffect (const EffectID a_EffectID, Vector3i a_Origin, int a_Data) override;
virtual void SendSpawnEntity (const cEntity & a_Entity) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendStatistics (const StatisticsManager & a_Manager) override;
virtual void SendTabCompletionResults (const AStringVector & a_Results) override;
- virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ virtual void SendThunderbolt (Vector3i a_BlockPos) override;
virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override;
virtual void SendTimeUpdate (cTickTimeLong a_WorldAge, cTickTimeLong a_WorldDate, bool a_DoDaylightCycle) override;
virtual void SendUnleashEntity (const cEntity & a_Entity) override;
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override;
- virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
+ virtual void SendUpdateSign (Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual void SendUnlockRecipe (UInt32 a_RecipeID) override;
virtual void SendInitRecipes (UInt32 a_RecipeID) override;
virtual void SendWeather (eWeather a_Weather) override;
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index ad304b4ac..5e630f457 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -557,16 +557,16 @@ void cProtocol_1_9_0::SendPlayerSpawn(const cPlayer & a_Player)
-void cProtocol_1_9_0::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
+void cProtocol_1_9_0::SendSoundEffect(const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktSoundEffect);
Pkt.WriteString(a_SoundName);
Pkt.WriteVarInt32(0); // Master sound category (may want to be changed to a parameter later)
- Pkt.WriteBEInt32(static_cast<Int32>(a_X * 8.0));
- Pkt.WriteBEInt32(static_cast<Int32>(a_Y * 8.0));
- Pkt.WriteBEInt32(static_cast<Int32>(a_Z * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Origin.x * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Origin.y * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Origin.z * 8.0));
Pkt.WriteBEFloat(a_Volume);
Pkt.WriteBEUInt8(static_cast<Byte>(a_Pitch * 63));
}
@@ -611,16 +611,16 @@ void cProtocol_1_9_0::SendSpawnMob(const cMonster & a_Mob)
-void cProtocol_1_9_0::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cProtocol_1_9_0::SendThunderbolt(Vector3i a_Origin)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktSpawnGlobalEntity);
Pkt.WriteVarInt32(0); // EntityID = 0, always
Pkt.WriteBEUInt8(1); // Type = Thunderbolt
- Pkt.WriteBEDouble(a_BlockX);
- Pkt.WriteBEDouble(a_BlockY);
- Pkt.WriteBEDouble(a_BlockZ);
+ Pkt.WriteBEDouble(a_Origin.x);
+ Pkt.WriteBEDouble(a_Origin.y);
+ Pkt.WriteBEDouble(a_Origin.z);
}
@@ -873,14 +873,14 @@ void cProtocol_1_9_0::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status);
- int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadXYZPosition64(BlockX, BlockY, BlockZ))
+ Vector3i Position;
+ if (!a_ByteBuffer.ReadXYZPosition64(Position))
{
return;
}
HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Face);
- m_Client->HandleLeftClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), Status);
+ m_Client->HandleLeftClick(Position, FaceIntToBlockFace(Face), Status);
}
@@ -889,8 +889,8 @@ void cProtocol_1_9_0::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
void cProtocol_1_9_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
{
- int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadXYZPosition64(BlockX, BlockY, BlockZ))
+ Vector3i Position;
+ if (!a_ByteBuffer.ReadXYZPosition64(Position))
{
return;
}
@@ -901,7 +901,7 @@ void cProtocol_1_9_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorY);
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorZ);
- m_Client->HandleRightClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), CursorX, CursorY, CursorZ, Hand == MAIN_HAND);
+ m_Client->HandleRightClick(Position, FaceIntToBlockFace(Face), CursorX, CursorY, CursorZ, Hand == MAIN_HAND);
}
@@ -1074,8 +1074,8 @@ void cProtocol_1_9_0::HandlePacketTabComplete(cByteBuffer & a_ByteBuffer)
void cProtocol_1_9_0::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer)
{
- int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadXYZPosition64(BlockX, BlockY, BlockZ))
+ Vector3i Position;
+ if (!a_ByteBuffer.ReadXYZPosition64(Position))
{
return;
}
@@ -1087,7 +1087,7 @@ void cProtocol_1_9_0::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer)
Lines[i] = Line;
}
- m_Client->HandleUpdateSign(BlockX, BlockY, BlockZ, Lines[0], Lines[1], Lines[2], Lines[3]);
+ m_Client->HandleUpdateSign(Position, Lines[0], Lines[1], Lines[2], Lines[3]);
}
@@ -1246,7 +1246,7 @@ void cProtocol_1_9_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, std
HANDLE_READ(a_ByteBuffer, ReadBool, bool, Conditional);
HANDLE_READ(a_ByteBuffer, ReadBool, bool, Automatic);
- m_Client->HandleCommandBlockBlockChange(BlockX, BlockY, BlockZ, Command);
+ m_Client->HandleCommandBlockBlockChange({BlockX, BlockY, BlockZ}, Command);
}
else if (a_Channel == "PickItem")
{
@@ -2401,19 +2401,19 @@ cProtocol::Version cProtocol_1_9_2::GetProtocolVersion() const
////////////////////////////////////////////////////////////////////////////////
// cProtocol_1_9_4:
-void cProtocol_1_9_4::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
+void cProtocol_1_9_4::SendUpdateSign(Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
ASSERT(m_State == 3); // In game mode?
// 1.9.4 removed the update sign packet and now uses Update Block Entity
cPacketizer Pkt(*this, pktUpdateBlockEntity);
- Pkt.WriteXYZPosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteXYZPosition64(a_BlockPos);
Pkt.WriteBEUInt8(9); // Action 9 - update sign
cFastNBTWriter Writer;
- Writer.AddInt("x", a_BlockX);
- Writer.AddInt("y", a_BlockY);
- Writer.AddInt("z", a_BlockZ);
+ Writer.AddInt("x", a_BlockPos.x);
+ Writer.AddInt("y", a_BlockPos.y);
+ Writer.AddInt("z", a_BlockPos.z);
Writer.AddString("id", "Sign");
Json::Value Line1;
diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h
index 6dfa51811..5f4bbed59 100644
--- a/src/Protocol/Protocol_1_9.h
+++ b/src/Protocol/Protocol_1_9.h
@@ -54,9 +54,9 @@ public:
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPermissionLevel() override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) 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 SendSoundEffect (const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
- virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ virtual void SendThunderbolt (Vector3i a_Origin) override;
virtual void SendUnleashEntity (const cEntity & a_Entity) override;
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
@@ -175,7 +175,7 @@ public:
protected:
- virtual void SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
+ virtual void SendUpdateSign(Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual UInt32 GetPacketID(ePacketType a_Packet) const override;
virtual Version GetProtocolVersion() const override;
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 9ce7cb10d..d1eb8618c 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -342,7 +342,7 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, Vector3i a_RelPos)
if (CanStartFireInBlock(a_Chunk, dstRelPos))
{
auto dstAbsPos = a_Chunk->RelativeToAbsolute(dstRelPos);
- if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(m_World, dstAbsPos.x, dstAbsPos.y, dstAbsPos.z, ssFireSpread))
+ if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(m_World, dstAbsPos, ssFireSpread))
{
return;
}
@@ -386,7 +386,7 @@ void cFireSimulator::RemoveFuelNeighbors(cChunk * a_Chunk, Vector3i a_RelPos)
}
bool ShouldReplaceFuel = (GetRandomProvider().RandBool(m_ReplaceFuelChance * (1.0 / MAX_CHANCE_REPLACE_FUEL)));
- if (ShouldReplaceFuel && !cRoot::Get()->GetPluginManager()->CallHookBlockSpread(m_World, absPos.x, absPos.y, absPos.z, ssFireSpread))
+ if (ShouldReplaceFuel && !cRoot::Get()->GetPluginManager()->CallHookBlockSpread(m_World, absPos, ssFireSpread))
{
neighbor->SetBlock(relPos, E_BLOCK_FIRE, 0);
}
diff --git a/src/World.cpp b/src/World.cpp
index 8ed179050..d0cca09db 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2544,7 +2544,7 @@ void cWorld::ChunkLoadFailed(int a_ChunkX, int a_ChunkZ)
-bool cWorld::SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
+bool cWorld::SetSignLines(Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
{
// TODO: rvalue these strings
@@ -2553,13 +2553,13 @@ bool cWorld::SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AStrin
AString Line3(a_Line3);
AString Line4(a_Line4);
- if (cRoot::Get()->GetPluginManager()->CallHookUpdatingSign(*this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4, a_Player))
+ if (cRoot::Get()->GetPluginManager()->CallHookUpdatingSign(*this, a_BlockPos, Line1, Line2, Line3, Line4, a_Player))
{
return false;
}
if (
- DoWithBlockEntityAt({ a_BlockX, a_BlockY, a_BlockZ }, [&Line1, &Line2, &Line3, &Line4](cBlockEntity & a_BlockEntity)
+ DoWithBlockEntityAt(a_BlockPos, [&Line1, &Line2, &Line3, &Line4](cBlockEntity & a_BlockEntity)
{
if ((a_BlockEntity.GetBlockType() != E_BLOCK_WALLSIGN) && (a_BlockEntity.GetBlockType() != E_BLOCK_SIGN_POST))
{
@@ -2571,7 +2571,7 @@ bool cWorld::SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AStrin
})
)
{
- cRoot::Get()->GetPluginManager()->CallHookUpdatedSign(*this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4, a_Player);
+ cRoot::Get()->GetPluginManager()->CallHookUpdatedSign(*this, a_BlockPos, Line1, Line2, Line3, Line4, a_Player);
return true;
}
diff --git a/src/World.h b/src/World.h
index 84c184819..a8a6e1b14 100644
--- a/src/World.h
+++ b/src/World.h
@@ -311,10 +311,19 @@ public:
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ);
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be nullptr. Returns true if sign text changed. */
- bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = nullptr); // Exported in ManualBindings.cpp
+ bool SetSignLines(Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = nullptr);
+ bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = nullptr) // Exported in ManualBindings.cpp
+ {
+ return SetSignLines({a_BlockX, a_BlockY, a_BlockZ}, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
+ }
+
/** Sets the command block command. Returns true if command changed. */
bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export
+ bool SetCommandBlockCommand(Vector3i a_BlockPos, const AString & a_Command)
+ {
+ return SetCommandBlockCommand(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Command);
+ }
/** Is the trapdoor open? Returns false if there is no trapdoor at the specified coords. */
bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export