From c53406f0d4d83f795e2a445059952b61abb12f34 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 11 Feb 2014 22:04:11 +0000 Subject: Fixed #612 * Chests send contents updates to client --- src/BlockEntities/ChestEntity.cpp | 15 +++++++++++++++ src/BlockEntities/ChestEntity.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index dfbe6ae87..9282da7fd 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -170,3 +170,18 @@ void cChestEntity::OpenNewWindow(void) + +void cChestEntity::OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) +{ + super::OnSlotChanged(a_Grid, a_SlotNum); + + cWindow * Window = GetWindow(); + if (Window != NULL) + { + Window->BroadcastWholeWindow(); + } +} + + + + diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 4110de1f3..1f5668f78 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -49,6 +49,7 @@ public: virtual void SaveToJson(Json::Value & a_Value) override; virtual void SendTo(cClientHandle & a_Client) override; virtual void UsedBy(cPlayer * a_Player) override; + virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override; /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. void OpenNewWindow(void); -- cgit v1.2.3 From 06239c8336a340459a62b45b6d633a55058e4677 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 11 Feb 2014 22:09:56 +0000 Subject: Fixed #627 - Attack() is now called from cAggressive instead of cMonster * Monsters can no longer attack through walls * Should fix last remnants of player damage after teleporting (that both STR and bearbin contributed fixes to :P) --- src/Entities/Player.cpp | 4 ++-- src/Mobs/AggressiveMonster.cpp | 11 +++++++++-- src/Mobs/AggressiveMonster.h | 2 +- src/Mobs/Monster.cpp | 14 -------------- src/Mobs/Monster.h | 2 -- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 286d43cf6..5f2379ba2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1122,8 +1122,8 @@ void cPlayer::SetIP(const AString & a_IP) void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) { - SetPosition( a_PosX, a_PosY, a_PosZ ); - m_LastGroundHeight = (float)a_PosY; + SetPosition(a_PosX, a_PosY, a_PosZ); + m_LastGroundHeight, m_LastJumpHeight = (float)a_PosY; m_World->BroadcastTeleportEntity(*this, GetClientHandle()); m_ClientHandle->SendPlayerMoveLook(); diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index f2f0c404c..7da9f4fc2 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -5,7 +5,7 @@ #include "../World.h" #include "../Entities/Player.h" -#include "../MersenneTwister.h" +#include "../Tracer.h" @@ -73,6 +73,13 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) { CheckEventSeePlayer(); } + + cTracer LineOfSight(GetWorld()); + if (ReachedFinalDestination() && (m_Target != NULL) && !LineOfSight.Trace(GetPosition(), (m_Target->GetPosition() - GetPosition()), (int)(m_Target->GetPosition() - GetPosition()).Length())) + { + // Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls) + Attack(a_Dt / 1000); + } } @@ -81,7 +88,7 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) void cAggressiveMonster::Attack(float a_Dt) { - super::Attack(a_Dt); + m_AttackInterval += a_Dt * m_AttackRate; if ((m_Target != NULL) && (m_AttackInterval > 3.0)) { diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h index 9cee4e7a7..152260f95 100644 --- a/src/Mobs/AggressiveMonster.h +++ b/src/Mobs/AggressiveMonster.h @@ -20,7 +20,7 @@ public: virtual void InStateChasing(float a_Dt) override; virtual void EventSeePlayer(cEntity *) override; - virtual void Attack(float a_Dt) override; + virtual void Attack(float a_Dt); } ; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index ad3a87725..9817901c9 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -311,9 +311,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) } } - if (ReachedFinalDestination() && (m_Target != NULL)) - Attack(a_Dt); - SetPitchAndYawFromDestination(); HandleFalling(); @@ -657,17 +654,6 @@ void cMonster::InStateEscaping(float a_Dt) -// Do attack here -// a_Dt is passed so we can set attack rate -void cMonster::Attack(float a_Dt) -{ - m_AttackInterval += a_Dt * m_AttackRate; -} - - - - - void cMonster::GetMonsterConfig(const AString & a_Name) { cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name); diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 714feddb9..4d2e099c5 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -112,8 +112,6 @@ public: virtual void InStateChasing (float a_Dt); virtual void InStateEscaping(float a_Dt); - virtual void Attack(float a_Dt); - int GetAttackRate() { return (int)m_AttackRate; } void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; } void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; } -- cgit v1.2.3 From 9d54f2b761370afb04ebb49e0920de460f269efd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 11 Feb 2014 22:54:01 +0000 Subject: Fixed #190 + Hoppers now collect pickups above them --- src/BlockEntities/HopperEntity.cpp | 69 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 2255cad64..2d07ce6c7 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -7,10 +7,12 @@ #include "HopperEntity.h" #include "../Chunk.h" #include "../Entities/Player.h" +#include "../Entities/Pickup.h" #include "../Bindings/PluginManager.h" #include "ChestEntity.h" #include "DropSpenserEntity.h" #include "FurnaceEntity.h" +#include "../BoundingBox.h" @@ -190,8 +192,71 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick) /// Moves pickups from above this hopper into it. Returns true if the contents have changed. bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) { - // TODO - return false; + UNUSED(a_CurrentTick); + + class cHopperPickupSearchCallback : + public cEntityCallback + { + public: + cHopperPickupSearchCallback(Vector3i a_Pos, cItemGrid & a_Contents) : + m_Pos(a_Pos), + m_Contents(a_Contents), + m_bFoundPickupsAbove(false) + { + } + + virtual bool Item(cEntity * a_Entity) override + { + ASSERT(a_Entity != NULL); + + if (!a_Entity->IsPickup() || a_Entity->IsDestroyed()) + { + return false; + } + + Vector3f EntityPos = a_Entity->GetPosition(); + Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards + float Distance = (EntityPos - BlockPos).Length(); + + if (Distance < 0.5) + { + for (int i = 0; i < ContentsWidth * ContentsHeight; i++) + { + if (m_Contents.IsSlotEmpty(i)) + { + m_bFoundPickupsAbove = true; + m_Contents.SetSlot(i, ((cPickup *)a_Entity)->GetItem()); + a_Entity->Destroy(); // Kill pickup + return false; // Don't break enumeration + } + else if (m_Contents.GetSlot(i).IsEqual(((cPickup *)a_Entity)->GetItem())) + { + m_bFoundPickupsAbove = true; + m_Contents.ChangeSlotCount(i, ((cPickup *)a_Entity)->GetItem().m_ItemCount); + a_Entity->Destroy(); + return false; + } + } + } + + return false; + } + + bool FoundPickupsAbove(void) const + { + return m_bFoundPickupsAbove; + } + + protected: + Vector3i m_Pos; + bool m_bFoundPickupsAbove; + cItemGrid & m_Contents; + }; + + cHopperPickupSearchCallback HopperPickupSearchCallback(Vector3i(GetPosX(), GetPosY(), GetPosZ()), m_Contents); + a_Chunk.ForEachEntity(HopperPickupSearchCallback); + + return HopperPickupSearchCallback.FoundPickupsAbove(); } -- cgit v1.2.3 From a0a44b969ece88d32bcc89fea51b25d819424a06 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 11 Feb 2014 23:13:49 +0000 Subject: Improved pressure plates + Two (or more) pressure plates can be triggered at the same time * Fixed issues caused by pressure plates not being in the sources list --- src/Simulator/IncrementalRedstoneSimulator.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 5dba69455..a875c9e4d 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -960,7 +960,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f); float Distance = (EntityPos - BlockPos).Length(); - if (Distance < 0.5) + if (Distance <= 0.7) { m_Entity = a_Entity; return true; // Break out, we only need to know for wooden plates that at least one entity is on top diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 3397e143c..a3da13584 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -207,6 +207,10 @@ private: case E_BLOCK_REDSTONE_REPEATER_ON: case E_BLOCK_BLOCK_OF_REDSTONE: case E_BLOCK_ACTIVE_COMPARATOR: + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: + case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: + case E_BLOCK_STONE_PRESSURE_PLATE: + case E_BLOCK_WOODEN_PRESSURE_PLATE: { return true; } -- cgit v1.2.3 From 7ced2f290fc2018d93e324d384d87cfd826312a5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 12 Feb 2014 21:53:21 +0000 Subject: Simplified Attack() tracing --- src/Mobs/AggressiveMonster.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 7da9f4fc2..0901f85a9 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -74,8 +74,13 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) CheckEventSeePlayer(); } + if (m_Target == NULL) + return; + cTracer LineOfSight(GetWorld()); - if (ReachedFinalDestination() && (m_Target != NULL) && !LineOfSight.Trace(GetPosition(), (m_Target->GetPosition() - GetPosition()), (int)(m_Target->GetPosition() - GetPosition()).Length())) + Vector3d AttackDirection(m_Target->GetPosition() - GetPosition()); + + if (ReachedFinalDestination() && !LineOfSight.Trace(GetPosition(), AttackDirection, (int)AttackDirection.Length())) { // Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls) Attack(a_Dt / 1000); -- cgit v1.2.3 From 91ebb6cef09ff8437beaa0c17ca2a1c094741200 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 12 Feb 2014 21:53:46 +0000 Subject: Made player jump reset less ambiguous --- src/Entities/Player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 5f2379ba2..838bbd06c 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1123,7 +1123,8 @@ void cPlayer::SetIP(const AString & a_IP) void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) { SetPosition(a_PosX, a_PosY, a_PosZ); - m_LastGroundHeight, m_LastJumpHeight = (float)a_PosY; + m_LastGroundHeight = (float)a_PosY; + m_LastJumpHeight = (float)a_PosY; m_World->BroadcastTeleportEntity(*this, GetClientHandle()); m_ClientHandle->SendPlayerMoveLook(); -- cgit v1.2.3 From f97ce3015171fcc6f6c5316810d19eb37c89c5f7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 12 Feb 2014 22:01:22 +0000 Subject: Changed inheritance a bit * cBlockEntityWithItems now inherits from cBlockEntityWindowOwner --- src/BlockEntities/BlockEntityWithItems.h | 7 +++++ src/BlockEntities/ChestEntity.h | 4 +-- src/BlockEntities/DropSpenserEntity.h | 4 +-- src/BlockEntities/EnderChestEntity.h | 4 +-- src/BlockEntities/FurnaceEntity.h | 4 +-- src/BlockEntities/HopperEntity.cpp | 53 +++++++++++++++++++++----------- src/BlockEntities/HopperEntity.h | 4 +-- src/ItemGrid.cpp | 7 +++++ 8 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h index bf6289a2f..918781a00 100644 --- a/src/BlockEntities/BlockEntityWithItems.h +++ b/src/BlockEntities/BlockEntityWithItems.h @@ -11,6 +11,7 @@ #include "BlockEntity.h" #include "../ItemGrid.h" +#include "../UI/WindowOwner.h" @@ -22,6 +23,7 @@ class cBlockEntityWithItems : // tolua_end // tolua doesn't seem to support multiple inheritance? , public cItemGrid::cListener + , public cBlockEntityWindowOwner // tolua_begin { typedef cBlockEntity super; @@ -77,6 +79,11 @@ protected: ASSERT(a_Grid == &m_Contents); if (m_World != NULL) { + if (GetWindow() != NULL) + { + GetWindow()->BroadcastWholeWindow(); + } + m_World->MarkChunkDirty(GetChunkX(), GetChunkZ()); } } diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 1f5668f78..3167d64a0 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -2,7 +2,6 @@ #pragma once #include "BlockEntityWithItems.h" -#include "../UI/WindowOwner.h" @@ -23,8 +22,7 @@ class cNBTData; // tolua_begin class cChestEntity : - public cBlockEntityWithItems, - public cBlockEntityWindowOwner + public cBlockEntityWithItems { typedef cBlockEntityWithItems super; diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h index f2f1eba36..47d3bd492 100644 --- a/src/BlockEntities/DropSpenserEntity.h +++ b/src/BlockEntities/DropSpenserEntity.h @@ -11,7 +11,6 @@ #pragma once #include "BlockEntityWithItems.h" -#include "../UI/WindowOwner.h" @@ -31,8 +30,7 @@ class cServer; // tolua_begin class cDropSpenserEntity : - public cBlockEntityWithItems, - public cBlockEntityWindowOwner + public cBlockEntityWithItems { typedef cBlockEntityWithItems super; diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h index 0ee3cab3b..45beee45f 100644 --- a/src/BlockEntities/EnderChestEntity.h +++ b/src/BlockEntities/EnderChestEntity.h @@ -2,7 +2,6 @@ #pragma once #include "BlockEntityWithItems.h" -#include "../UI/WindowOwner.h" @@ -23,8 +22,7 @@ class cNBTData; // tolua_begin class cEnderChestEntity : - public cBlockEntityWithItems, - public cBlockEntityWindowOwner + public cBlockEntityWithItems { typedef cBlockEntityWithItems super; diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h index b08187300..5e08ae37a 100644 --- a/src/BlockEntities/FurnaceEntity.h +++ b/src/BlockEntities/FurnaceEntity.h @@ -2,7 +2,6 @@ #pragma once #include "BlockEntityWithItems.h" -#include "../UI/WindowOwner.h" #include "../FurnaceRecipe.h" @@ -23,8 +22,7 @@ class cServer; // tolua_begin class cFurnaceEntity : - public cBlockEntityWithItems, - public cBlockEntityWindowOwner + public cBlockEntityWithItems { typedef cBlockEntityWithItems super; diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 2d07ce6c7..b2fe7ee99 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -198,10 +198,10 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) public cEntityCallback { public: - cHopperPickupSearchCallback(Vector3i a_Pos, cItemGrid & a_Contents) : + cHopperPickupSearchCallback(const Vector3i a_Pos, cItemGrid & a_Contents) : m_Pos(a_Pos), - m_Contents(a_Contents), - m_bFoundPickupsAbove(false) + m_bFoundPickupsAbove(false), + m_Contents(a_Contents) { } @@ -220,25 +220,42 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) if (Distance < 0.5) { - for (int i = 0; i < ContentsWidth * ContentsHeight; i++) + if (TrySuckPickupIn((cPickup *)a_Entity)) { - if (m_Contents.IsSlotEmpty(i)) - { - m_bFoundPickupsAbove = true; - m_Contents.SetSlot(i, ((cPickup *)a_Entity)->GetItem()); - a_Entity->Destroy(); // Kill pickup - return false; // Don't break enumeration - } - else if (m_Contents.GetSlot(i).IsEqual(((cPickup *)a_Entity)->GetItem())) + return false; + } + } + + return false; + } + + bool TrySuckPickupIn(cPickup * a_Pickup) + { + for (int i = 0; i < ContentsWidth * ContentsHeight; i++) + { + if (m_Contents.IsSlotEmpty(i)) + { + m_bFoundPickupsAbove = true; + m_Contents.SetSlot(i, a_Pickup->GetItem()); + a_Pickup->Destroy(); // Kill pickup + return true; + } + else if (m_Contents.GetSlot(i).IsEqual(a_Pickup->GetItem()) && !m_Contents.GetSlot(i).IsFullStack()) + { + m_bFoundPickupsAbove = true; + LOGINFO("Previous counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); + int PreviousCount = m_Contents.GetSlot(i).m_ItemCount; + a_Pickup->GetItem().m_ItemCount -= m_Contents.ChangeSlotCount(i, a_Pickup->GetItem().m_ItemCount) - PreviousCount; // Set count to however many items were added + LOGINFO("After counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); + + if (a_Pickup->GetItem().IsEmpty()) { - m_bFoundPickupsAbove = true; - m_Contents.ChangeSlotCount(i, ((cPickup *)a_Entity)->GetItem().m_ItemCount); - a_Entity->Destroy(); - return false; + //LOGINFO("Pickup was empty!"); + a_Pickup->Destroy(); // Kill pickup if all items were added } + return true; } } - return false; } @@ -248,7 +265,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) } protected: - Vector3i m_Pos; + const Vector3i m_Pos; bool m_bFoundPickupsAbove; cItemGrid & m_Contents; }; diff --git a/src/BlockEntities/HopperEntity.h b/src/BlockEntities/HopperEntity.h index 2c8b301fe..6ef98f43a 100644 --- a/src/BlockEntities/HopperEntity.h +++ b/src/BlockEntities/HopperEntity.h @@ -10,7 +10,6 @@ #pragma once #include "BlockEntityWithItems.h" -#include "../UI/WindowOwner.h" @@ -18,8 +17,7 @@ // tolua_begin class cHopperEntity : - public cBlockEntityWithItems, - public cBlockEntityWindowOwner + public cBlockEntityWithItems { typedef cBlockEntityWithItems super; diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index e8b58695f..34a267bab 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -369,6 +369,13 @@ int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount) } m_Slots[a_SlotNum].m_ItemCount += a_AddToCount; + + cItemHandler * Handler = cItemHandler::GetItemHandler(m_Slots[a_SlotNum].m_ItemType); + if (m_Slots[a_SlotNum].m_ItemCount > Handler->GetMaxStackSize()) + { + m_Slots[a_SlotNum].m_ItemCount = Handler->GetMaxStackSize(); + } + TriggerListeners(a_SlotNum); return m_Slots[a_SlotNum].m_ItemCount; } -- cgit v1.2.3 From e915a0df4cf78f41a200f0a06aabf069aec1bb07 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 12 Feb 2014 22:06:13 +0000 Subject: Removed some unneeded BroadcastWholeWindow()s --- src/BlockEntities/ChestEntity.cpp | 15 --------------- src/BlockEntities/ChestEntity.h | 1 - src/BlockEntities/DropSpenserEntity.cpp | 7 ------- src/BlockEntities/SignEntity.h | 2 ++ 4 files changed, 2 insertions(+), 23 deletions(-) diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 9282da7fd..dfbe6ae87 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -170,18 +170,3 @@ void cChestEntity::OpenNewWindow(void) - -void cChestEntity::OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) -{ - super::OnSlotChanged(a_Grid, a_SlotNum); - - cWindow * Window = GetWindow(); - if (Window != NULL) - { - Window->BroadcastWholeWindow(); - } -} - - - - diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 3167d64a0..ce16f84d7 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -47,7 +47,6 @@ public: virtual void SaveToJson(Json::Value & a_Value) override; virtual void SendTo(cClientHandle & a_Client) override; virtual void UsedBy(cPlayer * a_Player) override; - virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override; /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. void OpenNewWindow(void); diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 7c9a40ce6..81df0fc8c 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -99,13 +99,6 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) } m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir); m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f); - - // Update the UI window, if open: - cWindow * Window = GetWindow(); - if (Window != NULL) - { - Window->BroadcastWholeWindow(); - } } diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index d998ff1e8..2b965747c 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -56,6 +56,8 @@ public: virtual void UsedBy(cPlayer * a_Player) override; virtual void SendTo(cClientHandle & a_Client) override; + + static const char * GetClassStatic(void) { return "cSignrEntity"; } private: -- cgit v1.2.3 From 6ed4f476ce1365c5878c2726de331c892d00c256 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 12 Feb 2014 22:06:59 +0000 Subject: Added more missing GetClassStatic()s --- src/BlockEntities/JukeboxEntity.h | 2 ++ src/BlockEntities/NoteEntity.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 996de965b..734d7bb66 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -43,6 +43,8 @@ public: void EjectRecord(void); // tolua_end + + static const char * GetClassStatic(void) { return "cJukeboxEntity"; } virtual void UsedBy(cPlayer * a_Player) override; virtual void SendTo(cClientHandle &) override { }; diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index cf78aeac6..b698899c0 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -54,6 +54,8 @@ public: virtual void UsedBy(cPlayer * a_Player) override; virtual void SendTo(cClientHandle &) override { }; + static const char * GetClassStatic(void) { return "cNoteEntity"; } + private: char m_Pitch; } ; // tolua_export -- cgit v1.2.3 From c0e7d6fec9c8349321849b933183ef3f49ff87d2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 13 Feb 2014 19:57:23 +0000 Subject: Fancy stuff with constant references --- src/BlockEntities/HopperEntity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index b2fe7ee99..b4ee36607 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -198,7 +198,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) public cEntityCallback { public: - cHopperPickupSearchCallback(const Vector3i a_Pos, cItemGrid & a_Contents) : + cHopperPickupSearchCallback(const Vector3i & a_Pos, cItemGrid & a_Contents) : m_Pos(a_Pos), m_bFoundPickupsAbove(false), m_Contents(a_Contents) @@ -265,7 +265,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) } protected: - const Vector3i m_Pos; + Vector3i m_Pos; bool m_bFoundPickupsAbove; cItemGrid & m_Contents; }; -- cgit v1.2.3 From f4f0099947a017085574bff681d76aa1d4d53058 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 13 Feb 2014 20:20:37 +0000 Subject: Added proper debug messages --- src/BlockEntities/HopperEntity.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index b4ee36607..386dc2d32 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -238,19 +238,24 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) m_bFoundPickupsAbove = true; m_Contents.SetSlot(i, a_Pickup->GetItem()); a_Pickup->Destroy(); // Kill pickup + + LOGD("Hopper sucking pickup into an empty slot"); + return true; } else if (m_Contents.GetSlot(i).IsEqual(a_Pickup->GetItem()) && !m_Contents.GetSlot(i).IsFullStack()) { m_bFoundPickupsAbove = true; - LOGINFO("Previous counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); + + LOGD("Hopper sucking pickup; previous counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); + int PreviousCount = m_Contents.GetSlot(i).m_ItemCount; a_Pickup->GetItem().m_ItemCount -= m_Contents.ChangeSlotCount(i, a_Pickup->GetItem().m_ItemCount) - PreviousCount; // Set count to however many items were added - LOGINFO("After counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); + + LOGD("Hopper sucking pickup; after counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); if (a_Pickup->GetItem().IsEmpty()) { - //LOGINFO("Pickup was empty!"); a_Pickup->Destroy(); // Kill pickup if all items were added } return true; -- cgit v1.2.3 From c6a2e8c6889aca8aa422ac704b79bf7fc43856ec Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 15 Feb 2014 12:58:17 +0000 Subject: Removed debug messages again --- src/BlockEntities/HopperEntity.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 386dc2d32..31b23ac99 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -239,20 +239,14 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) m_Contents.SetSlot(i, a_Pickup->GetItem()); a_Pickup->Destroy(); // Kill pickup - LOGD("Hopper sucking pickup into an empty slot"); - return true; } else if (m_Contents.GetSlot(i).IsEqual(a_Pickup->GetItem()) && !m_Contents.GetSlot(i).IsFullStack()) { m_bFoundPickupsAbove = true; - LOGD("Hopper sucking pickup; previous counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); - int PreviousCount = m_Contents.GetSlot(i).m_ItemCount; a_Pickup->GetItem().m_ItemCount -= m_Contents.ChangeSlotCount(i, a_Pickup->GetItem().m_ItemCount) - PreviousCount; // Set count to however many items were added - - LOGD("Hopper sucking pickup; after counts, pickup: %i, hopper: %i", (int)a_Pickup->GetItem().m_ItemCount, (int)m_Contents.GetSlot(i).m_ItemCount); if (a_Pickup->GetItem().IsEmpty()) { -- cgit v1.2.3 From b0fd5511eab236b69fb0805789917e91f8bb6b6e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 15 Feb 2014 13:55:58 +0000 Subject: Fixed typographical error --- src/BlockEntities/SignEntity.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index 2b965747c..80c7bbfdf 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -1,4 +1,3 @@ - // SignEntity.h // Declares the cSignEntity class representing a single sign in the world @@ -57,7 +56,7 @@ public: virtual void UsedBy(cPlayer * a_Player) override; virtual void SendTo(cClientHandle & a_Client) override; - static const char * GetClassStatic(void) { return "cSignrEntity"; } + static const char * GetClassStatic(void) { return "cSignEntity"; } private: -- cgit v1.2.3