summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks')
-rw-r--r--src/Blocks/BlockBed.cpp12
-rw-r--r--src/Blocks/BlockEnchantingTable.h4
-rw-r--r--src/Blocks/BlockNoteBlock.h9
-rw-r--r--src/Blocks/WorldInterface.h6
4 files changed, 12 insertions, 19 deletions
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp
index 58ff720c8..4fd3eba54 100644
--- a/src/Blocks/BlockBed.cpp
+++ b/src/Blocks/BlockBed.cpp
@@ -158,12 +158,12 @@ bool cBlockBedHandler::OnUse(
void cBlockBedHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, const sSetBlock & a_BlockChange) const
{
- a_Player.GetWorld()->DoWithBedAt(a_BlockChange.GetX(), a_BlockChange.GetY(), a_BlockChange.GetZ(), [&](cBedEntity & a_Bed)
- {
- a_Bed.SetColor(a_Player.GetEquippedItem().m_ItemDamage);
- return true;
- }
- );
+ a_Player.GetWorld()->DoWithBlockEntityAt(a_BlockChange.GetAbsolutePos(), [&a_Player](cBlockEntity & a_BlockEntity)
+ {
+ ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_BED);
+ static_cast<cBedEntity &>(a_BlockEntity).SetColor(a_Player.GetEquippedItem().m_ItemDamage);
+ return false;
+ });
}
diff --git a/src/Blocks/BlockEnchantingTable.h b/src/Blocks/BlockEnchantingTable.h
index c921d8f27..33d7092e3 100644
--- a/src/Blocks/BlockEnchantingTable.h
+++ b/src/Blocks/BlockEnchantingTable.h
@@ -32,7 +32,7 @@ private:
) const override
{
AString WindowName = "Enchant";
- a_WorldInterface.DoWithBlockEntityAt(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, [&WindowName](cBlockEntity & a_Entity)
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockPos, [&WindowName](cBlockEntity & a_Entity)
{
if (a_Entity.GetBlockType() != E_BLOCK_ENCHANTMENT_TABLE)
{
@@ -46,7 +46,7 @@ private:
WindowName = CustomName;
}
- return true;
+ return false;
});
cWindow * Window = new cEnchantingWindow(a_BlockPos, std::move(WindowName));
diff --git a/src/Blocks/BlockNoteBlock.h b/src/Blocks/BlockNoteBlock.h
index ac1ab7238..566b9bef5 100644
--- a/src/Blocks/BlockNoteBlock.h
+++ b/src/Blocks/BlockNoteBlock.h
@@ -26,18 +26,15 @@ private:
const Vector3i a_BlockPos
) const override
{
- a_WorldInterface.DoWithBlockEntityAt(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, [](cBlockEntity & a_BlockEntity)
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockPos, [](cBlockEntity & a_BlockEntity)
{
if (a_BlockEntity.GetBlockType() != E_BLOCK_NOTE_BLOCK)
{
return false;
}
- auto & NoteEntity = static_cast<cNoteEntity &>(a_BlockEntity);
-
- NoteEntity.MakeSound();
-
- return true;
+ static_cast<cNoteEntity &>(a_BlockEntity).MakeSound();
+ return false;
});
}
};
diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h
index 2a39ffbc2..4ae3f33c9 100644
--- a/src/Blocks/WorldInterface.h
+++ b/src/Blocks/WorldInterface.h
@@ -4,13 +4,11 @@
#include "../FunctionRef.h"
#include "../Mobs/MonsterTypes.h"
-class cBedEntity;
class cBlockEntity;
class cBroadcastInterface;
class cItems;
class cPlayer;
-using cBedCallback = cFunctionRef<bool(cBedEntity &)>;
using cBlockEntityCallback = cFunctionRef<bool(cBlockEntity &)>;
using cPlayerListCallback = cFunctionRef<bool(cPlayer &)>;
using cEntityCallback = cFunctionRef<bool(cEntity &)>;
@@ -32,10 +30,8 @@ public:
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) = 0;
- virtual bool DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback) = 0;
-
/** 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 */
- virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback) = 0;
+ virtual bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback) = 0;
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) = 0;