1
0

BroadcastBlockBreakAnimation and BroadcastBlockEntity use vectors (#4038)

This commit is contained in:
Bond-009 2017-09-25 18:17:45 +02:00 committed by Mattes D
parent 463fa48aec
commit 10c5c1227e
13 changed files with 62 additions and 67 deletions

View File

@ -43,14 +43,12 @@ void cBedEntity::SendTo(cClientHandle & a_Client)
void cBedEntity::SetColor(short a_Color) void cBedEntity::SetColor(short a_Color)
{ {
m_Color = a_Color; m_Color = a_Color;
int posX = m_PosX; auto Pos = GetPos();
int posY = m_PosY;
int posZ = m_PosZ;
// If the bed entity is send immediately, the client (maybe) still has not the bed. // If the bed entity is send immediately, the client (maybe) still has not the bed.
// Fix that by delaying the broadcast of the bed entity by a tick: // Fix that by delaying the broadcast of the bed entity by a tick:
m_World->ScheduleTask(1, [posX, posY, posZ](cWorld & a_World) m_World->ScheduleTask(1, [Pos](cWorld & a_World)
{ {
a_World.BroadcastBlockEntity(posX, posY, posZ); a_World.BroadcastBlockEntity(Pos);
}); });
} }

View File

@ -52,7 +52,7 @@ void cCommandBlockEntity::SetCommand(const AString & a_Cmd)
Just documenting my experience in getting this to work :P Just documenting my experience in getting this to work :P
*/ */
m_World->BroadcastBlockEntity(GetPosX(), GetPosY(), GetPosZ()); m_World->BroadcastBlockEntity(GetPos());
} }
@ -61,7 +61,7 @@ void cCommandBlockEntity::SetCommand(const AString & a_Cmd)
void cCommandBlockEntity::SetLastOutput(const AString & a_LastOut) void cCommandBlockEntity::SetLastOutput(const AString & a_LastOut)
{ {
m_World->BroadcastBlockEntity(GetPosX(), GetPosY(), GetPosZ()); m_World->BroadcastBlockEntity(GetPos());
m_LastOutput = a_LastOut; m_LastOutput = a_LastOut;
} }

View File

@ -67,7 +67,7 @@ bool cFlowerPotEntity::UsedBy(cPlayer * a_Player)
{ {
a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().RemoveOneEquippedItem();
} }
m_World->BroadcastBlockEntity(m_PosX, m_PosY, m_PosZ, a_Player->GetClientHandle()); m_World->BroadcastBlockEntity(GetPos(), a_Player->GetClientHandle());
} }
return true; return true;
} }

View File

@ -58,7 +58,7 @@ void cMobHeadEntity::SetType(const eMobHeadType & a_Type)
m_OwnerUUID = cUUID{}; m_OwnerUUID = cUUID{};
} }
m_Type = a_Type; m_Type = a_Type;
m_World->BroadcastBlockEntity(m_PosX, m_PosY, m_PosZ); m_World->BroadcastBlockEntity(GetPos());
} }
@ -68,7 +68,7 @@ void cMobHeadEntity::SetType(const eMobHeadType & a_Type)
void cMobHeadEntity::SetRotation(eMobHeadRotation a_Rotation) void cMobHeadEntity::SetRotation(eMobHeadRotation a_Rotation)
{ {
m_Rotation = a_Rotation; m_Rotation = a_Rotation;
m_World->BroadcastBlockEntity(m_PosX, m_PosY, m_PosZ); m_World->BroadcastBlockEntity(GetPos());
} }
@ -96,7 +96,7 @@ void cMobHeadEntity::SetOwner(const cPlayer & a_Owner)
} }
} }
m_World->BroadcastBlockEntity(m_PosX, m_PosY, m_PosZ); m_World->BroadcastBlockEntity(GetPos());
} }
@ -114,7 +114,7 @@ void cMobHeadEntity::SetOwner(const cUUID & a_OwnerUUID, const AString & a_Owner
m_OwnerName = a_OwnerName; m_OwnerName = a_OwnerName;
m_OwnerTexture = a_OwnerTexture; m_OwnerTexture = a_OwnerTexture;
m_OwnerTextureSignature = a_OwnerTextureSignature; m_OwnerTextureSignature = a_OwnerTextureSignature;
m_World->BroadcastBlockEntity(m_PosX, m_PosY, m_PosZ); m_World->BroadcastBlockEntity(GetPos());
} }
@ -124,7 +124,7 @@ void cMobHeadEntity::SetOwner(const cUUID & a_OwnerUUID, const AString & a_Owner
void cMobHeadEntity::SendTo(cClientHandle & a_Client) void cMobHeadEntity::SendTo(cClientHandle & a_Client)
{ {
cWorld * World = a_Client.GetPlayer()->GetWorld(); cWorld * World = a_Client.GetPlayer()->GetWorld();
a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, m_BlockType, World->GetBlockMeta(m_PosX, m_PosY, m_PosZ)); a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, m_BlockType, World->GetBlockMeta(GetPos()));
a_Client.SendUpdateBlockEntity(*this); a_Client.SendUpdateBlockEntity(*this);
} }

View File

@ -122,7 +122,7 @@ bool cMobSpawnerEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
void cMobSpawnerEntity::ResetTimer(void) void cMobSpawnerEntity::ResetTimer(void)
{ {
m_SpawnDelay = GetRandomProvider().RandInt<short>(200, 800); m_SpawnDelay = GetRandomProvider().RandInt<short>(200, 800);
m_World->BroadcastBlockEntity(m_PosX, m_PosY, m_PosZ); m_World->BroadcastBlockEntity(GetPos());
} }

View File

@ -494,7 +494,7 @@ void cChunk::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock
auto clone = be->Clone(posX, posY, posZ); auto clone = be->Clone(posX, posY, posZ);
clone->SetWorld(m_World); clone->SetWorld(m_World);
AddBlockEntityClean(clone); AddBlockEntityClean(clone);
BroadcastBlockEntity(posX, posY, posZ); BroadcastBlockEntity({posX, posY, posZ});
} }
} }
} }
@ -1942,7 +1942,7 @@ bool cChunk::SetSignLines(int a_PosX, int a_PosY, int a_PosZ, const AString & a_
MarkDirty(); MarkDirty();
auto Sign = static_cast<cSignEntity *>(Entity); auto Sign = static_cast<cSignEntity *>(Entity);
Sign->SetLines(a_Line1, a_Line2, a_Line3, a_Line4); Sign->SetLines(a_Line1, a_Line2, a_Line3, a_Line4);
m_World->BroadcastBlockEntity(a_PosX, a_PosY, a_PosZ); m_World->BroadcastBlockEntity({a_PosX, a_PosY, a_PosZ});
return true; return true;
} }
@ -2713,7 +2713,7 @@ void cChunk::BroadcastBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte
void cChunk::BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude) void cChunk::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage, const cClientHandle * a_Exclude)
{ {
for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{ {
@ -2721,7 +2721,7 @@ void cChunk::BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a
{ {
continue; continue;
} }
(*itr)->SendBlockBreakAnim(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage); (*itr)->SendBlockBreakAnim(a_EntityID, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Stage);
} // for itr - LoadedByClient[] } // for itr - LoadedByClient[]
} }
@ -2729,10 +2729,10 @@ void cChunk::BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a
void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude) void cChunk::BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
{ {
// We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list // We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); cBlockEntity * Entity = GetBlockEntity(a_BlockPos);
if (Entity == nullptr) if (Entity == nullptr)
{ {
return; return;

View File

@ -341,8 +341,8 @@ public:
// (Please keep these alpha-sorted) // (Please keep these alpha-sorted)
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle); void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle);
void BroadcastBlockAction (Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); void BroadcastBlockAction (Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr); void BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); void BroadcastBlockEntity (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr);
void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr); void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr); void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle); void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
@ -368,7 +368,7 @@ public:
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
Vector3i PositionToWorldPosition(const Vector3i & a_RelPos) Vector3i PositionToWorldPosition(Vector3i a_RelPos)
{ {
return PositionToWorldPosition(a_RelPos.x, a_RelPos.y, a_RelPos.z); return PositionToWorldPosition(a_RelPos.x, a_RelPos.y, a_RelPos.z);
} }

View File

@ -325,36 +325,33 @@ void cChunkMap::BroadcastBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_B
void cChunkMap::BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude) void cChunkMap::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage, const cClientHandle * a_Exclude)
{ {
cCSLock Lock(m_CSChunks); cCSLock Lock(m_CSChunks);
int ChunkX, ChunkZ; cChunkCoords ChunkPos = cChunkDef::BlockToChunk(a_BlockPos);
cChunkPtr Chunk = GetChunkNoGen(ChunkPos);
cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
if (Chunk == nullptr) if (Chunk == nullptr)
{ {
return; return;
} }
// It's perfectly legal to broadcast packets even to invalid chunks! // It's perfectly legal to broadcast packets even to invalid chunks!
Chunk->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude); Chunk->BroadcastBlockBreakAnimation(a_EntityID, a_BlockPos, a_Stage, a_Exclude);
} }
void cChunkMap::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude) void cChunkMap::BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
{ {
cCSLock Lock(m_CSChunks); cCSLock Lock(m_CSChunks);
int ChunkX, ChunkZ; cChunkCoords ChunkPos = cChunkDef::BlockToChunk(a_BlockPos);
cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, ChunkX, ChunkZ); cChunkPtr Chunk = GetChunkNoGen(ChunkPos);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
if ((Chunk == nullptr) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
return; return;
} }
Chunk->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude); Chunk->BroadcastBlockEntity(a_BlockPos, a_Exclude);
} }

View File

@ -72,8 +72,8 @@ public:
// (Please keep these alpha-sorted) // (Please keep these alpha-sorted)
void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle); void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle);
void BroadcastBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); void BroadcastBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr); void BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude); void BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude);
void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr); void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr);
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr); void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle); void BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle);

View File

@ -1257,7 +1257,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
m_BlockDigAnimY = a_BlockY; m_BlockDigAnimY = a_BlockY;
m_BlockDigAnimZ = a_BlockZ; m_BlockDigAnimZ = a_BlockZ;
m_BlockDigAnimStage = 0; 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_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ}, 0, this);
cWorld * World = m_Player->GetWorld(); cWorld * World = m_Player->GetWorld();
cChunkInterface ChunkInterface(World->GetChunkMap()); cChunkInterface ChunkInterface(World->GetChunkMap());
@ -1371,7 +1371,7 @@ void cClientHandle::FinishDigAnimation()
// End dig animation // End dig animation
m_BlockDigAnimStage = -1; m_BlockDigAnimStage = -1;
// It seems that 10 ends block animation // 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_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ}, 10, this);
} }
m_BlockDigAnimX = -1; m_BlockDigAnimX = -1;
@ -2160,7 +2160,7 @@ void cClientHandle::Tick(float a_Dt)
} }
if (m_BlockDigAnimStage / 1000 != lastAnimVal / 1000) 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_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ}, static_cast<char>(m_BlockDigAnimStage / 1000), this);
} }
} }

View File

@ -38,7 +38,7 @@ public:
// If the placed head is a wither, try to spawn the wither first: // If the placed head is a wither, try to spawn the wither first:
if (a_EquippedItem.m_ItemDamage == E_META_HEAD_WITHER) if (a_EquippedItem.m_ItemDamage == E_META_HEAD_WITHER)
{ {
if (TrySpawnWitherAround(a_World, a_Player, placedX, placedY, placedZ)) if (TrySpawnWitherAround(a_World, a_Player, {placedX, placedY, placedZ}))
{ {
return true; return true;
} }
@ -82,7 +82,7 @@ public:
MobHeadEntity.SetType(HeadType); MobHeadEntity.SetType(HeadType);
MobHeadEntity.SetRotation(static_cast<eMobHeadRotation>(Rotation)); MobHeadEntity.SetRotation(static_cast<eMobHeadRotation>(Rotation));
MobHeadEntity.GetWorld()->BroadcastBlockEntity(MobHeadEntity.GetPosX(), MobHeadEntity.GetPosY(), MobHeadEntity.GetPosZ()); MobHeadEntity.GetWorld()->BroadcastBlockEntity(MobHeadEntity.GetPos());
return false; return false;
} }
); );
@ -93,11 +93,11 @@ public:
Returns true if the wither was created. */ Returns true if the wither was created. */
bool TrySpawnWitherAround( bool TrySpawnWitherAround(
cWorld & a_World, cPlayer & a_Player, cWorld & a_World, cPlayer & a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ Vector3i a_BlockPos
) )
{ {
// No wither can be created at Y < 2 - not enough space for the formula: // No wither can be created at Y < 2 - not enough space for the formula:
if (a_BlockY < 2) if (a_BlockPos.y < 2)
{ {
return false; return false;
} }
@ -111,17 +111,17 @@ public:
{ 0, 0, 1}, { 0, 0, 1},
{ 0, 0, -1}, { 0, 0, -1},
}; };
for (size_t i = 0; i < ARRAYCOUNT(RelCoords); ++i) for (auto & RelCoord : RelCoords)
{ {
if (TrySpawnWitherAt( if (TrySpawnWitherAt(
a_World, a_Player, a_World, a_Player,
a_BlockX, a_BlockY, a_BlockZ, a_BlockPos,
RelCoords[i].x, RelCoords[i].z RelCoord.x, RelCoord.z
)) ))
{ {
return true; return true;
} }
} // for i - Coords[] } // for i - RelCoords[]
return false; return false;
} }
@ -134,7 +134,7 @@ public:
Returns true iff the wither was created successfully. */ Returns true iff the wither was created successfully. */
bool TrySpawnWitherAt( bool TrySpawnWitherAt(
cWorld & a_World, cPlayer & a_Player, cWorld & a_World, cPlayer & a_Player,
int a_PlacedHeadX, int a_PlacedHeadY, int a_PlacedHeadZ, Vector3i a_PlacedHeadPos,
int a_OffsetX, int a_OffsetZ int a_OffsetX, int a_OffsetZ
) )
{ {
@ -170,12 +170,12 @@ public:
return ( return (
TrySpawnWitherFromImage( TrySpawnWitherFromImage(
a_World, a_Player, ImageWitherX, ARRAYCOUNT(ImageWitherX), a_World, a_Player, ImageWitherX, ARRAYCOUNT(ImageWitherX),
a_PlacedHeadX, a_PlacedHeadY, a_PlacedHeadZ, a_PlacedHeadPos,
a_OffsetX, a_OffsetZ a_OffsetX, a_OffsetZ
) || ) ||
TrySpawnWitherFromImage( TrySpawnWitherFromImage(
a_World, a_Player, ImageWitherZ, ARRAYCOUNT(ImageWitherZ), a_World, a_Player, ImageWitherZ, ARRAYCOUNT(ImageWitherZ),
a_PlacedHeadX, a_PlacedHeadY, a_PlacedHeadZ, a_PlacedHeadPos,
a_OffsetX, a_OffsetZ a_OffsetX, a_OffsetZ
) )
); );
@ -189,7 +189,7 @@ public:
Returns true iff the wither was created successfully. */ Returns true iff the wither was created successfully. */
bool TrySpawnWitherFromImage( bool TrySpawnWitherFromImage(
cWorld & a_World, cPlayer & a_Player, const sSetBlock * a_Image, size_t a_ImageCount, cWorld & a_World, cPlayer & a_Player, const sSetBlock * a_Image, size_t a_ImageCount,
int a_PlacedHeadX, int a_PlacedHeadY, int a_PlacedHeadZ, Vector3i a_PlacedHeadPos,
int a_OffsetX, int a_OffsetZ int a_OffsetX, int a_OffsetZ
) )
{ {
@ -199,12 +199,12 @@ public:
for (size_t i = 0; i < a_ImageCount; i++) for (size_t i = 0; i < a_ImageCount; i++)
{ {
// Get the absolute coords of the image: // Get the absolute coords of the image:
int BlockX = a_PlacedHeadX + a_OffsetX + a_Image[i].GetX(); int BlockX = a_PlacedHeadPos.x + a_OffsetX + a_Image[i].GetX();
int BlockY = a_PlacedHeadY + a_Image[i].GetY(); int BlockY = a_PlacedHeadPos.y + a_Image[i].GetY();
int BlockZ = a_PlacedHeadZ + a_OffsetZ + a_Image[i].GetZ(); int BlockZ = a_PlacedHeadPos.z + a_OffsetZ + a_Image[i].GetZ();
// If the query is for the placed head, short-circuit-evaluate it: // If the query is for the placed head, short-circuit-evaluate it:
if ((BlockX == a_PlacedHeadX) && (BlockY == a_PlacedHeadY) && (BlockZ == a_PlacedHeadZ)) if ((BlockX == a_PlacedHeadPos.x) && (BlockY == a_PlacedHeadPos.y) && (BlockZ == a_PlacedHeadPos.z))
{ {
if (a_Image[i].m_BlockType != E_BLOCK_HEAD) if (a_Image[i].m_BlockType != E_BLOCK_HEAD)
{ {
@ -256,18 +256,18 @@ public:
} }
// Spawn the wither: // Spawn the wither:
int BlockX = a_PlacedHeadX + a_OffsetX; int BlockX = a_PlacedHeadPos.x + a_OffsetX;
int BlockZ = a_PlacedHeadZ + a_OffsetZ; int BlockZ = a_PlacedHeadPos.z + a_OffsetZ;
a_World.SpawnMob(static_cast<double>(BlockX) + 0.5, a_PlacedHeadY - 2, static_cast<double>(BlockZ) + 0.5, mtWither, false); a_World.SpawnMob(static_cast<double>(BlockX) + 0.5, a_PlacedHeadPos.y - 2, static_cast<double>(BlockZ) + 0.5, mtWither, false);
AwardSpawnWitherAchievement(a_World, BlockX, a_PlacedHeadY - 2, BlockZ); AwardSpawnWitherAchievement(a_World, {BlockX, a_PlacedHeadPos.y - 2, BlockZ});
return true; return true;
} }
/** Awards the achievement to all players close to the specified point. */ /** Awards the achievement to all players close to the specified point. */
void AwardSpawnWitherAchievement(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ) void AwardSpawnWitherAchievement(cWorld & a_World, Vector3i a_BlockPos)
{ {
Vector3f Pos{ static_cast<float>(a_BlockX), static_cast<float>(a_BlockY), static_cast<float>(a_BlockZ) }; Vector3f Pos(a_BlockPos);
a_World.ForEachPlayer([=](cPlayer & a_Player) a_World.ForEachPlayer([=](cPlayer & a_Player)
{ {
// If player is close, award achievement: // If player is close, award achievement:

View File

@ -2420,18 +2420,18 @@ void cWorld::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, Byte
void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude) void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage, const cClientHandle * a_Exclude)
{ {
m_ChunkMap->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude); m_ChunkMap->BroadcastBlockBreakAnimation(a_EntityID, a_BlockPos, a_Stage, a_Exclude);
} }
void cWorld::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude) void cWorld::BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
{ {
m_ChunkMap->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude); m_ChunkMap->BroadcastBlockEntity(a_BlockPos, a_Exclude);
} }

View File

@ -163,8 +163,8 @@ public:
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle); void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle);
void BroadcastBlockAction (Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export void BroadcastBlockAction (Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr); void BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude void BroadcastBlockEntity (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
// tolua_begin // tolua_begin
void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = nullptr, eMessageType a_ChatPrefix = mtCustom); void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = nullptr, eMessageType a_ChatPrefix = mtCustom);