From 748b121703fa28b10933f4432c09391e66179118 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 28 Mar 2021 14:40:57 +0100 Subject: Unify DoWithBlockEntity (#5168) + DoWith calls now broadcast the block entity and mark the chunk dirty + Add block entity change queue to synchronise BE updates with block updates * Fixed a few incorrect assertions about BE type - Remove manual overloads --- src/ChunkMap.h | 118 +++------------------------------------------------------ 1 file changed, 5 insertions(+), 113 deletions(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 99a1d764d..d0aeb867c 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -18,19 +18,6 @@ class cItems; class cChunkStay; class cChunk; class cPlayer; -class cBeaconEntity; -class cBedEntity; -class cBrewingstandEntity; -class cChestEntity; -class cDispenserEntity; -class cDropperEntity; -class cDropSpenserEntity; -class cFurnaceEntity; -class cHopperEntity; -class cNoteEntity; -class cCommandBlockEntity; -class cMobHeadEntity; -class cFlowerPotEntity; class cBlockArea; class cMobCensus; class cMobSpawner; @@ -40,22 +27,9 @@ class cDeadlockDetect; struct SetChunkData; typedef std::list cClientHandleList; -using cEntityCallback = cFunctionRef; -using cBeaconCallback = cFunctionRef; -using cBedCallback = cFunctionRef; -using cBlockEntityCallback = cFunctionRef; -using cBrewingstandCallback = cFunctionRef; -using cChestCallback = cFunctionRef; -using cChunkCallback = cFunctionRef; -using cDispenserCallback = cFunctionRef; -using cDropperCallback = cFunctionRef; -using cDropSpenserCallback = cFunctionRef; -using cFurnaceCallback = cFunctionRef; -using cHopperCallback = cFunctionRef; -using cNoteBlockCallback = cFunctionRef; -using cCommandBlockCallback = cFunctionRef; -using cMobHeadCallback = cFunctionRef; -using cFlowerPotCallback = cFunctionRef; +using cChunkCallback = cFunctionRef; +using cEntityCallback = cFunctionRef; +using cBlockEntityCallback = cFunctionRef; @@ -228,88 +202,9 @@ public: Returns true if all block entities processed, false if the callback aborted by returning true. */ bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback a_Callback); // Lua-accessible - /** Calls the callback for brewingstand in the specified chunk. - Returns true if all brewingstands processed, false if the callback aborted by returning true. */ - bool ForEachBrewingstandInChunk(int a_ChunkX, int a_ChunkZ, cBrewingstandCallback a_Callback); // Lua-accessible - - /** Calls the callback for each chest in the specified chunk. - Returns true if all chests processed, false if the callback aborted by returning true. */ - bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback a_Callback); // Lua-accessible - - /** Calls the callback for each dispenser in the specified chunk. - Returns true if all dispensers processed, false if the callback aborted by returning true. */ - bool ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallback a_Callback); - - /** Calls the callback for each dropper in the specified chunk. - Returns true if all droppers processed, false if the callback aborted by returning true. */ - bool ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback a_Callback); - - /** Calls the callback for each dropspenser in the specified chunk. - Returns true if all dropspensers processed, false if the callback aborted by returning true. */ - bool ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserCallback a_Callback); - - /** Calls the callback for each furnace in the specified chunk. - Returns true if all furnaces processed, false if the callback aborted by returning true. */ - bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback a_Callback); // Lua-accessible - /** Calls the callback for the block entity at the specified coords. - Returns false if there's no block entity at those coords, true if found. */ - bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback); // Lua-acessible - - /** Calls the callback for the beacon at the specified coords. - Returns false if there's no beacon at those coords, true if found. */ - bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback a_Callback); // Lua-acessible - - /** Calls the callback for the bed at the specified coords. - Returns false if there's no bed at those coords, true if found. */ - bool DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback); // Lua-acessible - - /** Calls the callback for the brewingstand at the specified coords; returns false if there's no brewingstand at those coords, true if found */ - bool DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBrewingstandCallback a_Callback); // Lua-acessible - - /** Calls the callback for the chest at the specified coords. - Returns false if there's no chest at those coords, true if found. */ - bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback a_Callback); // Lua-acessible - - /** Calls the callback for the dispenser at the specified coords. - Returns false if there's no dispenser at those coords or callback returns true, returns true if found. */ - bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback a_Callback); // Lua-accessible - - /** Calls the callback for the dropper at the specified coords. - Returns false if there's no dropper at those coords or callback returns true, returns true if found. */ - bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback a_Callback); // Lua-accessible - - /** Calls the callback for the dropspenser at the specified coords. - Returns false if there's no dropspenser at those coords or callback returns true, returns true if found. */ - bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback a_Callback); // Lua-accessible - - /** Calls the callback for the furnace at the specified coords. - Returns false if there's no furnace at those coords or callback returns true, returns true if found. */ - bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback a_Callback); // Lua-accessible - - /** Calls the callback for the hopper at the specified coords. - Returns false if there's no hopper at those coords or callback returns true, returns true if found. */ - bool DoWithHopperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperCallback a_Callback); // Lua-accessible - - /** Calls the callback for the noteblock at the specified coords. - Returns false if there's no noteblock at those coords or callback returns true, returns true if found. */ - bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback a_Callback); // Lua-accessible - - /** Calls the callback for the command block at the specified coords. - Returns false if there's no command block at those coords or callback returns true, returns true if found. */ - bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback a_Callback); // Lua-accessible - - /** Calls the callback for the mob head block at the specified coords. - Returns false if there's no mob head block at those coords or callback returns true, returns true if found. */ - bool DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback a_Callback); // Lua-accessible - - /** Calls the callback for the flower pot at the specified coords. - Returns false if there's no flower pot at those coords or callback returns true, returns true if found. */ - bool DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback a_Callback); // Lua-accessible - - /** Retrieves the test on the sign at the specified coords. - Returns false if there's no sign at those coords, true if found. */ - bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Lua-accessible + Returns false if there's no block entity at those coords, and whatever the callback returns if found. */ + bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback); // Lua-acessible /** Queues the chunk for preparing - making sure that it's generated and lit. The specified chunk is queued to be loaded or generated, and lit if needed. @@ -324,9 +219,6 @@ public: /** Marks the chunk as failed-to-load */ void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ); - /** Sets the sign text. Returns true if sign text changed. */ - bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); - /** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk()) */ void MarkChunkRegenerating(int a_ChunkX, int a_ChunkZ); -- cgit v1.2.3