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:
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;
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(m_BlockType, 1, a_BlockMeta >> 2);
|
||||
}
|
||||
|
@ -168,14 +168,10 @@ void cBlockBedHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWor
|
||||
|
||||
|
||||
|
||||
cItems cBlockBedHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
cItems cBlockBedHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
{
|
||||
short color = E_META_WOOL_RED;
|
||||
if (a_BlockEntity != nullptr)
|
||||
{
|
||||
color = reinterpret_cast<cBedEntity *>(a_BlockEntity)->GetColor();
|
||||
}
|
||||
return cItem(E_ITEM_BED, 1, color);
|
||||
// Drops handled by the block entity:
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,12 +67,7 @@ private:
|
||||
const Vector3i a_CursorPos
|
||||
) const override;
|
||||
|
||||
virtual cItems ConvertToPickups(
|
||||
NIBBLETYPE a_BlockMeta,
|
||||
cBlockEntity * a_BlockEntity,
|
||||
const cEntity * a_Digger,
|
||||
const cItem * a_Tool
|
||||
) const override;
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override;
|
||||
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player,
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
if (IsMetaTopPart(a_BlockMeta))
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
if (ToolHasSilkTouch(a_Tool))
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../BlockEntities/BrewingstandEntity.h"
|
||||
#include "Mixins.h"
|
||||
|
||||
|
||||
@ -19,15 +18,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
cItems res(cItem(E_ITEM_BREWING_STAND, 1)); // We have to drop the item form of a brewing stand
|
||||
if (a_BlockEntity != nullptr)
|
||||
{
|
||||
auto be = static_cast<cBrewingstandEntity *>(a_BlockEntity);
|
||||
res.AddItemGrid(be->GetContents());
|
||||
}
|
||||
return res;
|
||||
return cItem(E_ITEM_BREWING_STAND); // We have to drop the item form of a brewing stand
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Give nothing
|
||||
return {};
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_CAULDRON, 1, 0);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../BlockEntities/ChestEntity.h"
|
||||
#include "../BlockArea.h"
|
||||
#include "../Entities/Player.h"
|
||||
#include "Mixins.h"
|
||||
@ -11,9 +10,9 @@
|
||||
|
||||
|
||||
class cBlockChestHandler :
|
||||
public cYawRotator<cContainerEntityHandler<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05>
|
||||
public cYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05>
|
||||
{
|
||||
using Super = cYawRotator<cContainerEntityHandler<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05>;
|
||||
using Super = cYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05>;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Silk touch gives cobweb, anything else gives just string:
|
||||
if (ToolHasSilkTouch(a_Tool))
|
||||
|
@ -70,7 +70,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// If fully grown, give 3 items, otherwise just one:
|
||||
auto growState = a_BlockMeta >> 2;
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Don't allow as a pickup:
|
||||
return {};
|
||||
|
@ -182,7 +182,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_COMPARATOR, 1, 0);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
auto & rand = GetRandomProvider();
|
||||
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// If cutting down with shears, drop self:
|
||||
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
if (a_BlockMeta == E_META_DIRT_COARSE)
|
||||
{
|
||||
|
@ -196,7 +196,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
switch (m_BlockType)
|
||||
{
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Blocks/BlockPiston.h"
|
||||
#include "../BlockEntities/DropSpenserEntity.h"
|
||||
#include "Mixins.h"
|
||||
|
||||
|
||||
@ -14,9 +12,9 @@
|
||||
|
||||
|
||||
class cBlockDropSpenserHandler :
|
||||
public cPitchYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>
|
||||
public cPitchYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>
|
||||
{
|
||||
using Super = cPitchYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>;
|
||||
using Super = cPitchYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>;
|
||||
|
||||
public:
|
||||
|
||||
@ -24,28 +22,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
cItems res(cItem(m_BlockType, 1));
|
||||
if (a_BlockEntity != nullptr)
|
||||
{
|
||||
auto be = static_cast<cDropSpenserEntity *>(a_BlockEntity);
|
||||
res.AddItemGrid(be->GetContents());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
|
||||
{
|
||||
UNUSED(a_Meta);
|
||||
return 11;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -62,17 +62,10 @@ private:
|
||||
}
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
if ((a_BlockEntity == nullptr) || (a_BlockEntity->GetBlockType() != E_BLOCK_ENCHANTMENT_TABLE))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto & EnchantingTable = static_cast<const cEnchantingTableEntity &>(*a_BlockEntity);
|
||||
cItem Item = cItem(E_BLOCK_ENCHANTMENT_TABLE);
|
||||
Item.m_CustomName = EnchantingTable.GetCustomName();
|
||||
return Item;
|
||||
// Drops handled by the block entity:
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BlockEntity.h"
|
||||
#include "Mixins.h"
|
||||
|
||||
|
||||
@ -18,7 +17,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Only drop something when mined with a pickaxe:
|
||||
if (
|
||||
@ -29,13 +28,12 @@ private:
|
||||
// Only drop self when mined with a silk-touch pickaxe:
|
||||
if (a_Tool->m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)
|
||||
{
|
||||
return cItem(E_BLOCK_ENDER_CHEST, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return cItem(E_BLOCK_OBSIDIAN, 8, 0);
|
||||
return cItem(E_BLOCK_ENDER_CHEST);
|
||||
}
|
||||
|
||||
return cItem(E_BLOCK_OBSIDIAN, 8);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "BlockHandler.h"
|
||||
#include "ChunkInterface.h"
|
||||
#include "../Item.h"
|
||||
#include "../BlockEntities/BlockEntityWithItems.h"
|
||||
|
||||
|
||||
|
||||
@ -44,37 +43,3 @@ private:
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Wrapper for blocks that have a cBlockEntityWithItems descendant attached to them.
|
||||
When converting to pickups, drops self with meta reset to zero, and adds the container contents. */
|
||||
template <typename Base = cBlockEntityHandler>
|
||||
class cContainerEntityHandler:
|
||||
public Base
|
||||
{
|
||||
public:
|
||||
|
||||
constexpr cContainerEntityHandler(BLOCKTYPE a_BlockType):
|
||||
Base(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Reset meta to 0
|
||||
cItems res(cItem(Base::m_BlockType, 1, 0));
|
||||
|
||||
// Drop the contents:
|
||||
if (a_BlockEntity != nullptr)
|
||||
{
|
||||
auto container = static_cast<cBlockEntityWithItems *>(a_BlockEntity);
|
||||
res.AddItemGrid(container->GetContents());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_BLOCK_DIRT, 1, 0);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// No pickups from this block
|
||||
return {};
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
NIBBLETYPE meta = a_BlockMeta & 0x7;
|
||||
return cItem(m_BlockType, 1, meta);
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BlockEntity.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@ -18,7 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_FLOWER_POT, 1, 0);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// No pickups
|
||||
return {};
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Blocks/BlockPiston.h"
|
||||
#include "../BlockEntities/FurnaceEntity.h"
|
||||
#include "Mixins.h"
|
||||
|
||||
|
||||
@ -19,15 +17,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
cItems res(cItem(E_BLOCK_FURNACE, 1)); // We can't drop a lit furnace
|
||||
if (a_BlockEntity != nullptr)
|
||||
{
|
||||
auto be = static_cast<cFurnaceEntity *>(a_BlockEntity);
|
||||
res.AddItemGrid(be->GetContents());
|
||||
}
|
||||
return res;
|
||||
return cItem(E_BLOCK_FURNACE); // We can't drop a lit furnace
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Only drop self when mined with silk-touch:
|
||||
if (ToolHasSilkTouch(a_Tool))
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Drop self only when using silk-touch:
|
||||
if (ToolHasSilkTouch(a_Tool))
|
||||
|
@ -31,7 +31,7 @@ private:
|
||||
DieInDarkness
|
||||
};
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
if (!ToolHasSilkTouch(a_Tool))
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// TODO: Handle the Fortune and Silk touch enchantments here
|
||||
if (GetRandomProvider().RandBool(0.10))
|
||||
|
@ -522,21 +522,13 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i
|
||||
|
||||
|
||||
|
||||
cItems cBlockHandler::ConvertToPickups(
|
||||
NIBBLETYPE a_BlockMeta,
|
||||
cBlockEntity * a_BlockEntity,
|
||||
const cEntity * a_Digger,
|
||||
const cItem * a_Tool
|
||||
) const
|
||||
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
{
|
||||
UNUSED(a_BlockEntity);
|
||||
UNUSED(a_Digger);
|
||||
UNUSED(a_Tool);
|
||||
|
||||
// Add self:
|
||||
cItems res;
|
||||
res.push_back(cItem(m_BlockType, 1, a_BlockMeta));
|
||||
return res;
|
||||
return cItem(m_BlockType, 1, a_BlockMeta);
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,16 +146,10 @@ public:
|
||||
|
||||
/** Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
|
||||
Doesn't do any actual block change / mining, only calculates the pickups.
|
||||
a_BlockEntity is the block entity present at the block, if any, nullptr if none.
|
||||
a_Digger is the entity that caused the conversion, usually the player digging.
|
||||
a_Tool is the tool used for the digging.
|
||||
The default implementation drops a single item created from m_BlockType and the current meta. */
|
||||
virtual cItems ConvertToPickups(
|
||||
NIBBLETYPE a_BlockMeta,
|
||||
cBlockEntity * a_BlockEntity,
|
||||
const cEntity * a_Digger = nullptr,
|
||||
const cItem * a_Tool = nullptr
|
||||
) const;
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger = nullptr, const cItem * a_Tool = nullptr) const;
|
||||
|
||||
/** Checks if the block can stay at the specified relative coords in the chunk */
|
||||
virtual bool CanBeAt(
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
|
||||
class cBlockHopperHandler :
|
||||
public cPitchYawRotator<cContainerEntityHandler<cBlockEntityHandler>>
|
||||
public cPitchYawRotator<cClearMetaOnDrop<cBlockEntityHandler>>
|
||||
{
|
||||
using Super = cPitchYawRotator<cContainerEntityHandler<cBlockEntityHandler>>;
|
||||
using Super = cPitchYawRotator<cClearMetaOnDrop<cBlockEntityHandler>>;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Only drop self when using silk-touch:
|
||||
if (ToolHasSilkTouch(a_Tool))
|
||||
|
@ -93,7 +93,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// If breaking with shears, drop self:
|
||||
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Reset meta to zero:
|
||||
return cItem(E_BLOCK_LEVER, 1, 0);
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_MELON_SLICE, GetRandomProvider().RandInt<char>(3, 7), 0);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockEntity.h"
|
||||
#include "../BlockEntities/MobHeadEntity.h"
|
||||
|
||||
|
||||
|
||||
@ -19,14 +18,10 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
if ((a_BlockEntity == nullptr) || (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
auto mobHeadEntity = static_cast<cMobHeadEntity *>(a_BlockEntity);
|
||||
return cItem(E_ITEM_HEAD, 1, static_cast<short>(mobHeadEntity->GetType()));
|
||||
// Drops handled by the block entity:
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// No pickups
|
||||
return {};
|
||||
|
@ -18,7 +18,7 @@ private:
|
||||
|
||||
// TODO: Add Mycel Spread
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_BLOCK_DIRT, 1, 0);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
if (a_BlockMeta == 0x03)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// If using silk-touch, drop self rather than the resource:
|
||||
if (ToolHasSilkTouch(a_Tool))
|
||||
|
@ -339,7 +339,7 @@ void cBlockPistonHeadHandler::OnBroken(
|
||||
|
||||
|
||||
|
||||
cItems cBlockPistonHeadHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
cItems cBlockPistonHeadHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
{
|
||||
// Give a normal\sticky piston base, not piston extension
|
||||
// With 1.7, the item forms of these technical blocks have been removed, so giving someone this will crash their client...
|
||||
|
@ -159,5 +159,5 @@ public:
|
||||
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
|
||||
) const override;
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override;
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override;
|
||||
} ;
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// No pickups
|
||||
return {};
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_REDSTONE_DUST, 1, 0);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Always drop the Off variant:
|
||||
return(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0));
|
||||
|
@ -135,7 +135,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_REDSTONE_REPEATER, 1, 0);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Always drop the ON torch, meta 0
|
||||
return cItem(E_BLOCK_REDSTONE_TORCH_ON, 1, 0);
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// The low 3 bits store the sapling type; bit 0x08 is the growth timer (not used in pickups)
|
||||
return cItem(m_BlockType, 1, a_BlockMeta & 0x07);
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Drop self only when using silk-touch:
|
||||
if (ToolHasSilkTouch(a_Tool))
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Reset the orientation part of meta, keep the sub-type part of meta
|
||||
return cItem(m_BlockType, 1, a_BlockMeta & 0x03);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_SIGN, 1, 0);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Reset the "top half" flag:
|
||||
return cItem(m_BlockType, 1, a_BlockMeta & 0x07);
|
||||
@ -246,7 +246,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
BLOCKTYPE Block = GetSingleSlabType(m_BlockType);
|
||||
return cItem(Block, 2, a_BlockMeta & 0x7);
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// No drop unless dug up with a shovel
|
||||
if ((a_Tool == nullptr) || !ItemCategory::IsShovel(a_Tool->m_ItemType))
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(StemPickupType, 1, 0);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Convert stone to cobblestone, unless using silk-touch:
|
||||
if (
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_SUGARCANE, 1, 0);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// If using shears, drop self:
|
||||
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_STRING, 1, 0);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Only drops self when using shears, otherwise drops nothing:
|
||||
if ((a_Tool == nullptr) || (a_Tool->m_ItemType != E_ITEM_SHEARS))
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
return cItem(E_ITEM_SIGN, 1, 0);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Don't drop anything:
|
||||
return {};
|
||||
@ -63,7 +63,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// Reset the meta to zero:
|
||||
return cItem(this->m_BlockType);
|
||||
|
@ -930,20 +930,34 @@ void cChunk::ApplyWeatherToTop()
|
||||
|
||||
cItems cChunk::PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, const cItem * a_Tool)
|
||||
{
|
||||
BLOCKTYPE blockType;
|
||||
NIBBLETYPE blockMeta;
|
||||
GetBlockTypeMeta(a_RelPos, blockType, blockMeta);
|
||||
auto blockEntity = GetBlockEntityRel(a_RelPos);
|
||||
cItems pickups (0);
|
||||
auto toolHandler = a_Tool ? a_Tool->GetHandler() : cItemHandler::GetItemHandler(E_ITEM_EMPTY);
|
||||
auto canHarvestBlock = toolHandler->CanHarvestBlock(blockType);
|
||||
if (canHarvestBlock)
|
||||
BLOCKTYPE BlockType;
|
||||
NIBBLETYPE BlockMeta;
|
||||
GetBlockTypeMeta(a_RelPos, BlockType, BlockMeta);
|
||||
|
||||
cItems Pickups;
|
||||
const auto BlockEntity = GetBlockEntityRel(a_RelPos);
|
||||
|
||||
const auto ToolHandler = (a_Tool != nullptr) ? a_Tool->GetHandler() : cItemHandler::GetItemHandler(E_ITEM_EMPTY);
|
||||
if (ToolHandler->CanHarvestBlock(BlockType))
|
||||
{
|
||||
pickups = cBlockHandler::For(blockType).ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool);
|
||||
Pickups = cBlockHandler::For(BlockType).ConvertToPickups(BlockMeta, a_Digger, a_Tool);
|
||||
|
||||
if (BlockEntity != nullptr)
|
||||
{
|
||||
auto BlockEntityPickups = BlockEntity->ConvertToPickups();
|
||||
Pickups.insert(Pickups.end(), std::make_move_iterator(BlockEntityPickups.begin()), std::make_move_iterator(BlockEntityPickups.end()));
|
||||
}
|
||||
}
|
||||
auto absPos = RelativeToAbsolute(a_RelPos);
|
||||
cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(*m_World, absPos, blockType, blockMeta, blockEntity, a_Digger, a_Tool, pickups);
|
||||
return pickups;
|
||||
|
||||
// TODO: this should be in cWorld::DropBlockAsPickups. When it's here we can't check the return value and cancel spawning:
|
||||
cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(
|
||||
*m_World,
|
||||
cChunkDef::RelativeToAbsolute(a_RelPos, GetPos()),
|
||||
BlockType, BlockMeta, BlockEntity,
|
||||
a_Digger, a_Tool, Pickups
|
||||
);
|
||||
|
||||
return Pickups;
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,10 +140,7 @@ namespace Explodinator
|
||||
else if (Random.RandBool(1.f / a_Power))
|
||||
{
|
||||
const auto DestroyedMeta = a_Chunk.GetMeta(a_Position);
|
||||
a_Chunk.GetWorld()->SpawnItemPickups(
|
||||
cBlockHandler::For(DestroyedBlock).ConvertToPickups(DestroyedMeta, a_Chunk.GetBlockEntityRel(a_Position)),
|
||||
Absolute
|
||||
);
|
||||
a_Chunk.GetWorld()->SpawnItemPickups(cBlockHandler::For(DestroyedBlock).ConvertToPickups(DestroyedMeta), Absolute);
|
||||
}
|
||||
else if (a_Fiery && Random.RandBool(1.f / 3.f)) // 33% chance of starting fires if it can start fires
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i
|
||||
|
||||
|
||||
|
||||
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
{
|
||||
return cItems();
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i
|
||||
|
||||
|
||||
|
||||
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
{
|
||||
return cItems();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i
|
||||
|
||||
|
||||
|
||||
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const
|
||||
{
|
||||
return cItems();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user