From 61cb08b54698e9b70f629858a6a9c5b389db8b3e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 20:44:34 +0100 Subject: Implemented tripwire(s) (hooks) * Fixes #944 --- src/Items/ItemHandler.cpp | 2 ++ src/Items/ItemString.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/Items/ItemString.h (limited to 'src/Items') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index f639423ae..a2fd4e3f8 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -44,6 +44,7 @@ #include "ItemSign.h" #include "ItemMobHead.h" #include "ItemSpawnEgg.h" +#include "ItemString.h" #include "ItemSugarcane.h" #include "ItemSword.h" @@ -129,6 +130,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_HEAD: return new cItemMobHeadHandler(a_ItemType); case E_ITEM_SNOWBALL: return new cItemSnowballHandler(); case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType); + case E_ITEM_STRING: return new cItemStringHandler(a_ItemType); case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType); case E_ITEM_WOODEN_HOE: diff --git a/src/Items/ItemString.h b/src/Items/ItemString.h new file mode 100644 index 000000000..a97fbe0ce --- /dev/null +++ b/src/Items/ItemString.h @@ -0,0 +1,39 @@ + +#pragma once + +#include "ItemHandler.h" + + + + + +class cItemStringHandler : + public cItemHandler +{ +public: + cItemStringHandler(int a_ItemType) : + cItemHandler(a_ItemType) + { + } + + virtual bool IsPlaceable(void) override + { + return true; + } + + virtual bool GetPlacementBlockTypeMeta( + cWorld * a_World, 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 + ) override + { + a_BlockType = E_BLOCK_TRIPWIRE; + a_BlockMeta = 0; + return true; + } +}; + + + + -- cgit v1.2.3 From 64f6ddf1e2171dd7713f454c792916257e770f98 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 14:47:49 +0200 Subject: Fix server-crash with non-existing items. --- src/Items/ItemHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index a2fd4e3f8..0f56b2b90 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -63,7 +63,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268]; cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) { - if (a_ItemType < 0) + if ((a_ItemType < 0) || (a_ItemType >= ARRAYCOUNT(m_ItemHandler)) || (!IsValidBlock(a_ItemType) && !IsValidItem(a_ItemType))) { // Either nothing (-1), or bad value, both cases should return the air handler if (a_ItemType < -1) -- cgit v1.2.3 From 64e66674355c84c091564197dcbdf26806e61659 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 20:34:50 +0200 Subject: Only fixes the server crash. --- src/Items/ItemHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 0f56b2b90..423039cf4 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -63,7 +63,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268]; cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) { - if ((a_ItemType < 0) || (a_ItemType >= ARRAYCOUNT(m_ItemHandler)) || (!IsValidBlock(a_ItemType) && !IsValidItem(a_ItemType))) + if ((a_ItemType < 0) || ((unsigned long)a_ItemType >= ARRAYCOUNT(m_ItemHandler))) { // Either nothing (-1), or bad value, both cases should return the air handler if (a_ItemType < -1) -- cgit v1.2.3 From 98950af634cca62af08ddf8c07b77f46165578a8 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Wed, 9 Jul 2014 16:53:01 +0200 Subject: Fixed Bucket placing --- src/Items/ItemBucket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 68c89dd85..fa98587ea 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -41,7 +41,7 @@ public: bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) { - if (a_BlockFace > 0) + if (a_BlockFace < 0) { return false; } -- cgit v1.2.3 From da1d946b2b6cbb5d3e66c78adc09a4c472e04078 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 9 Jul 2014 22:04:26 +0100 Subject: Fixed bow charge --- src/Items/ItemBow.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index 940338d0f..185f17fee 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -55,7 +55,7 @@ public: // Too little force, ignore the shot return; } - Force = std::max(Force, 1.0); + Force = std::min(Force, 1.0); // Create the arrow entity: cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); @@ -70,16 +70,7 @@ public: return; } - cFastRandom Random; - a_Player->GetWorld()->BroadcastSoundEffect( - "random.bow", - (int)std::floor(a_Player->GetPosX() * 8.0), - (int)std::floor(a_Player->GetPosY() * 8.0), - (int)std::floor(a_Player->GetPosZ() * 8.0), - 1.0F, - 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F - ); - + a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force); if (!a_Player->IsGameModeCreative()) { a_Player->UseEquippedItem(); -- cgit v1.2.3 From a11ad977ce9465c6c37050f7b9a82f1884645a34 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:10:42 +0200 Subject: Fixed Bucket Placing --- src/Items/ItemBucket.h | 63 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index fa98587ea..41b7c82bc 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -41,7 +41,7 @@ public: bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) { - if (a_BlockFace < 0) + if (a_BlockFace > 0) { return false; } @@ -95,18 +95,24 @@ public: bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock) { - if (a_BlockFace < 0) + if (a_BlockFace > 0) { return false; } + + Vector3i BlockPos; + if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) + { + return false; + } - BLOCKTYPE CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) { // The block pointed at cannot be washed away, so put fluid on top of it / on its sides - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + //AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); + CurrentBlock = a_World->GetBlock(BlockPos); } if ( !CanWashAway && @@ -149,7 +155,7 @@ public: } } - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FluidBlock, 0); + a_World->SetBlock(BlockPos.x, BlockPos.y, BlockPos.z, a_FluidBlock, 0); return true; } @@ -201,5 +207,50 @@ public: BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); return true; } + + + bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) + { + class cCallbacks : + public cBlockTracer::cCallbacks + { + public: + Vector3i m_Pos; + bool m_HasHitLastBlock; + + + cCallbacks(void) : + m_HasHitLastBlock(false) + { + } + + virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override + { + if (a_BlockType != E_BLOCK_AIR) + { + m_HasHitLastBlock = true; + return true; + } + + m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); + + return false; + } + } Callbacks; + cLineBlockTracer Tracer(*a_World, Callbacks); + Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); + Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); + + Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z); + + if (!Callbacks.m_HasHitLastBlock) + { + return false; + } + + + BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); + return true; + } }; -- cgit v1.2.3 From 47ceb9e79db2a30dd5b5e48dd28f9c6f14ed2fc3 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:36:28 +0200 Subject: Maybe fixed whitespaces --- src/Items/ItemBucket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 41b7c82bc..5c8d5f741 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -105,7 +105,7 @@ public: { return false; } - + BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) -- cgit v1.2.3 From 944c04a209492826365b3785ccf1ed1fc70e122c Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:38:19 +0200 Subject: Maybe fixed whitespaces --- src/Items/ItemBucket.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 5c8d5f741..ab884ced6 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -99,13 +99,13 @@ public: { return false; } - - Vector3i BlockPos; - if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) - { - return false; - } - + + Vector3i BlockPos; + if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) + { + return false; + } + BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) -- cgit v1.2.3 From a8efb620881cd744cfd3cc74316a39bfec80b897 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 17:46:07 +0200 Subject: Changes --- src/Items/ItemBucket.h | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index ab884ced6..b31266f35 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -100,19 +100,19 @@ public: return false; } + BLOCKTYPE CurrentBlock; Vector3i BlockPos; - if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) + if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos, CurrentBlock)) { return false; } - BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) { // The block pointed at cannot be washed away, so put fluid on top of it / on its sides - //AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); - CurrentBlock = a_World->GetBlock(BlockPos); + // AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); + // CurrentBlock = a_World->GetBlock(BlockPos); } if ( !CanWashAway && @@ -161,7 +161,7 @@ public: } - bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) + bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) { class cCallbacks : public cBlockTracer::cCallbacks @@ -204,19 +204,20 @@ public: } - BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); + a_BlockPos = Callbacks.m_Pos; return true; } - bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) + bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) { class cCallbacks : public cBlockTracer::cCallbacks { public: - Vector3i m_Pos; - bool m_HasHitLastBlock; + Vector3i m_Pos; + bool m_HasHitLastBlock; + BLOCKTYPE m_LastBlock; cCallbacks(void) : @@ -226,15 +227,16 @@ public: virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override { - if (a_BlockType != E_BLOCK_AIR) - { - m_HasHitLastBlock = true; - return true; - } - - m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); - - return false; + if (a_BlockType != E_BLOCK_AIR) + { + m_HasHitLastBlock = true; + return true; + } + + m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); + m_LastBlock = a_BlockType; + + return false; } } Callbacks; @@ -249,8 +251,8 @@ public: return false; } - - BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); + a_BlockPos = Callbacks.m_Pos; + a_BlockType = Callbacks.m_LastBlock; return true; } }; -- cgit v1.2.3 From ca6bcacdb9216237a25c05b2887ea69c6066356b Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Fri, 11 Jul 2014 17:58:35 +0200 Subject: Changes --- src/Items/ItemBucket.h | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index b31266f35..e7214d852 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -41,7 +41,7 @@ public: bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) { - if (a_BlockFace > 0) + if (a_BlockFace != BLOCK_FACE_NONE) { return false; } @@ -95,38 +95,18 @@ public: bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock) { - if (a_BlockFace > 0) + if (a_BlockFace != BLOCK_FACE_NONE) { return false; } BLOCKTYPE CurrentBlock; Vector3i BlockPos; - if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos, CurrentBlock)) + if (!GetPlacementCoordsFromTrace(a_World, a_Player, BlockPos, CurrentBlock)) { return false; } - bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); - if (!CanWashAway) - { - // The block pointed at cannot be washed away, so put fluid on top of it / on its sides - // AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); - // CurrentBlock = a_World->GetBlock(BlockPos); - } - if ( - !CanWashAway && - (CurrentBlock != E_BLOCK_AIR) && - (CurrentBlock != E_BLOCK_WATER) && - (CurrentBlock != E_BLOCK_STATIONARY_WATER) && - (CurrentBlock != E_BLOCK_LAVA) && - (CurrentBlock != E_BLOCK_STATIONARY_LAVA) - ) - { - // Cannot place water here - return false; - } - if (a_Player->GetGameMode() != gmCreative) { // Remove fluid bucket, add empty bucket: @@ -144,6 +124,7 @@ public: } // Wash away anything that was there prior to placing: + bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (CanWashAway) { cBlockHandler * Handler = BlockHandler(CurrentBlock); @@ -209,7 +190,7 @@ public: } - bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) + bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) { class cCallbacks : public cBlockTracer::cCallbacks @@ -229,6 +210,17 @@ public: { if (a_BlockType != E_BLOCK_AIR) { + bool CanWashAway = cFluidSimulator::CanWashAway(m_LastBlock); + if ( + !CanWashAway && + (m_LastBlock != E_BLOCK_AIR) && + !IsBlockWater(m_LastBlock) && + !IsBlockLava(m_LastBlock) + ) + { + return true; + } + m_HasHitLastBlock = true; return true; } -- cgit v1.2.3 From 68668d7a6eb3a989fc331f68fb660fff19b2f069 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 12 Jul 2014 12:44:59 +0200 Subject: Changes --- src/Items/ItemBucket.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index e7214d852..b3f008229 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -124,8 +124,7 @@ public: } // Wash away anything that was there prior to placing: - bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); - if (CanWashAway) + if (cFluidSimulator::CanWashAway(CurrentBlock)) { cBlockHandler * Handler = BlockHandler(CurrentBlock); if (Handler->DoesDropOnUnsuitable()) @@ -188,9 +187,9 @@ public: a_BlockPos = Callbacks.m_Pos; return true; } - - - bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) + + + bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) { class cCallbacks : public cBlockTracer::cCallbacks -- cgit v1.2.3 From 9f4348fb09ae77aebcf0cdcfc2139613756dbcdc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:50:28 +0100 Subject: Simplified buckets code slightly --- src/Items/ItemBucket.h | 47 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index b3f008229..20d955de4 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -196,54 +196,37 @@ public: { public: Vector3i m_Pos; - bool m_HasHitLastBlock; - BLOCKTYPE m_LastBlock; - - - cCallbacks(void) : - m_HasHitLastBlock(false) - { - } + BLOCKTYPE m_ReplacedBlock; virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override { if (a_BlockType != E_BLOCK_AIR) { - bool CanWashAway = cFluidSimulator::CanWashAway(m_LastBlock); - if ( - !CanWashAway && - (m_LastBlock != E_BLOCK_AIR) && - !IsBlockWater(m_LastBlock) && - !IsBlockLava(m_LastBlock) - ) + m_ReplacedBlock = a_BlockType; + if (!cFluidSimulator::CanWashAway(a_BlockType)) { - return true; + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was a unwashawayable block, can't overwrite it! } - - m_HasHitLastBlock = true; - return true; - } - - m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); - m_LastBlock = a_BlockType; - + m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it) + return true; // Abort tracing + } return false; } } Callbacks; cLineBlockTracer Tracer(*a_World, Callbacks); Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); - Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - - Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z); + Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - if (!Callbacks.m_HasHitLastBlock) + // cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed + // Use this to judge whether the position is valid + if (!Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z)) { - return false; + a_BlockPos = Callbacks.m_Pos; + a_BlockType = Callbacks.m_ReplacedBlock; + return true; } - a_BlockPos = Callbacks.m_Pos; - a_BlockType = Callbacks.m_LastBlock; - return true; + return false; } }; -- cgit v1.2.3 From 945dfe75d753271394ef4109b66b1a526e5b2c93 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:52:45 +0100 Subject: Comment grammar correction --- src/Items/ItemBucket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 20d955de4..5529b4e36 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -205,7 +205,7 @@ public: m_ReplacedBlock = a_BlockType; if (!cFluidSimulator::CanWashAway(a_BlockType)) { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was a unwashawayable block, can't overwrite it! + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was an unwashawayable block, can't overwrite it! } m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it) return true; // Abort tracing -- cgit v1.2.3