Cuberite Forum

Full Version: Creating new drops
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I'm having a bit of trouble with new item drops within a plugin.

Whenever I create one, every once in a while a stone block will drop as well, and I can't pick them up. You can see the code here. Am I doing something wrong?
I think the last "else" branch is wrong:
amount = math.random(0,2)
if (amount ~= 0) then
  Pickups:Add(cItem(E_ITEM_POTATO, math.random(0,2)))
This checks the amount, but then uses a new random number for the amount anyway; if that results in a zero, it might misbehave.
Whoops. Thanks for catching that. Just went and fixed it.

The thing is, I'm having the issue with all of them: Wheat, Carrots, and Potatoes.

I've been thinking about it, and it might be due to passing World:SpawnItemPickups an empty cItems instance. Well, except it can spawn along with other items... Hmmm....
Your code is already checking for empty cItems instance. I'm not too sure about the last param to SpawnItemPickups, try setting it to zero for a quick test. Other than that, no idea what could be wrong, seems alright to me.
I tested your code, it works on my side
Yeah, I don't know what was causing it. It stopped happening randomly, and I can't get it to happen again.