1
0

Properly deprecate more XYZ parameter'd functions (#5147)

* Fixes #5144
This commit is contained in:
Tiger Wang 2021-03-15 02:28:18 +00:00 committed by GitHub
parent c729d7abde
commit 45591cbe7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 530 additions and 296 deletions

View File

@ -1198,7 +1198,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
Type = "number",
},
},
Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!",
Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it! <b>OBSOLETE</b>, use the vector-based overload instead.",
},
{
Params =
@ -1499,7 +1499,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
Type = "number",
},
},
Notes = "Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded.",
Notes = "Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded. <b>OBSOLETE</b>, use the vector-based overload instead.",
},
{
Params =
@ -1543,7 +1543,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
Type = "number",
},
},
Notes = "Returns the amount of block light at the specified coords, or 0 if the appropriate chunk is not loaded.",
Notes = "Returns the amount of block light at the specified coords, or 0 if the appropriate chunk is not loaded. <b>OBSOLETE</b>, use the vector-based overload instead.",
},
{
Params =
@ -1628,7 +1628,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
Type = "number",
},
},
Notes = "Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded.",
Notes = "Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded. <b>OBSOLETE</b>, use the vector-based overload instead.",
},
{
Params =
@ -3742,7 +3742,6 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
},
},
WakeUpSimulators =
{
{
Params =
{
@ -3753,27 +3752,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
},
Notes = "Wakes up the simulators for the specified block.",
},
{
Params =
{
{
Name = "BlockX",
Type = "number",
},
{
Name = "BlockY",
Type = "number",
},
{
Name = "BlockZ",
Type = "number",
},
},
Notes = "Wakes up the simulators for the specified block. (DEPRECATED, use vector-parametered version)",
},
},
WakeUpSimulatorsInArea =
{
{
Params =
{
@ -3784,37 +3763,6 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
},
Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive).",
},
{
Params =
{
{
Name = "MinBlockX",
Type = "number",
},
{
Name = "MaxBlockX",
Type = "number",
},
{
Name = "MinBlockY",
Type = "number",
},
{
Name = "MaxBlockY",
Type = "number",
},
{
Name = "MinBlockZ",
Type = "number",
},
{
Name = "MaxBlockZ",
Type = "number",
},
},
Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive). (DEPRECATED, use vector-parametered version)",
},
},
},
AdditionalInfo =
{

View File

@ -507,6 +507,65 @@ static int tolua_cWorld_DoWithNearestPlayer(lua_State * tolua_S)
static int tolua_cWorld_FastSetBlock(lua_State * tolua_S)
{
/* Function signature:
World:FastSetBlock(BlockX, BlockY, BlockZ)
--or--
World:FastSetBlock(Position)
*/
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamNumber(OffsetIndex, OffsetIndex + 1) ||
!L.CheckParamEnd(OffsetIndex + 2)
)
{
return 0;
}
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlockBlockLight with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
BLOCKTYPE Type;
NIBBLETYPE Meta;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position) ||
!L.GetStackValues(OffsetIndex, Type, Meta)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
if (!cChunkDef::IsValidHeight(Position.y))
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
}
World->FastSetBlock(Position, Type, Meta);
return 0;
}
static int tolua_cWorld_ForEachLoadedChunk(lua_State * tolua_S)
{
// Exported manually, because tolua doesn't support converting functions to functor types.
@ -561,37 +620,171 @@ static int tolua_cWorld_ForEachLoadedChunk(lua_State * tolua_S)
static int tolua_cWorld_GetBlockInfo(lua_State * tolua_S)
static int tolua_cWorld_GetBlock(lua_State * tolua_S)
{
// Exported manually, because tolua would generate useless additional parameters (a_BlockType .. a_BlockSkyLight)
// Function signature: GetBlockInfo(BlockX, BlockY, BlockZ) -> BlockValid, [BlockType, BlockMeta, BlockSkyLight, BlockBlockLight]
/* Function signature:
World:GetBlock(BlockX, BlockY, BlockZ) -> BlockType
--or--
World:GetBlock(Position) -> BlockType
*/
// Check params:
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamUserType(1, "cWorld") ||
!L.CheckParamNumber(2, 4) ||
!L.CheckParamEnd(5)
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamEnd(OffsetIndex)
)
{
return 0;
}
// Get params:
cWorld * Self = nullptr;
int BlockX = 0;
int BlockY = 0;
int BlockZ = 0;
L.GetStackValues(1, Self, BlockX, BlockY, BlockZ);
if (Self == nullptr)
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlock with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
// Call the function:
if (!cChunkDef::IsValidHeight(Position.y))
{
L.Push(E_BLOCK_AIR);
return 1;
}
L.Push(World->GetBlock(Position));
return 1;
}
static int tolua_cWorld_GetBlockBlockLight(lua_State * tolua_S)
{
/* Function signature:
World:GetBlockBlockLight(BlockX, BlockY, BlockZ) -> BlockLight
--or--
World:GetBlockBlockLight(Position) -> BlockLight
*/
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamEnd(OffsetIndex)
)
{
return 0;
}
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlockBlockLight with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
if (!cChunkDef::IsValidHeight(Position.y))
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
}
L.Push(World->GetBlockBlockLight(Position));
return 1;
}
static int tolua_cWorld_GetBlockInfo(lua_State * tolua_S)
{
/* Exported manually, because tolua would generate useless additional parameters (a_BlockType .. a_BlockSkyLight)
Function signature:
GetBlockInfo(BlockX, BlockY, BlockZ) -> BlockValid, [BlockType, BlockMeta, BlockSkyLight, BlockBlockLight]
--or--
GetBlockInfo(Position) -> BlockValid, [BlockType, BlockMeta, BlockSkyLight, BlockBlockLight]
*/
// Check params:
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamEnd(OffsetIndex)
)
{
return 0;
}
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlockInfo with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
if (!cChunkDef::IsValidHeight(Position.y))
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
}
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta, BlockSkyLight, BlockBlockLight;
bool res = Self->GetBlockInfo(BlockX, BlockY, BlockZ, BlockType, BlockMeta, BlockSkyLight, BlockBlockLight);
// Call the function:
bool res = World->GetBlockInfo(Position, BlockType, BlockMeta, BlockSkyLight, BlockBlockLight);
// Push the returned values:
L.Push(res);
@ -607,37 +800,172 @@ static int tolua_cWorld_GetBlockInfo(lua_State * tolua_S)
static int tolua_cWorld_GetBlockTypeMeta(lua_State * tolua_S)
static int tolua_cWorld_GetBlockMeta(lua_State * tolua_S)
{
// Exported manually, because tolua would generate useless additional parameters (a_BlockType, a_BlockMeta)
// Function signature: GetBlockTypeMeta(BlockX, BlockY, BlockZ) -> BlockValid, [BlockType, BlockMeta]
/* Function signature:
World:GetBlockMeta(BlockX, BlockY, BlockZ) -> BlockMeta
--or--
World:GetBlockMeta(Position) -> BlockMeta
*/
// Check params:
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamUserType(1, "cWorld") ||
!L.CheckParamNumber(2, 4) ||
!L.CheckParamEnd(5)
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamEnd(OffsetIndex)
)
{
return 0;
}
// Get params:
cWorld * Self = nullptr;
int BlockX = 0;
int BlockY = 0;
int BlockZ = 0;
L.GetStackValues(1, Self, BlockX, BlockY, BlockZ);
if (Self == nullptr)
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlockMeta with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
// Call the function:
if (!cChunkDef::IsValidHeight(Position.y))
{
L.Push(0);
return 1;
}
L.Push(World->GetBlockMeta(Position));
return 1;
}
static int tolua_cWorld_GetBlockSkyLight(lua_State * tolua_S)
{
/* Function signature:
World:GetBlockSkyLight(BlockX, BlockY, BlockZ) -> BlockLight
--or--
World:GetBlockSkyLight(Position) -> BlockLight
*/
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamEnd(OffsetIndex)
)
{
return 0;
}
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlockSkyLight with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
if (!cChunkDef::IsValidHeight(Position.y))
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
}
L.Push(World->GetBlockSkyLight(Position));
return 1;
}
static int tolua_cWorld_GetBlockTypeMeta(lua_State * tolua_S)
{
/* Exported manually, because tolua would generate useless additional parameters (a_BlockType, a_BlockMeta)
Function signature:
GetBlockTypeMeta(BlockX, BlockY, BlockZ) -> BlockValid, [BlockType, BlockMeta]
--or--
GetBlockTypeMeta(Position) -> BlockValid, [BlockType, BlockMeta]
*/
// Check params:
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamEnd(OffsetIndex)
)
{
return 0;
}
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlockTypeMeta with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
if (!cChunkDef::IsValidHeight(Position.y))
{
L.Push(E_BLOCK_AIR, 0);
return 2;
}
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
bool res = Self->GetBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta);
// Call the function:
bool res = World->GetBlockTypeMeta(Position, BlockType, BlockMeta);
// Push the returned values:
L.Push(res);
@ -791,6 +1119,65 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
static int tolua_cWorld_SetBlock(lua_State * tolua_S)
{
/* Function signature:
World:SetBlock(BlockX, BlockY, BlockZ)
--or--
World:SetBlock(Position)
*/
cLuaState L(tolua_S);
int OffsetIndex;
if (
!L.CheckParamSelf("cWorld") ||
!CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
!L.CheckParamNumber(OffsetIndex, OffsetIndex + 1) ||
!L.CheckParamEnd(OffsetIndex + 2)
)
{
return 0;
}
if (OffsetIndex != 3) // Not the vector overload
{
L.LogStackTrace();
LOGWARN("GetBlockBlockLight with 3 position arguments is deprecated, use vector-parametered version instead.");
}
cWorld * World;
Vector3i Position;
BLOCKTYPE Type;
NIBBLETYPE Meta;
// Read the params:
if (
!L.GetStackValues(1, World) ||
!GetStackVectorOr3Numbers(L, 2, Position) ||
!L.GetStackValues(OffsetIndex, Type, Meta)
)
{
return 0;
}
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
}
if (!cChunkDef::IsValidHeight(Position.y))
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
}
World->SetBlock(Position, Type, Meta);
return 0;
}
static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
{
// Exported manually, because tolua would generate useless additional return values (a_Line1 .. a_Line4)
@ -978,6 +1365,7 @@ void cManualBindings::BindWorld(lua_State * tolua_S)
tolua_function(tolua_S, "DoWithNoteBlockAt", DoWithXYZ<cWorld, cNoteEntity, &cWorld::DoWithNoteBlockAt>);
tolua_function(tolua_S, "DoWithPlayer", DoWith< cWorld, cPlayer, &cWorld::DoWithPlayer>);
tolua_function(tolua_S, "DoWithPlayerByUUID", tolua_cWorld_DoWithPlayerByUUID);
tolua_function(tolua_S, "FastSetBlock", tolua_cWorld_FastSetBlock);
tolua_function(tolua_S, "FindAndDoWithPlayer", DoWith< cWorld, cPlayer, &cWorld::FindAndDoWithPlayer>);
tolua_function(tolua_S, "ForEachBlockEntityInChunk", ForEachInChunk<cWorld, cBlockEntity, &cWorld::ForEachBlockEntityInChunk>);
tolua_function(tolua_S, "ForEachBrewingstandInChunk", ForEachInChunk<cWorld, cBrewingstandEntity, &cWorld::ForEachBrewingstandInChunk>);
@ -988,12 +1376,17 @@ void cManualBindings::BindWorld(lua_State * tolua_S)
tolua_function(tolua_S, "ForEachFurnaceInChunk", ForEachInChunk<cWorld, cFurnaceEntity, &cWorld::ForEachFurnaceInChunk>);
tolua_function(tolua_S, "ForEachLoadedChunk", tolua_cWorld_ForEachLoadedChunk);
tolua_function(tolua_S, "ForEachPlayer", ForEach< cWorld, cPlayer, &cWorld::ForEachPlayer>);
tolua_function(tolua_S, "GetBlock", tolua_cWorld_GetBlock);
tolua_function(tolua_S, "GetBlockBlockLight", tolua_cWorld_GetBlockBlockLight);
tolua_function(tolua_S, "GetBlockInfo", tolua_cWorld_GetBlockInfo);
tolua_function(tolua_S, "GetBlockMeta", tolua_cWorld_GetBlockMeta);
tolua_function(tolua_S, "GetBlockSkyLight", tolua_cWorld_GetBlockSkyLight);
tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cWorld_GetBlockTypeMeta);
tolua_function(tolua_S, "GetSignLines", tolua_cWorld_GetSignLines);
tolua_function(tolua_S, "PrepareChunk", tolua_cWorld_PrepareChunk);
tolua_function(tolua_S, "QueueTask", tolua_cWorld_QueueTask);
tolua_function(tolua_S, "ScheduleTask", tolua_cWorld_ScheduleTask);
tolua_function(tolua_S, "SetBlock", tolua_cWorld_SetBlock);
tolua_function(tolua_S, "SetSignLines", tolua_cWorld_SetSignLines);
tolua_function(tolua_S, "SpawnSplitExperienceOrbs", tolua_cWorld_SpawnSplitExperienceOrbs);
tolua_function(tolua_S, "TryGetHeight", tolua_cWorld_TryGetHeight);

View File

@ -215,7 +215,7 @@ bool cChestEntity::IsBlocked()
return (
(GetPosY() < cChunkDef::Height - 1) &&
(
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPos().addedY(1))) ||
!cOcelot::IsCatSittingOnBlock(GetWorld(), Vector3d(GetPos()))
)
);

View File

@ -53,7 +53,7 @@ bool cEnderChestEntity::UsedBy(cPlayer * a_Player)
if (
(GetPosY() < cChunkDef::Height - 1) &&
(
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPos().addedY(1))) ||
!cOcelot::IsCatSittingOnBlock(GetWorld(), Vector3d(GetPos()))
)
)

View File

@ -48,7 +48,7 @@ void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld & a_World)
BLOCKTYPE pistonBlock;
NIBBLETYPE pistonMeta;
a_World.GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta);
a_World.GetBlockTypeMeta(a_BlockPos, pistonBlock, pistonMeta);
a_World.BroadcastBlockAction(a_BlockPos, PistonExtendAction, pistonMeta, pistonBlock);
}
@ -60,7 +60,7 @@ void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld & a_World)
{
BLOCKTYPE pistonBlock;
NIBBLETYPE pistonMeta;
World.GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta);
World.GetBlockTypeMeta(a_BlockPos, pistonBlock, pistonMeta);
if ((pistonBlock != E_BLOCK_PISTON) && !IsSticky(pistonBlock))
{
@ -86,11 +86,8 @@ void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld & a_World)
// Set the extension and the piston base correctly
Vector3i extensionPos = a_BlockPos + pushDir;
World.SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta | 0x8);
World.SetBlock(
extensionPos.x, extensionPos.y, extensionPos.z,
E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0)
);
World.SetBlock(a_BlockPos, pistonBlock, pistonMeta | 0x8);
World.SetBlock(extensionPos, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0));
// Play sound effect only if extended successfully
World.BroadcastSoundEffect("block.piston.extend", a_BlockPos, 0.5f, 0.7f);
@ -107,7 +104,7 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World)
{
BLOCKTYPE pistonBlock;
NIBBLETYPE pistonMeta;
a_World.GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta);
a_World.GetBlockTypeMeta(a_BlockPos, pistonBlock, pistonMeta);
a_World.BroadcastBlockAction(a_BlockPos, PistonRetractAction, pistonMeta, pistonBlock);
}
@ -115,7 +112,7 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World)
{
BLOCKTYPE pistonBlock;
NIBBLETYPE pistonMeta;
World.GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta);
World.GetBlockTypeMeta(a_BlockPos, pistonBlock, pistonMeta);
if ((pistonBlock != E_BLOCK_PISTON) && !IsSticky(pistonBlock))
{
@ -192,7 +189,7 @@ void cBlockPistonHandler::PushBlocks(
NIBBLETYPE moveMeta;
for (auto & moveBlockPos : sortedBlocks)
{
a_World.GetBlockTypeMeta(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, moveBlock, moveMeta);
a_World.GetBlockTypeMeta(moveBlockPos, moveBlock, moveMeta);
if (cBlockInfo::IsPistonBreakable(moveBlock))
{
@ -202,9 +199,9 @@ void cBlockPistonHandler::PushBlocks(
else
{
// Not breakable, just move it
a_World.SetBlock(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, E_BLOCK_AIR, 0);
a_World.SetBlock(moveBlockPos, E_BLOCK_AIR, 0);
moveBlockPos += a_PushDir;
a_World.SetBlock(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, moveBlock, moveMeta);
a_World.SetBlock(moveBlockPos, moveBlock, moveMeta);
}
}
}
@ -229,7 +226,7 @@ bool cBlockPistonHandler::CanPushBlock(
BLOCKTYPE currBlock;
NIBBLETYPE currMeta;
a_World.GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, currBlock, currMeta);
a_World.GetBlockTypeMeta(a_BlockPos, currBlock, currMeta);
if (!cChunkDef::IsValidHeight(a_BlockPos.y))
{

View File

@ -1293,8 +1293,7 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
{
ASSERT(!((a_RelX < 0) || (a_RelX >= cChunkDef::Width) || (a_RelY < 0) || (a_RelY >= cChunkDef::Height) || (a_RelZ < 0) || (a_RelZ >= cChunkDef::Width)));
ASSERT(cChunkDef::IsValidRelPos({ a_RelX, a_RelY, a_RelZ }));
ASSERT(IsValid());
const BLOCKTYPE OldBlockType = GetBlock(a_RelX, a_RelY, a_RelZ);

View File

@ -1003,7 +1003,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
if (
cChunkDef::IsValidHeight(BlockY) &&
cBlockHandler::For(m_Player->GetWorld()->GetBlock(BlockX, BlockY, BlockZ)).IsClickedThrough()
cBlockHandler::For(m_Player->GetWorld()->GetBlock({ BlockX, BlockY, BlockZ })).IsClickedThrough()
)
{
a_BlockX = BlockX;
@ -1140,7 +1140,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_BlockX, a_BlockY, a_BlockZ }, DiggingBlock, DiggingMeta);
if (
m_Player->IsGameModeCreative() &&
@ -1225,7 +1225,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_BlockX, a_BlockY, a_BlockZ }, DugBlock, DugMeta);
if (!m_Player->IsGameModeCreative())
{
@ -1977,7 +1977,7 @@ void cClientHandle::Tick(float 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_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ });
m_BreakProgress += m_Player->GetMiningProgressPerTick(Block);
}

View File

@ -153,7 +153,7 @@ void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
return;
}
if (IsBlockWater(m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT)))
if (IsBlockWater(m_World->GetBlock(POS_TOINT)))
{
if (GetSpeedY() < 2)
{

View File

@ -1308,7 +1308,7 @@ void cEntity::DetectCacti(void)
{
for (int y = MinY; y <= MaxY; y++)
{
if (GetWorld()->GetBlock(x, y, z) == E_BLOCK_CACTUS)
if (GetWorld()->GetBlock({ x, y, z }) == E_BLOCK_CACTUS)
{
TakeDamage(dtCactusContact, nullptr, 1, 0);
return;
@ -1337,7 +1337,7 @@ void cEntity::DetectMagma(void)
{
for (int y = MinY; y <= MaxY; y++)
{
if (GetWorld()->GetBlock(x, y, z) == E_BLOCK_MAGMA)
if (GetWorld()->GetBlock({ x, y, z }) == E_BLOCK_MAGMA)
{
TakeDamage(dtMagmaContact, nullptr, 1, 0);
return;
@ -1367,10 +1367,9 @@ bool cEntity::DetectPortal()
return false;
}
int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT;
if (cChunkDef::IsValidHeight(Y))
if (const auto Position = m_Position.Floor(); cChunkDef::IsValidHeight(Position.y))
{
switch (GetWorld()->GetBlock(X, Y, Z))
switch (GetWorld()->GetBlock(Position))
{
case E_BLOCK_NETHER_PORTAL:
{

View File

@ -23,7 +23,7 @@ void cFireChargeEntity::Explode(Vector3i a_Block)
{
if (m_World->GetBlock(a_Block) == E_BLOCK_AIR)
{
m_World->SetBlock(a_Block.x, a_Block.y, a_Block.z, E_BLOCK_FIRE, 1);
m_World->SetBlock(a_Block, E_BLOCK_FIRE, 1);
}
}

View File

@ -1241,7 +1241,7 @@ void cMinecart::OnRemoveFromWorld(cWorld & a_World)
{
if (m_bIsOnDetectorRail)
{
m_World->SetBlock(m_DetectorRailPosition.x, m_DetectorRailPosition.y, m_DetectorRailPosition.z, E_BLOCK_DETECTOR_RAIL, m_World->GetBlockMeta(m_DetectorRailPosition) & 0x07);
m_World->SetBlock(m_DetectorRailPosition, E_BLOCK_DETECTOR_RAIL, m_World->GetBlockMeta(m_DetectorRailPosition) & 0x07);
}
Super::OnRemoveFromWorld(a_World);

View File

@ -2200,16 +2200,14 @@ void cPlayer::HandleFloater()
bool cPlayer::IsClimbing(void) const
{
int PosX = POSX_TOINT;
int PosY = POSY_TOINT;
int PosZ = POSZ_TOINT;
const auto Position = GetPosition().Floor();
if ((PosY < 0) || (PosY >= cChunkDef::Height))
if (!cChunkDef::IsValidHeight(Position.y))
{
return false;
}
BLOCKTYPE Block = m_World->GetBlock(PosX, PosY, PosZ);
BLOCKTYPE Block = m_World->GetBlock(Position);
switch (Block)
{
case E_BLOCK_LADDER:
@ -2423,12 +2421,12 @@ bool cPlayer::DoesPlacingBlocksIntersectEntity(const sSetBlockVector & a_Blocks)
int y = blk.GetY();
int z = blk.GetZ();
cBoundingBox BlockBox = cBlockHandler::For(blk.m_BlockType).GetPlacementCollisionBox(
m_World->GetBlock(x - 1, y, z),
m_World->GetBlock(x + 1, y, z),
(y == 0) ? E_BLOCK_AIR : m_World->GetBlock(x, y - 1, z),
(y == cChunkDef::Height - 1) ? E_BLOCK_AIR : m_World->GetBlock(x, y + 1, z),
m_World->GetBlock(x, y, z - 1),
m_World->GetBlock(x, y, z + 1)
m_World->GetBlock({ x - 1, y, z }),
m_World->GetBlock({ x + 1, y, z }),
(y == 0) ? E_BLOCK_AIR : m_World->GetBlock({ x, y - 1, z }),
(y == cChunkDef::Height - 1) ? E_BLOCK_AIR : m_World->GetBlock({ x, y + 1, z }),
m_World->GetBlock({ x, y, z - 1 }),
m_World->GetBlock({ x, y, z + 1 })
);
BlockBox.Move(x, y, z);
@ -2591,9 +2589,9 @@ void cPlayer::Detach()
for (int z = PosZ - 1; z <= (PosZ + 1); ++z)
{
if (
(m_World->GetBlock(x, y, z) == E_BLOCK_AIR) &&
(m_World->GetBlock(x, y + 1, z) == E_BLOCK_AIR) &&
cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z))
(m_World->GetBlock({ x, y, z }) == E_BLOCK_AIR) &&
(m_World->GetBlock({ x, y + 1, z }) == E_BLOCK_AIR) &&
cBlockInfo::IsSolid(m_World->GetBlock({ x, y - 1, z }))
)
{
TeleportToCoords(x + 0.5, y, z + 0.5);
@ -2674,12 +2672,12 @@ float cPlayer::GetLiquidHeightPercent(NIBBLETYPE a_Meta)
bool cPlayer::IsInsideWater()
{
BLOCKTYPE Block = m_World->GetBlock(FloorC(GetPosX()), FloorC(m_Stance), FloorC(GetPosZ()));
BLOCKTYPE Block = m_World->GetBlock(Vector3d(GetPosX(), m_Stance, GetPosZ()).Floor());
if ((Block != E_BLOCK_WATER) && (Block != E_BLOCK_STATIONARY_WATER))
{
return false;
}
NIBBLETYPE Meta = GetWorld()->GetBlockMeta(FloorC(GetPosX()), FloorC(m_Stance), FloorC(GetPosZ()));
NIBBLETYPE Meta = GetWorld()->GetBlockMeta(Vector3d(GetPosX(), m_Stance, GetPosZ()).Floor());
float f = GetLiquidHeightPercent(Meta) - 0.11111111f;
float f1 = static_cast<float>(m_Stance + 1) - f;
bool flag = (m_Stance < f1);

View File

@ -76,13 +76,13 @@ public:
return false; // Nothing in range.
}
if (a_World->GetBlockMeta(BlockPos.x, BlockPos.y, BlockPos.z) != 0)
if (a_World->GetBlockMeta(BlockPos) != 0)
{
// Not a source block
return false;
}
BLOCKTYPE Block = a_World->GetBlock(BlockPos.x, BlockPos.y, BlockPos.z);
BLOCKTYPE Block = a_World->GetBlock(BlockPos);
ENUM_ITEM_TYPE NewItemType;
if (IsBlockWater(Block))

View File

@ -231,7 +231,7 @@ public:
// Query the world block:
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
if (!a_World.GetBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta))
if (!a_World.GetBlockTypeMeta({ BlockX, BlockY, BlockZ }, BlockType, BlockMeta))
{
// Cannot query block, assume unloaded chunk, fail to spawn the wither
return false;

View File

@ -541,26 +541,26 @@ void cMonster::HandleFalling()
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
int PosY = POSY_TOINT;
PosY = Clamp(PosY, 0, cChunkDef::Height);
auto Position = GetPosition().Floor();
Position.y = Clamp(Position.y, 0, cChunkDef::Height);
if (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ))))
if (!cBlockInfo::IsSolid(m_World->GetBlock(Position)))
{
while (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ))) && (PosY > 0))
while (!cBlockInfo::IsSolid(m_World->GetBlock(Position)) && (Position.y > 0))
{
PosY--;
Position.y--;
}
return PosY + 1;
return Position.y + 1;
}
else
{
while ((PosY < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock(static_cast<int>(floor(a_PosX)), PosY, static_cast<int>(floor(a_PosZ)))))
while ((Position.y < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock(Position)))
{
PosY++;
Position.y++;
}
return PosY;
return Position.y;
}
}

View File

@ -113,11 +113,11 @@ void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if (m_TimeToStopEating == 0)
{
if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
if (m_World->GetBlock({ PosX, PosY, PosZ }) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
{
// The sheep ate the grass so we change it to dirt
m_World->SetBlock(PosX, PosY, PosZ, E_BLOCK_DIRT, 0);
GetWorld()->BroadcastSoundParticleEffect(EffectID::PARTICLE_BLOCK_BREAK, {PosX, PosY, PosZ}, E_BLOCK_GRASS);
m_World->SetBlock({ PosX, PosY, PosZ }, E_BLOCK_DIRT, 0);
GetWorld()->BroadcastSoundParticleEffect(EffectID::PARTICLE_BLOCK_BREAK, { PosX, PosY, PosZ }, E_BLOCK_GRASS);
m_IsSheared = false;
m_World->BroadcastEntityMetadata(*this);
}
@ -127,7 +127,7 @@ void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (GetRandomProvider().RandBool(1.0 / 600.0))
{
if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS)
if (m_World->GetBlock({ PosX, PosY, PosZ }) == E_BLOCK_GRASS)
{
m_World->BroadcastEntityStatus(*this, esSheepEating);
m_TimeToStopEating = 40;

View File

@ -186,8 +186,8 @@ void cVillager::HandleFarmerTryHarvestCrops()
if (!m_PathfinderActivated && (GetPosition() - m_CropsPos).Length() < 2)
{
// Check if the blocks didn't change while the villager was walking to the coordinates.
BLOCKTYPE CropBlock = m_World->GetBlock(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z);
if (IsBlockFarmable(CropBlock) && m_World->GetBlockMeta(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z) == 0x7)
BLOCKTYPE CropBlock = m_World->GetBlock(m_CropsPos);
if (IsBlockFarmable(CropBlock) && m_World->GetBlockMeta(m_CropsPos) == 0x7)
{
m_World->DropBlockAsPickups(m_CropsPos, this, nullptr);
m_ActionCountDown = 20;
@ -202,9 +202,9 @@ void cVillager::HandleFarmerTryHarvestCrops()
void cVillager::HandleFarmerPlaceCrops()
{
// Check if there is still farmland at the spot where the crops were.
if (m_World->GetBlock(m_CropsPos.x, m_CropsPos.y - 1, m_CropsPos.z) == E_BLOCK_FARMLAND)
if (m_World->GetBlock(m_CropsPos.addedY(-1)) == E_BLOCK_FARMLAND)
{
m_World->SetBlock(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z, E_BLOCK_CROPS, 0);
m_World->SetBlock(m_CropsPos, E_BLOCK_CROPS, 0);
}
}

View File

@ -128,7 +128,7 @@ bool cNetherPortalScanner::IsValidBuildLocation(Vector3i a_BlockPos)
{
for (int j = 0; j < PortalLength; j++)
{
BLOCKTYPE blocktype = m_World.GetBlock(a_BlockPos.x + i, a_BlockPos.y, a_BlockPos.z + j);
BLOCKTYPE blocktype = m_World.GetBlock(a_BlockPos.addedXZ(i, j));
if (!cBlockInfo::IsSolid(blocktype))
{
return false;
@ -137,7 +137,7 @@ bool cNetherPortalScanner::IsValidBuildLocation(Vector3i a_BlockPos)
// Check the airspace
for (int k = 1; k < PortalHeight; k++)
{
blocktype = m_World.GetBlock(a_BlockPos.x + i, a_BlockPos.y + k, a_BlockPos.z + j);
blocktype = m_World.GetBlock(a_BlockPos + Vector3i(i, k, j));
if (blocktype != E_BLOCK_AIR)
{
return false;
@ -157,15 +157,15 @@ bool cNetherPortalScanner::OnAllChunksAvailable(void)
if (m_FoundPortal)
{
// Find the bottom of this portal
while (m_World.GetBlock(m_PortalLoc.x, m_PortalLoc.y, m_PortalLoc.z) == E_BLOCK_NETHER_PORTAL)
while (m_World.GetBlock(m_PortalLoc) == E_BLOCK_NETHER_PORTAL)
{
m_PortalLoc.y -= 1;
}
m_PortalLoc.y += 1;
// Figure out which way the portal is facing
int BXP = m_World.GetBlock(m_PortalLoc.x + 1, m_PortalLoc.y, m_PortalLoc.z);
int BXM = m_World.GetBlock(m_PortalLoc.x - 1, m_PortalLoc.y, m_PortalLoc.z);
int BXP = m_World.GetBlock(m_PortalLoc.addedX(1));
int BXM = m_World.GetBlock(m_PortalLoc.addedX(-1));
if ((BXP == E_BLOCK_NETHER_PORTAL) || (BXM == E_BLOCK_NETHER_PORTAL))
{
// The long axis is along X
@ -244,11 +244,11 @@ void cNetherPortalScanner::BuildNetherPortal(Vector3i a_Location, Direction a_Di
{
if (a_Direction == Direction::Y)
{
m_World.SetBlock(x + i, y + k, z + j, E_BLOCK_AIR, 0);
m_World.SetBlock({ x + i, y + k, z + j }, E_BLOCK_AIR, 0);
}
else if (a_Direction == Direction::X)
{
m_World.SetBlock(x + j, y + k, z + i, E_BLOCK_AIR, 0);
m_World.SetBlock({ x + j, y + k, z + i }, E_BLOCK_AIR, 0);
}
}
}
@ -262,11 +262,11 @@ void cNetherPortalScanner::BuildNetherPortal(Vector3i a_Location, Direction a_Di
// +2 on the short axis because that's where we deposit the entity
if (a_Direction == Direction::Y)
{
m_World.SetBlock(x + 2, y, z + j, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + 2, y, z + j }, E_BLOCK_OBSIDIAN, 0);
}
else if (a_Direction == Direction::X)
{
m_World.SetBlock(x + j, y, z + 2, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + j, y, z + 2 }, E_BLOCK_OBSIDIAN, 0);
}
}
}
@ -276,26 +276,26 @@ void cNetherPortalScanner::BuildNetherPortal(Vector3i a_Location, Direction a_Di
{
if (a_Direction == Direction::Y)
{
m_World.SetBlock(x + 1, y + i, z, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 1, y + i, z + 3, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + 1, y + i, z }, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + 1, y + i, z + 3 }, E_BLOCK_OBSIDIAN, 0);
}
else if (a_Direction == Direction::X)
{
m_World.SetBlock(x, y + i, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 3, y + i, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x, y + i, z + 1 }, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + 3, y + i, z + 1 }, E_BLOCK_OBSIDIAN, 0);
}
}
for (int i = 0; i < PortalLength; i++)
{
if (a_Direction == Direction::Y)
{
m_World.SetBlock(x + 1, y + 4, z + i, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 1, y, z + i, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + 1, y + 4, z + i }, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + 1, y, z + i }, E_BLOCK_OBSIDIAN, 0);
}
else if (a_Direction == Direction::X)
{
m_World.SetBlock(x + i, y + 4, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + i, y, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + i, y + 4, z + 1 }, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock({ x + i, y, z + 1 }, E_BLOCK_OBSIDIAN, 0);
}
}

View File

@ -137,7 +137,7 @@ Vector3f cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z)
return {};
}
if (!IsAllowedBlock(m_World.GetBlock(a_X, a_Y, a_Z))) // No Fluid -> No Flowing direction :D
if (!IsAllowedBlock(m_World.GetBlock({ a_X, a_Y, a_Z }))) // No Fluid -> No Flowing direction :D
{
return {};
}
@ -148,7 +148,7 @@ Vector3f cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z)
return ((a_BlockMeta & 0x08) != 0) ? 0 : a_BlockMeta;
};
auto BlockMeta = m_World.GetBlockMeta(a_X, a_Y, a_Z);
auto BlockMeta = m_World.GetBlockMeta({ a_X, a_Y, a_Z });
NIBBLETYPE CentralPoint = HeightFromMeta(BlockMeta);
NIBBLETYPE LevelPoint[4];

View File

@ -236,11 +236,11 @@ void cSandSimulator::FinishFalling(
{
ASSERT(a_BlockY < cChunkDef::Height);
BLOCKTYPE CurrentBlockType = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
BLOCKTYPE CurrentBlockType = a_World->GetBlock({ a_BlockX, a_BlockY, a_BlockZ });
if ((a_FallingBlockType == E_BLOCK_ANVIL) || IsReplacedOnRematerialization(CurrentBlockType))
{
// Rematerialize the material here:
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FallingBlockType, a_FallingBlockMeta);
a_World->SetBlock({ a_BlockX, a_BlockY, a_BlockZ }, a_FallingBlockType, a_FallingBlockMeta);
if (a_FallingBlockType == E_BLOCK_ANVIL)
{
a_World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_ANVIL_LAND, {a_BlockX, a_BlockY, a_BlockZ}, 0);

View File

@ -755,7 +755,7 @@ bool cWorld::CanSpawnAt(double a_X, double & a_Y, double a_Z)
for (int PotentialY = HighestSpawnPoint; PotentialY > LowestSpawnPoint; --PotentialY)
{
BLOCKTYPE HeadBlock = GetBlock(static_cast<int>(a_X), PotentialY, static_cast<int>(a_Z));
BLOCKTYPE HeadBlock = GetBlock({ static_cast<int>(a_X), PotentialY, static_cast<int>(a_Z) });
// Is this block safe for spawning
if (HeadBlock != E_BLOCK_AIR)
@ -763,7 +763,7 @@ bool cWorld::CanSpawnAt(double a_X, double & a_Y, double a_Z)
continue;
}
BLOCKTYPE BodyBlock = GetBlock(static_cast<int>(a_X), PotentialY - 1, static_cast<int>(a_Z));
BLOCKTYPE BodyBlock = GetBlock({ static_cast<int>(a_X), PotentialY - 1, static_cast<int>(a_Z) });
// Is this block safe for spawning
if (BodyBlock != E_BLOCK_AIR)
@ -771,7 +771,7 @@ bool cWorld::CanSpawnAt(double a_X, double & a_Y, double a_Z)
continue;
}
BLOCKTYPE FloorBlock = GetBlock(static_cast<int>(a_X), PotentialY - 2, static_cast<int>(a_Z));
BLOCKTYPE FloorBlock = GetBlock({ static_cast<int>(a_X), PotentialY - 2, static_cast<int>(a_Z) });
// Early out - Is the floor block air
if (FloorBlock == E_BLOCK_AIR)
@ -835,7 +835,7 @@ bool cWorld::CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ)
const int XPos = a_PosX + SurroundingCoords[CoordIndex].x;
const int ZPos = a_PosZ + SurroundingCoords[CoordIndex].z;
const BLOCKTYPE BlockType = GetBlock(XPos, a_PosY, ZPos);
const BLOCKTYPE BlockType = GetBlock({ XPos, a_PosY, ZPos });
if (cBlockInfo::IsSolid(BlockType) || IsBlockLiquid(BlockType))
{
return false;
@ -1295,16 +1295,6 @@ void cWorld::WakeUpSimulators(Vector3i a_Block)
void cWorld::WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ)
{
LOGWARNING("cWorld::WakeUpSimulatorsInArea(int, int, int) is deprecated, use cWorld::WakeUpSimulatorsInArea(Vector3i) instead.");
WakeUpSimulatorsInArea(cCuboid({a_MinBlockX, a_MinBlockY, a_MinBlockZ}, {a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ}));
}
void cWorld::WakeUpSimulatorsInArea(const cCuboid & a_Area)
{
m_SimulatorManager->WakeUp(a_Area);
@ -2684,7 +2674,7 @@ bool cWorld::IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ)
{
BLOCKTYPE Block;
NIBBLETYPE Meta;
GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta);
GetBlockTypeMeta({ a_BlockX, a_BlockY, a_BlockZ }, Block, Meta);
if ((Block != E_BLOCK_TRAPDOOR) && (Block != E_BLOCK_IRON_TRAPDOOR))
{
return false;
@ -2701,7 +2691,7 @@ bool cWorld::SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Op
{
BLOCKTYPE Block;
NIBBLETYPE Meta;
GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta);
GetBlockTypeMeta({ a_BlockX, a_BlockY, a_BlockZ }, Block, Meta);
if ((Block != E_BLOCK_TRAPDOOR) && (Block != E_BLOCK_IRON_TRAPDOOR))
{
return false;
@ -2710,8 +2700,8 @@ bool cWorld::SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Op
bool IsOpen = (Meta & 0x4) != 0;
if (a_Open != IsOpen)
{
SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta ^ 0x4);
BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_WOODEN_TRAPDOOR_OPEN, {a_BlockX, a_BlockY, a_BlockZ}, 0);
SetBlockMeta({ a_BlockX, a_BlockY, a_BlockZ }, Meta ^ 0x4);
BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_WOODEN_TRAPDOOR_OPEN, { a_BlockX, a_BlockY, a_BlockZ }, 0);
return true;
}
return false;
@ -2950,10 +2940,10 @@ void cWorld::QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, int a_T
bool cWorld::IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return (
IsBlockWater(GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ)) ||
IsBlockWater(GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ)) ||
IsBlockWater(GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1)) ||
IsBlockWater(GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1))
IsBlockWater(GetBlock({ a_BlockX - 1, a_BlockY, a_BlockZ })) ||
IsBlockWater(GetBlock({ a_BlockX + 1, a_BlockY, a_BlockZ })) ||
IsBlockWater(GetBlock({ a_BlockX, a_BlockY, a_BlockZ - 1 })) ||
IsBlockWater(GetBlock({ a_BlockX, a_BlockY, a_BlockZ + 1 }))
);
}

View File

@ -365,20 +365,10 @@ public:
/** Calls the callback for each loaded chunk. Returns true if all chunks have been processed successfully */
bool ForEachLoadedChunk(cFunctionRef<bool(int, int)> a_Callback);
// tolua_begin
/** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed. */
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
/** OBSOLETE, use the Vector3-based overload instead.
Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed. */
void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return SetBlock({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_BlockMeta);
}
/** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates, nor wake up simulators.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block) */
@ -387,15 +377,6 @@ public:
m_ChunkMap.FastSetBlock(a_BlockPos, a_BlockType, a_BlockMeta);
}
/** OBSOLETE, use the Vector3-based overload instead.
Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates, nor wake up simulators.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block) */
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return FastSetBlock({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_BlockMeta);
}
/** Returns the block type at the specified position.
Returns 0 if the chunk is not valid. */
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
@ -403,14 +384,6 @@ public:
return m_ChunkMap.GetBlock(a_BlockPos);
}
/** OBSOLETE, use the Vector3-based overload instead.
Returns the block type at the specified position.
Returns 0 if the chunk is not valid. */
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) const
{
return m_ChunkMap.GetBlock({a_BlockX, a_BlockY, a_BlockZ});
}
/** Returns the block meta at the specified position.
Returns 0 if the chunk is not valid. */
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos) const
@ -418,83 +391,30 @@ public:
return m_ChunkMap.GetBlockMeta(a_BlockPos);
}
/** OBSOLETE, use the Vector3-based overload instead.
Returns the block meta at the specified position.
Returns 0 if the chunk is not valid. */
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) const
{
return m_ChunkMap.GetBlockMeta({a_BlockX, a_BlockY, a_BlockZ});
}
/** Sets the meta for the specified block, while keeping the blocktype.
Ignored if the chunk is invalid. */
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData);
/** OBSOLETE, use the Vector3-based overload instead.
Sets the meta for the specified block, while keeping the blocktype.
Ignored if the chunk is invalid. */
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
{
return SetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}, a_MetaData);
}
/** Returns the sky light value at the specified block position.
The sky light is "raw" - not affected by time-of-day.
Returns 0 if chunk not valid. */
NIBBLETYPE GetBlockSkyLight(Vector3i a_BlockPos);
/** OBSOLETE, use the Vector3-based overload instead.
Returns the sky light value at the specified block position.
The sky light is "raw" - not affected by time-of-day.
Returns 0 if chunk not valid. */
NIBBLETYPE GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return GetBlockSkyLight({a_BlockX, a_BlockY, a_BlockZ});
}
/** Returns the block-light value at the specified block position.
Returns 0 if chunk not valid. */
NIBBLETYPE GetBlockBlockLight(Vector3i a_BlockPos);
/** OBSOLETE, use the Vector3-based overload instead.
Returns the block-light value at the specified block position.
Returns 0 if chunk not valid. */
NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return GetBlockBlockLight({a_BlockX, a_BlockY, a_BlockZ});
}
// tolua_end
/** Retrieves the block type and meta at the specified coords.
Stores the result into a_BlockType and a_BlockMeta.
Returns true if successful, false if chunk not present.
TODO: Export in ManualBindings_World.cpp. */
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
/** OBSOLETE, use the Vector3i-based overload instead.
Retrieves the block type and meta at the specified coords.
Stores the result into a_BlockType and a_BlockMeta.
Returns true if successful, false if chunk not present.
Exported in ManualBindings_World.cpp. */
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
return GetBlockTypeMeta({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_BlockMeta);
}
/** Queries the whole block specification from the world.
Returns true if all block info was retrieved successfully, false if not (invalid chunk / bad position).
Exported in ManualBindings_World.cpp. */
bool GetBlockInfo(Vector3i a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
/** Queries the whole block specification from the world.
Returns true if all block info was retrieved successfully, false if not (invalid chunk / bad position).
Exported in ManualBindings_World.cpp. */
bool GetBlockInfo(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight)
{
return GetBlockInfo({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_Meta, a_SkyLight, a_BlockLight);
}
// TODO: NIBBLETYPE GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ);
/** Writes the block area into the specified coords.
@ -691,16 +611,6 @@ public:
/** Wakes up the simulators for the specified area of blocks */
void WakeUpSimulatorsInArea(const cCuboid & a_Area);
// DEPRECATED, use vector-parametered version instead
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
{
LOGWARNING("cWorld::WakeUpSimulators(int, int, int) is deprecated, use cWorld::WakeUpSimulators(Vector3i) instead.");
WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
}
// DEPRECATED, use vector-parametered version instead
void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
// tolua_end
inline cSimulatorManager * GetSimulatorManager(void) { return m_SimulatorManager.get(); }