diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-25 21:31:48 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-25 21:31:48 +0200 |
commit | e4c09ca87d04a1512b59091fffc69d29a0e000a2 (patch) | |
tree | 098d2ed48fba367d243a4f296090f14d23653593 | |
parent | Correct placement for tripwire hooks (diff) | |
download | cuberite-e4c09ca87d04a1512b59091fffc69d29a0e000a2.tar cuberite-e4c09ca87d04a1512b59091fffc69d29a0e000a2.tar.gz cuberite-e4c09ca87d04a1512b59091fffc69d29a0e000a2.tar.bz2 cuberite-e4c09ca87d04a1512b59091fffc69d29a0e000a2.tar.lz cuberite-e4c09ca87d04a1512b59091fffc69d29a0e000a2.tar.xz cuberite-e4c09ca87d04a1512b59091fffc69d29a0e000a2.tar.zst cuberite-e4c09ca87d04a1512b59091fffc69d29a0e000a2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Chunk.cpp | 64 | ||||
-rw-r--r-- | src/Chunk.h | 35 | ||||
-rw-r--r-- | src/ChunkMap.cpp | 30 |
3 files changed, 63 insertions, 66 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index e5b4d83d7..d354448ce 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1999,10 +1999,10 @@ bool cChunk::ForEachFurnace(cFurnaceCallback a_Callback) template <class tyEntity, BLOCKTYPE... tBlocktype> -bool cChunk::GenericDoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFunctionRef<bool(tyEntity &)> a_Callback) +bool cChunk::GenericDoWithBlockEntityAt(Vector3i a_Position, cFunctionRef<bool(tyEntity &)> a_Callback) { // The blockentity list is locked by the parent chunkmap's CS - cBlockEntity * Block = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); + cBlockEntity * Block = GetBlockEntityRel(a_Position); if (Block == nullptr) { return false; // No block entity here @@ -2021,165 +2021,165 @@ bool cChunk::GenericDoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ -bool cChunk::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback) +bool cChunk::DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback) { - return GenericDoWithBlockEntityAt<cBlockEntity>(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return GenericDoWithBlockEntityAt<cBlockEntity>(a_Position, a_Callback); } -bool cChunk::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback a_Callback) +bool cChunk::DoWithBeaconAt(Vector3i a_Position, cBeaconCallback a_Callback) { return GenericDoWithBlockEntityAt<cBeaconEntity, E_BLOCK_BEACON - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback) +bool cChunk::DoWithBedAt(Vector3i a_Position, cBedCallback a_Callback) { return GenericDoWithBlockEntityAt<cBedEntity, E_BLOCK_BED - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBrewingstandCallback a_Callback) +bool cChunk::DoWithBrewingstandAt(Vector3i a_Position, cBrewingstandCallback a_Callback) { return GenericDoWithBlockEntityAt<cBrewingstandEntity, E_BLOCK_BREWING_STAND - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback a_Callback) +bool cChunk::DoWithChestAt(Vector3i a_Position, cChestCallback a_Callback) { return GenericDoWithBlockEntityAt<cChestEntity, E_BLOCK_CHEST, E_BLOCK_TRAPPED_CHEST - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback a_Callback) +bool cChunk::DoWithDispenserAt(Vector3i a_Position, cDispenserCallback a_Callback) { return GenericDoWithBlockEntityAt<cDispenserEntity, E_BLOCK_DISPENSER - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback a_Callback) +bool cChunk::DoWithDropperAt(Vector3i a_Position, cDropperCallback a_Callback) { return GenericDoWithBlockEntityAt<cDropperEntity, E_BLOCK_DROPPER - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback a_Callback) +bool cChunk::DoWithDropSpenserAt(Vector3i a_Position, cDropSpenserCallback a_Callback) { return GenericDoWithBlockEntityAt<cDropSpenserEntity, E_BLOCK_DISPENSER, E_BLOCK_DROPPER - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback a_Callback) +bool cChunk::DoWithFurnaceAt(Vector3i a_Position, cFurnaceCallback a_Callback) { return GenericDoWithBlockEntityAt<cFurnaceEntity, E_BLOCK_FURNACE, E_BLOCK_LIT_FURNACE - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithHopperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperCallback a_Callback) +bool cChunk::DoWithHopperAt(Vector3i a_Position, cHopperCallback a_Callback) { return GenericDoWithBlockEntityAt<cHopperEntity, E_BLOCK_HOPPER - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback a_Callback) +bool cChunk::DoWithNoteBlockAt(Vector3i a_Position, cNoteBlockCallback a_Callback) { return GenericDoWithBlockEntityAt<cNoteEntity, E_BLOCK_NOTE_BLOCK - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback a_Callback) +bool cChunk::DoWithCommandBlockAt(Vector3i a_Position, cCommandBlockCallback a_Callback) { return GenericDoWithBlockEntityAt<cCommandBlockEntity, E_BLOCK_COMMAND_BLOCK - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback a_Callback) +bool cChunk::DoWithMobHeadAt(Vector3i a_Position, cMobHeadCallback a_Callback) { return GenericDoWithBlockEntityAt<cMobHeadEntity, E_BLOCK_HEAD - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback a_Callback) +bool cChunk::DoWithFlowerPotAt(Vector3i a_Position, cFlowerPotCallback a_Callback) { return GenericDoWithBlockEntityAt<cFlowerPotEntity, E_BLOCK_FLOWER_POT - >(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + >(a_Position, a_Callback); } -bool cChunk::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) +bool cChunk::GetSignLines(Vector3i a_Position, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) { // The blockentity list is locked by the parent chunkmap's CS - auto Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); + auto Entity = GetBlockEntity(a_Position); if (Entity == nullptr) { return false; // Not a block entity diff --git a/src/Chunk.h b/src/Chunk.h index 96adf71d7..884682962 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -306,52 +306,52 @@ public: tBlocktype is a list of the blocktypes to be called. If no BLOCKTYPE template arguments are given the callback is called for any block entity Accessible only from within Chunk.cpp */ template <class tyEntity, BLOCKTYPE... tBlocktype> - bool GenericDoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFunctionRef<bool(tyEntity &)> a_Callback); + bool GenericDoWithBlockEntityAt(Vector3i a_Position, cFunctionRef<bool(tyEntity &)> a_Callback); /** 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 + bool DoWithBlockEntityAt(Vector3i a_Position, 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 + bool DoWithBeaconAt(Vector3i a_Position, cBeaconCallback 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 + bool DoWithBrewingstandAt(Vector3i a_Position, cBrewingstandCallback 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 + bool DoWithBedAt(Vector3i a_Position, cBedCallback 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 + bool DoWithChestAt(Vector3i a_Position, 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); + bool DoWithDispenserAt(Vector3i a_Position, cDispenserCallback a_Callback); /** Calls the callback for the dispenser 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); + bool DoWithDropperAt(Vector3i a_Position, cDropperCallback a_Callback); /** Calls the callback for the dispenser 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); + bool DoWithDropSpenserAt(Vector3i a_Position, cDropSpenserCallback a_Callback); /** 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 + bool DoWithFurnaceAt(Vector3i a_Position, 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 + bool DoWithHopperAt(Vector3i a_Position, 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); + bool DoWithNoteBlockAt(Vector3i a_Position, cNoteBlockCallback a_Callback); /** 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); + bool DoWithCommandBlockAt(Vector3i a_Position, cCommandBlockCallback a_Callback); /** 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); + bool DoWithMobHeadAt(Vector3i a_Position, cMobHeadCallback a_Callback); /** 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); + bool DoWithFlowerPotAt(Vector3i a_Position, cFlowerPotCallback a_Callback); /** 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 + bool GetSignLines (Vector3i a_Position, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Lua-accessible /** Use block entity on coordinate. returns true if the use was successful, return false to use the block as a "normal" block */ @@ -536,9 +536,7 @@ public: cFluidSimulatorData * GetWaterSimulatorData(void) { return m_WaterSimulatorData; } cFluidSimulatorData * GetLavaSimulatorData (void) { return m_LavaSimulatorData; } cSandSimulatorChunkData & GetSandSimulatorData (void) { return m_SandSimulatorData; } - cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return m_RedstoneSimulatorData; } - void SetRedstoneSimulatorData(cRedstoneSimulatorChunkData * a_Data) { m_RedstoneSimulatorData = a_Data; } /** Returns the block entity at the specified (absolute) coords. Returns nullptr if no such BE or outside this chunk. */ @@ -643,7 +641,6 @@ private: cFluidSimulatorData * m_WaterSimulatorData; cFluidSimulatorData * m_LavaSimulatorData; cSandSimulatorChunkData m_SandSimulatorData; - cRedstoneSimulatorChunkData * m_RedstoneSimulatorData; /** If greater than zero, the chunk is ticked even if it has no clients. diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 0ff4d5ff7..9a3baa609 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1474,7 +1474,7 @@ bool cChunkMap::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cB { return false; } - return Chunk->DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithBlockEntityAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1492,7 +1492,7 @@ bool cChunkMap::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeacon { return false; } - return Chunk->DoWithBeaconAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithBeaconAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1510,7 +1510,7 @@ bool cChunkMap::DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallba { return false; } - return Chunk->DoWithBedAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithBedAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1528,7 +1528,7 @@ bool cChunkMap::DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, c { return false; } - return Chunk->DoWithBrewingstandAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithBrewingstandAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1546,7 +1546,7 @@ bool cChunkMap::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCa { return false; } - return Chunk->DoWithChestAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithChestAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1564,7 +1564,7 @@ bool cChunkMap::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDis { return false; } - return Chunk->DoWithDispenserAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithDispenserAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1582,7 +1582,7 @@ bool cChunkMap::DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropp { return false; } - return Chunk->DoWithDropperAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithDropperAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1600,7 +1600,7 @@ bool cChunkMap::DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cD { return false; } - return Chunk->DoWithDropSpenserAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithDropSpenserAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1618,7 +1618,7 @@ bool cChunkMap::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurna { return false; } - return Chunk->DoWithFurnaceAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithFurnaceAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1636,7 +1636,7 @@ bool cChunkMap::DoWithHopperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cHopper { return false; } - return Chunk->DoWithHopperAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithHopperAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1654,7 +1654,7 @@ bool cChunkMap::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNot { return false; } - return Chunk->DoWithNoteBlockAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithNoteBlockAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1672,7 +1672,7 @@ bool cChunkMap::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, c { return false; } - return Chunk->DoWithCommandBlockAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithCommandBlockAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1690,7 +1690,7 @@ bool cChunkMap::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHe { return false; } - return Chunk->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithMobHeadAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1708,7 +1708,7 @@ bool cChunkMap::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlo { return false; } - return Chunk->DoWithFlowerPotAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); + return Chunk->DoWithFlowerPotAt({ BlockX, BlockY, BlockZ }, a_Callback); } @@ -1726,7 +1726,7 @@ bool cChunkMap::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & { return false; } - return Chunk->GetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4); + return Chunk->GetSignLines({ BlockX, BlockY, BlockZ }, a_Line1, a_Line2, a_Line3, a_Line4); } |