From b165ab63633cd8c45d505a2fd2165807ea2b50ec Mon Sep 17 00:00:00 2001 From: Freddie Wang Date: Wed, 4 Feb 2015 23:10:46 -0800 Subject: Fix door placement check --- src/Items/ItemDoor.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/Items/ItemDoor.h') diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h index dacf286e5..6d8d97f6f 100644 --- a/src/Items/ItemDoor.h +++ b/src/Items/ItemDoor.h @@ -62,10 +62,10 @@ public: return false; } } - + // Check the two blocks that will get replaced by the door: - BLOCKTYPE LowerBlockType = a_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ); - BLOCKTYPE UpperBlockType = a_World.GetBlock(a_BlockX, a_BlockY + 2, a_BlockZ); + BLOCKTYPE LowerBlockType = a_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ); + BLOCKTYPE UpperBlockType = a_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ); if ( !cBlockDoorHandler::CanReplaceBlock(LowerBlockType) || !cBlockDoorHandler::CanReplaceBlock(UpperBlockType)) @@ -106,7 +106,3 @@ public: return true; } } ; - - - - -- cgit v1.2.3 From 1bcc4abd68ad7cff943b1aa785f9d7bcb62c6b5d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 21 Feb 2015 14:23:37 +0100 Subject: Door handler: Removed needless check. The Y coord has already been checked above. --- src/Items/ItemDoor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items/ItemDoor.h') diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h index 6d8d97f6f..18289be03 100644 --- a/src/Items/ItemDoor.h +++ b/src/Items/ItemDoor.h @@ -40,7 +40,7 @@ public: } // The door needs a compatible block below it: - if ((a_BlockY > 0) && !cBlockDoorHandler::CanBeOn(a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) + if (!cBlockDoorHandler::CanBeOn(a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) { return false; } -- cgit v1.2.3 From 88fc70a06a9e2d15f9a672f792e0029a79be136f Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 28 Feb 2015 17:16:21 +0100 Subject: Fixed door placement. Doors now have hinges on the correct side, based on what the surroundings are when placing them. --- src/Items/ItemDoor.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/Items/ItemDoor.h') diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h index 18289be03..71143d5a8 100644 --- a/src/Items/ItemDoor.h +++ b/src/Items/ItemDoor.h @@ -77,19 +77,32 @@ public: NIBBLETYPE LowerBlockMeta = cBlockDoorHandler::PlayerYawToMetaData(a_Player.GetYaw()); Vector3i RelDirToOutside = cBlockDoorHandler::GetRelativeDirectionToOutside(LowerBlockMeta); Vector3i LeftNeighborPos = RelDirToOutside; - LeftNeighborPos.TurnCCW(); + LeftNeighborPos.TurnCW(); LeftNeighborPos.Move(a_BlockX, a_BlockY, a_BlockZ); Vector3i RightNeighborPos = RelDirToOutside; - RightNeighborPos.TurnCW(); + RightNeighborPos.TurnCCW(); RightNeighborPos.Move(a_BlockX, a_BlockY, a_BlockZ); // Decide whether the hinge is on the left (default) or on the right: 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 ( - cBlockDoorHandler::IsDoorBlockType(a_World.GetBlock(LeftNeighborPos)) || // The block to the left is a door block - cBlockInfo::IsSolid(a_World.GetBlock(RightNeighborPos)) // The block to the right is solid + cBlockDoorHandler::IsDoorBlockType(LeftNeighborBlock) || // The block to the left is a door block + ( + 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 } -- cgit v1.2.3