Cuberite Forum
Dig Blocks, item not dropping - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Dig Blocks, item not dropping (/thread-2968.html)



Dig Blocks, item not dropping - ImCrafted - 06-05-2017

I have the following code in my plugin CRPG, similar to bukkit's MCMMO. It's almost ready for release however, I have the following code

Code:
   World = Player:GetWorld()
   World:DigBlock(BlockX, BlockY, BlockZ)


And it is working fine in that it's destroying the blocks a character clicks on, however I'm unsure of how to get the blocks to be instantly destroyed and have the item drop like normal. Is there some class for this that can do this?

Any help with this would be greatly appreciated!


RE: Dig Blocks, item not dropping - ImCrafted - 06-05-2017

I've narrowed it down to me using World:SpawnItemPickups, but I'm not sure the proper format to get that to work, spent quite a lot of time trying though.. :/


RE: Dig Blocks, item not dropping - Seadragon91 - 06-05-2017

Here a example, you would need to set the world object, e.g. world = Player:GetWorld()

Code:
-- The items to drop
local items = cItems()
items:Add(cItem(E_BLOCK_STONE, 12))
items:Add(cItem(E_BLOCK_COBBLESTONE, 6))
items:Add(cItem(E_BLOCK_SAND, 3))

-- The world where the pickup should be spawned
local world = <world>

-- Change the position of the spawn
world:SpawnItemPickups(100, 100, 100, items, 0)

cItems -> https://api.cuberite.org/cItems.html


RE: Dig Blocks, item not dropping - ImCrafted - 06-05-2017

That works great! Thanks!

However, using cItems, I don't see a way to specify the item meta, for example I have an instant miner, but when I mine andesite and diorite it just drops stone. The page for cItem says nothing about specifying this data (yes it did Big Grin ), along with SpawnItemPickups.

[Image: QkjPlkH.png]


RE: Dig Blocks, item not dropping - Seadragon91 - 06-05-2017

Look here https://api.cuberite.org/cItem.html, the item damage is the meta value.


RE: Dig Blocks, item not dropping - ImCrafted - 06-05-2017

I had no idea, thank you!


RE: Dig Blocks, item not dropping - xoft - 06-05-2017

I think the cWorld:DigBlock() function should also spawn the pickups, otherwise what's the point of it - there's no difference from cWorld:SetBlock(E_BLOCK_AIR)


RE: Dig Blocks, item not dropping - ImCrafted - 06-05-2017

I don't believe so, tested it many times. It was my understanding when I saw what the function was named that it would actually dig the block, as in give a drop like if you were digging it, however the block just gets replaced with air, also the documentation says "Replaces the specified block with air, without dropping the usual pickups for the block."

Or perhaps you meant that you think it should and currently doesn't, spawn the pickups, in which we can both agree there!


RE: Dig Blocks, item not dropping - xoft - 06-05-2017

Yes, I mean that it should be changed.