Unify block entity pickup conversion
- Removed normal BlockHandler knowledge of block entities during conversion + Added cBlockEntity::ConvertToPickups that handles it
This commit is contained in:
committed by
Alexander Harkness
parent
1a60164848
commit
c53a0ba5f6
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -44,6 +44,7 @@ public: // tolua_export
|
||||
);
|
||||
|
||||
// cBlockEntity overrides:
|
||||
virtual cItems ConvertToPickups() const override;
|
||||
virtual void CopyFrom(const cBlockEntity & a_Src) override;
|
||||
|
||||
// tolua_begin
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user