parent
bb7919d66b
commit
3a6002de5b
@ -19,16 +19,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) override
|
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) override
|
||||||
{
|
{
|
||||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
if (Meta & 0x8)
|
if (Meta & 0x8)
|
||||||
{
|
{
|
||||||
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_DropVerbatim);
|
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_CanDrop, a_DropVerbatim);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_DropVerbatim);
|
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop, a_DropVerbatim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,19 +418,22 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim)
|
void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim)
|
||||||
{
|
{
|
||||||
cItems Pickups;
|
cItems Pickups;
|
||||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
|
||||||
if (!a_DropVerbatim)
|
if (a_CanDrop)
|
||||||
{
|
{
|
||||||
ConvertToPickups(Pickups, Meta);
|
if (!a_DropVerbatim)
|
||||||
}
|
{
|
||||||
else
|
ConvertToPickups(Pickups, Meta);
|
||||||
{
|
}
|
||||||
// TODO: Add a proper overridable function for this
|
else
|
||||||
Pickups.Add(m_BlockType, 1, Meta);
|
{
|
||||||
|
// TODO: Add a proper overridable function for this
|
||||||
|
Pickups.Add(m_BlockType, 1, Meta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow plugins to modify the pickups:
|
// Allow plugins to modify the pickups:
|
||||||
|
@ -79,9 +79,10 @@ public:
|
|||||||
|
|
||||||
/** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins
|
/** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins
|
||||||
@param a_Digger The entity causing the drop; it may be NULL
|
@param a_Digger The entity causing the drop; it may be NULL
|
||||||
|
@param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand
|
||||||
@param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment)
|
@param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment)
|
||||||
*/
|
*/
|
||||||
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false);
|
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true, bool a_DropVerbatim = false);
|
||||||
|
|
||||||
/// Returns step sound name of block
|
/// Returns step sound name of block
|
||||||
virtual const char * GetStepSound(void);
|
virtual const char * GetStepSound(void);
|
||||||
|
@ -330,7 +330,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
|
|||||||
{
|
{
|
||||||
cChunkInterface ChunkInterface(a_World->GetChunkMap());
|
cChunkInterface ChunkInterface(a_World->GetChunkMap());
|
||||||
cBlockInServerPluginInterface PluginInterface(*a_World);
|
cBlockInServerPluginInterface PluginInterface(*a_World);
|
||||||
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block));
|
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
a_Player->UseEquippedItem();
|
a_Player->UseEquippedItem();
|
||||||
@ -511,9 +511,48 @@ bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
|
|||||||
|
|
||||||
bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
|
bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
|
||||||
{
|
{
|
||||||
UNUSED(a_BlockType);
|
switch (a_BlockType)
|
||||||
|
{
|
||||||
return false;
|
case E_BLOCK_ANVIL:
|
||||||
|
case E_BLOCK_ENCHANTMENT_TABLE:
|
||||||
|
case E_BLOCK_FURNACE:
|
||||||
|
case E_BLOCK_LIT_FURNACE:
|
||||||
|
case E_BLOCK_COAL_ORE:
|
||||||
|
case E_BLOCK_STONE:
|
||||||
|
case E_BLOCK_COBBLESTONE:
|
||||||
|
case E_BLOCK_END_STONE:
|
||||||
|
case E_BLOCK_MOSSY_COBBLESTONE:
|
||||||
|
case E_BLOCK_SANDSTONE_STAIRS:
|
||||||
|
case E_BLOCK_SANDSTONE:
|
||||||
|
case E_BLOCK_STONE_BRICKS:
|
||||||
|
case E_BLOCK_NETHER_BRICK:
|
||||||
|
case E_BLOCK_NETHERRACK:
|
||||||
|
case E_BLOCK_STONE_SLAB:
|
||||||
|
case E_BLOCK_DOUBLE_STONE_SLAB:
|
||||||
|
case E_BLOCK_STONE_PRESSURE_PLATE:
|
||||||
|
case E_BLOCK_BRICK:
|
||||||
|
case E_BLOCK_COBBLESTONE_STAIRS:
|
||||||
|
case E_BLOCK_COBBLESTONE_WALL:
|
||||||
|
case E_BLOCK_STONE_BRICK_STAIRS:
|
||||||
|
case E_BLOCK_NETHER_BRICK_STAIRS:
|
||||||
|
case E_BLOCK_CAULDRON:
|
||||||
|
case E_BLOCK_OBSIDIAN:
|
||||||
|
case E_BLOCK_DIAMOND_BLOCK:
|
||||||
|
case E_BLOCK_DIAMOND_ORE:
|
||||||
|
case E_BLOCK_GOLD_BLOCK:
|
||||||
|
case E_BLOCK_GOLD_ORE:
|
||||||
|
case E_BLOCK_REDSTONE_ORE:
|
||||||
|
case E_BLOCK_REDSTONE_ORE_GLOWING:
|
||||||
|
case E_BLOCK_EMERALD_ORE:
|
||||||
|
case E_BLOCK_IRON_BLOCK:
|
||||||
|
case E_BLOCK_IRON_ORE:
|
||||||
|
case E_BLOCK_LAPIS_ORE:
|
||||||
|
case E_BLOCK_LAPIS_BLOCK:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
default: return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ public:
|
|||||||
cItemSwordHandler(int a_ItemType)
|
cItemSwordHandler(int a_ItemType)
|
||||||
: cItemHandler(a_ItemType)
|
: cItemHandler(a_ItemType)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user