summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/BedEntity.cpp9
-rw-r--r--src/BlockEntities/BedEntity.h1
-rw-r--r--src/BlockEntities/BlockEntity.cpp9
-rw-r--r--src/BlockEntities/BlockEntity.h5
-rw-r--r--src/BlockEntities/BlockEntityWithItems.cpp11
-rw-r--r--src/BlockEntities/BlockEntityWithItems.h1
-rw-r--r--src/BlockEntities/EnchantingTableEntity.cpp11
-rw-r--r--src/BlockEntities/EnchantingTableEntity.h1
-rw-r--r--src/BlockEntities/JukeboxEntity.cpp11
-rw-r--r--src/BlockEntities/MobHeadEntity.cpp9
-rw-r--r--src/BlockEntities/MobHeadEntity.h1
11 files changed, 68 insertions, 1 deletions
diff --git a/src/BlockEntities/BedEntity.cpp b/src/BlockEntities/BedEntity.cpp
index 55fc53b98..3d7005b12 100644
--- a/src/BlockEntities/BedEntity.cpp
+++ b/src/BlockEntities/BedEntity.cpp
@@ -24,6 +24,15 @@ cBedEntity::cBedEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a
+cItems cBedEntity::ConvertToPickups() const
+{
+ return cItem(E_ITEM_BED, 1, m_Color);
+}
+
+
+
+
+
void cBedEntity::CopyFrom(const cBlockEntity & a_Src)
{
Super::CopyFrom(a_Src);
diff --git a/src/BlockEntities/BedEntity.h b/src/BlockEntities/BedEntity.h
index 0a5d25767..fe5970681 100644
--- a/src/BlockEntities/BedEntity.h
+++ b/src/BlockEntities/BedEntity.h
@@ -38,6 +38,7 @@ public: // tolua_export
// tolua_end
// cBlockEntity overrides:
+ virtual cItems ConvertToPickups() const override;
virtual void CopyFrom(const cBlockEntity & a_Src) override;
virtual bool UsedBy(cPlayer * a_Player) override { return false; }
virtual void SendTo(cClientHandle & a_Client) override;
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index 7e7f5eaab..44d5e2d19 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -128,6 +128,15 @@ OwnedBlockEntity cBlockEntity::Clone(Vector3i a_Pos)
+cItems cBlockEntity::ConvertToPickups() const
+{
+ return {};
+}
+
+
+
+
+
void cBlockEntity::CopyFrom(const cBlockEntity & a_Src)
{
// Nothing to copy, but check that we're copying the right entity:
diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h
index 474192107..6232eb1ef 100644
--- a/src/BlockEntities/BlockEntity.h
+++ b/src/BlockEntities/BlockEntity.h
@@ -29,6 +29,7 @@
class cChunk;
+class cItems;
class cPlayer;
class cWorld;
class cBlockEntity;
@@ -83,6 +84,10 @@ public:
Uses CopyFrom() to copy the properties. */
OwnedBlockEntity Clone(Vector3i a_Pos);
+ /** Returns the contents of this block entity that it would drop if broken.
+ Note that the block itself is not included; that's handled by the block handler. */
+ virtual cItems ConvertToPickups() const;
+
/** Copies all properties of a_Src into this entity, except for its m_World and location.
Each non-abstract descendant should override to copy its specific properties, and call
Super::CopyFrom(a_Src) to copy the common ones. */
diff --git a/src/BlockEntities/BlockEntityWithItems.cpp b/src/BlockEntities/BlockEntityWithItems.cpp
index 9821bd539..5a52b9767 100644
--- a/src/BlockEntities/BlockEntityWithItems.cpp
+++ b/src/BlockEntities/BlockEntityWithItems.cpp
@@ -26,6 +26,17 @@ cBlockEntityWithItems::cBlockEntityWithItems(
+cItems cBlockEntityWithItems::ConvertToPickups() const
+{
+ cItems Pickups;
+ Pickups.AddItemGrid(m_Contents);
+ return Pickups;
+}
+
+
+
+
+
void cBlockEntityWithItems::CopyFrom(const cBlockEntity & a_Src)
{
Super::CopyFrom(a_Src);
diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h
index 2a809bb35..74e02693d 100644
--- a/src/BlockEntities/BlockEntityWithItems.h
+++ b/src/BlockEntities/BlockEntityWithItems.h
@@ -44,6 +44,7 @@ public: // tolua_export
);
// cBlockEntity overrides:
+ virtual cItems ConvertToPickups() const override;
virtual void CopyFrom(const cBlockEntity & a_Src) override;
// tolua_begin
diff --git a/src/BlockEntities/EnchantingTableEntity.cpp b/src/BlockEntities/EnchantingTableEntity.cpp
index 55124e7d3..81c42caaf 100644
--- a/src/BlockEntities/EnchantingTableEntity.cpp
+++ b/src/BlockEntities/EnchantingTableEntity.cpp
@@ -19,6 +19,17 @@ cEnchantingTableEntity::cEnchantingTableEntity(BLOCKTYPE a_BlockType, NIBBLETYPE
+cItems cEnchantingTableEntity::ConvertToPickups() const
+{
+ cItem Item(E_BLOCK_ENCHANTMENT_TABLE);
+ Item.m_CustomName = m_CustomName;
+ return Item;
+}
+
+
+
+
+
void cEnchantingTableEntity::CopyFrom(const cBlockEntity & a_Src)
{
Super::CopyFrom(a_Src);
diff --git a/src/BlockEntities/EnchantingTableEntity.h b/src/BlockEntities/EnchantingTableEntity.h
index f10fa3c87..d5e947838 100644
--- a/src/BlockEntities/EnchantingTableEntity.h
+++ b/src/BlockEntities/EnchantingTableEntity.h
@@ -24,6 +24,7 @@ public:
private:
// cBlockEntity overrides:
+ virtual cItems ConvertToPickups() const override;
virtual void CopyFrom(const cBlockEntity & a_Src) override;
virtual bool UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override;
diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp
index f5380e789..11d50b19a 100644
--- a/src/BlockEntities/JukeboxEntity.cpp
+++ b/src/BlockEntities/JukeboxEntity.cpp
@@ -40,7 +40,16 @@ cJukeboxEntity::~cJukeboxEntity()
void cJukeboxEntity::Destroy(void)
{
ASSERT(m_World != nullptr);
- EjectRecord();
+ m_World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_PLAY_MUSIC_DISC, GetPos(), 0);
+}
+
+
+
+
+
+cItems cJukeboxEntity::ConvertToPickups() const
+{
+ return IsPlayingRecord() ? cItem(static_cast<short>(m_Record)) : cItems();
}
diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp
index 36402f59f..eee6cf9c1 100644
--- a/src/BlockEntities/MobHeadEntity.cpp
+++ b/src/BlockEntities/MobHeadEntity.cpp
@@ -25,6 +25,15 @@ cMobHeadEntity::cMobHeadEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Ve
+cItems cMobHeadEntity::ConvertToPickups() const
+{
+ return cItem(E_ITEM_HEAD, 1, static_cast<short>(m_Type));
+}
+
+
+
+
+
void cMobHeadEntity::CopyFrom(const cBlockEntity & a_Src)
{
Super::CopyFrom(a_Src);
diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h
index 5c41b40d8..fe82a1027 100644
--- a/src/BlockEntities/MobHeadEntity.h
+++ b/src/BlockEntities/MobHeadEntity.h
@@ -70,6 +70,7 @@ public: // tolua_export
cUUID GetOwnerUUID(void) const { return m_OwnerUUID; } // Exported in ManualBindings.cpp
// cBlockEntity overrides:
+ virtual cItems ConvertToPickups() const override;
virtual void CopyFrom(const cBlockEntity & a_Src) override;
virtual bool UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override;