06-14-2012, 03:45 AM
Rev 602 has a new hook, HOOK_BLOCK_TO_PICKUP, that is called each time a player breaks a block and it can modify the pickups that they receive. It is called when MCServer has already decided what the standard pickups should be, and the hook can add / modify / remove them.
Hook parameters: BlockType, BlockMeta, cPlayer, cItem (equipped), cItems (pickups)
Example code that makes grass drop 4 diamonds:
Hook parameters: BlockType, BlockMeta, cPlayer, cItem (equipped), cItems (pickups)
Example code that makes grass drop 4 diamonds:
Code:
PluginManager:AddHook(Plugin, cPluginManager.HOOK_BLOCK_TO_PICKUP)
...
function OnBlockToPickup(BlockType, BlockMeta, Player, EquippedItem, Pickups)
if (BlockType == E_BLOCK_GRASS) then
Pickups:Clear()
Pickups:Add(E_ITEM_DIAMOND, 4, 0)
return true
end
return false
end