Fixed door placement.
Doors now have hinges on the correct side, based on what the surroundings are when placing them.
This commit is contained in:
parent
958834f5e9
commit
88fc70a06a
@ -77,19 +77,32 @@ public:
|
|||||||
NIBBLETYPE LowerBlockMeta = cBlockDoorHandler::PlayerYawToMetaData(a_Player.GetYaw());
|
NIBBLETYPE LowerBlockMeta = cBlockDoorHandler::PlayerYawToMetaData(a_Player.GetYaw());
|
||||||
Vector3i RelDirToOutside = cBlockDoorHandler::GetRelativeDirectionToOutside(LowerBlockMeta);
|
Vector3i RelDirToOutside = cBlockDoorHandler::GetRelativeDirectionToOutside(LowerBlockMeta);
|
||||||
Vector3i LeftNeighborPos = RelDirToOutside;
|
Vector3i LeftNeighborPos = RelDirToOutside;
|
||||||
LeftNeighborPos.TurnCCW();
|
LeftNeighborPos.TurnCW();
|
||||||
LeftNeighborPos.Move(a_BlockX, a_BlockY, a_BlockZ);
|
LeftNeighborPos.Move(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
Vector3i RightNeighborPos = RelDirToOutside;
|
Vector3i RightNeighborPos = RelDirToOutside;
|
||||||
RightNeighborPos.TurnCW();
|
RightNeighborPos.TurnCCW();
|
||||||
RightNeighborPos.Move(a_BlockX, a_BlockY, a_BlockZ);
|
RightNeighborPos.Move(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
|
||||||
// Decide whether the hinge is on the left (default) or on the right:
|
// Decide whether the hinge is on the left (default) or on the right:
|
||||||
NIBBLETYPE UpperBlockMeta = 0x08;
|
NIBBLETYPE UpperBlockMeta = 0x08;
|
||||||
|
BLOCKTYPE LeftNeighborBlock = a_World.GetBlock(LeftNeighborPos);
|
||||||
|
BLOCKTYPE RightNeighborBlock = a_World.GetBlock(RightNeighborPos);
|
||||||
|
/*
|
||||||
|
// DEBUG:
|
||||||
|
LOGD("Door being placed at {%d, %d, %d}", a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
LOGD("RelDirToOutside: {%d, %d, %d}", RelDirToOutside.x, RelDirToOutside.y, RelDirToOutside.z);
|
||||||
|
LOGD("Left neighbor at {%d, %d, %d}: %d (%s)", LeftNeighborPos.x, LeftNeighborPos.y, LeftNeighborPos.z, LeftNeighborBlock, ItemTypeToString(LeftNeighborBlock).c_str());
|
||||||
|
LOGD("Right neighbor at {%d, %d, %d}: %d (%s)", RightNeighborPos.x, RightNeighborPos.y, RightNeighborPos.z, RightNeighborBlock, ItemTypeToString(RightNeighborBlock).c_str());
|
||||||
|
*/
|
||||||
if (
|
if (
|
||||||
cBlockDoorHandler::IsDoorBlockType(a_World.GetBlock(LeftNeighborPos)) || // The block to the left is a door block
|
cBlockDoorHandler::IsDoorBlockType(LeftNeighborBlock) || // The block to the left is a door block
|
||||||
cBlockInfo::IsSolid(a_World.GetBlock(RightNeighborPos)) // The block to the right is solid
|
(
|
||||||
|
cBlockInfo::IsSolid(RightNeighborBlock) && // The block to the right is solid...
|
||||||
|
!cBlockDoorHandler::IsDoorBlockType(RightNeighborBlock) // ... but not a door
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// DEBUG: LOGD("Setting hinge to right side");
|
||||||
UpperBlockMeta = 0x09; // Upper block | hinge on right
|
UpperBlockMeta = 0x09; // Upper block | hinge on right
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user