Cuberite Forum
Creating new drops - 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: Creating new drops (/thread-2035.html)



Creating new drops - SamJBarney - 07-02-2015

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?


RE: Creating new drops - xoft - 07-02-2015

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.


RE: Creating new drops - SamJBarney - 07-02-2015

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....


RE: Creating new drops - xoft - 07-02-2015

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.


RE: Creating new drops - Seadragon91 - 07-03-2015

I tested your code, it works on my side


RE: Creating new drops - SamJBarney - 07-08-2015

Yeah, I don't know what was causing it. It stopped happening randomly, and I can't get it to happen again.