From fec64bb91c03c5e872a8f6fbc1a253f341373072 Mon Sep 17 00:00:00 2001 From: Persson-dev <66266021+Persson-dev@users.noreply.github.com> Date: Wed, 29 Dec 2021 20:28:41 +0100 Subject: Improved farmer AI & Fixed entity loading functions (#5351) * Allow villagers to pickup items * Add farmer villager harvesting * Use of auto keyword * Using for loop to check adjacent crops * Show particules when farmer harvest * Fix area comment * Move constants to header file * Removing unnecessary semicolon * Initialization of CropBlockType variable * Apply 12xx12 suggestion * Fixing area constant size * Refactor bounding box calculation, use vectors. * Add Api documentation * Update lua docs * Rework farmer ai * Fixing lua docs notes * Add missing capitalisation * Add villagers inventory save * Fixing loading entities from disk inconsistencies * Add farmer harvest animation * Fix beetroots grow state Co-authored-by: Alexander Harkness --- src/ChunkMap.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 9e39338de..c3139ed9c 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -439,14 +439,14 @@ void cChunkMap::FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLET -void cChunkMap::CollectPickupsByPlayer(cPlayer & a_Player) +void cChunkMap::CollectPickupsByEntity(cEntity & a_Entity) { cCSLock Lock(m_CSChunks); - auto BoundingBox = a_Player.GetBoundingBox(); + auto BoundingBox = a_Entity.GetBoundingBox(); BoundingBox.Expand(1, 0.5, 1); - ForEachEntityInBox(BoundingBox, [&a_Player](cEntity & Entity) + ForEachEntityInBox(BoundingBox, [&a_Entity](cEntity & Entity) { // Only pickups and projectiles can be picked up: if (Entity.IsPickup()) @@ -456,11 +456,11 @@ void cChunkMap::CollectPickupsByPlayer(cPlayer & a_Player) (*itr)->GetUniqueID(), a_Player->GetName().c_str(), SqrDist ); */ - static_cast(Entity).CollectedBy(a_Player); + static_cast(Entity).CollectedBy(a_Entity); } - else if (Entity.IsProjectile()) + else if (Entity.IsProjectile() && a_Entity.IsPlayer()) { - static_cast(Entity).CollectedBy(a_Player); + static_cast(Entity).CollectedBy(static_cast(a_Entity)); } // The entities will MarkDirty when they Destroy themselves -- cgit v1.2.3