From 9b97d63f8f939dbc431cc2dcd9eddf959f86603a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 30 Apr 2021 14:23:46 +0100 Subject: Chest, weather, crash, and miscellaneous fixes (#5215) * Alpha-sort cChestEntity * Chests: use SendUpdateBlockEntity * Pathfinder: fix out of range Y * 1.13: correct weather packet ID * Chests: fix neighbour scanner + Add OnAddToWorld and overload to scan neighbours there, instead of in the constructor/OnUse. This fixes hoppers accessing newly loaded double chests and seeing a null m_Neighbour, thus thinking its a single chest. * Fix typo in cross coords computation. * Simplify hopper logic. * Block entities: ASSERT that type is correct If you match the block type first before calling DoWithBlockEntity, the corresponding block entity must either be empty or correspond to the block type. * Chunk: fix some forgotten PendingSendBE cleanup + Add cleanup in SetAllData, WriteBlockArea - Remove RemoveBlockEntity (used once), HasBlockEntity (not used) * Replace MakeIndex with MakeIndexNoCheck * Remove extraneous MarkDirty in hopper & chests --- src/Chunk.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index 9178c6f1b..92e46cf5c 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -114,9 +114,6 @@ public: /** Writes the specified cBlockArea at the coords specified. Note that the coords may extend beyond the chunk! */ void WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes); - /** Returns true if there is a block entity at the coords specified */ - bool HasBlockEntityAt(Vector3i a_BlockPos); - /** Sets or resets the internal flag that prevents chunk from being unloaded. The flag is cumulative - it can be set multiple times and then needs to be un-set that many times before the chunk is unloadable again. */ @@ -493,7 +490,7 @@ private: /** Block entities that have been touched and need to be sent to all clients. Because block changes are buffered and we need to happen after them, this buffer exists too. - Pointers to block entities that were destroyed are guaranteed to be removed from this array by RemoveBlockEntity. */ + Pointers to block entities that were destroyed are guaranteed to be removed from this array by SetAllData, SetBlock, WriteBlockArea. */ std::vector m_PendingSendBlockEntities; /** A queue of relative positions to call cBlockHandler::Check on. @@ -543,8 +540,8 @@ private: void GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z); void GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ); - void RemoveBlockEntity(cBlockEntity * a_BlockEntity); - void AddBlockEntity (OwnedBlockEntity a_BlockEntity); + /** Takes ownership of a block entity, which MUST actually reside in this chunk. */ + void AddBlockEntity(OwnedBlockEntity a_BlockEntity); /** Wakes up each simulator for its specific blocks; through all the blocks in the chunk */ void WakeUpSimulators(void); -- cgit v1.2.3