Dig Blocks, item not dropping
#1
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!
Reply
Thanks given by:
#2
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.. :/
Reply
Thanks given by:
#3
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
Reply
Thanks given by:
#4
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]
Reply
Thanks given by:
#5
Look here https://api.cuberite.org/cItem.html, the item damage is the meta value.
Reply
Thanks given by: ImCrafted
#6
I had no idea, thank you!
Reply
Thanks given by:
#7
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)
Reply
Thanks given by:
#8
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!
Reply
Thanks given by:
#9
Yes, I mean that it should be changed.
Reply
Thanks given by:




Users browsing this thread: 6 Guest(s)