Gather rate 0.5x

Hey, when I have gather rate at 0.5x, when I pick up fruits and vegetables, sometimes I pick up a 0 amount of something; I was assuming it was a half of an item which doesn't really make sense but whatever, anyways upon picking up another one I got another 0, and they didn't combine into 1, I just had two 0's, which functioned perferctly as a whole thing by the way; I'm refering to it as a thing as it could be anything, as seed, a potato, etc.

Anyways, you see my problem here? I don't want to have nothing of something and have it function as somethething, so I was wondering if someone could adjust this to more properly address fraction values of gather rates?

Let's say my gather rate is 0.5x, and I pick up a hemp, That's 10 cloth x 1/2, = 5 cloth, and 1 seed x 0.5 = 0 seeds (in game logic.) I was wondering if the function that sets the value of things, could check to see if the value is a fraction, and if it is, leave it whole, but give it a chance to be deleted, in our case being 50% chance, as it is a (0.5) value we're looking at.

Hey, I solved this myself, although its quite clunky... as I sort of copied and pasted my code without really adding extra functions and that sort of things.

at every single spot with this code

item.amount = (int)(item.amount * modifier);​

I replaced it with this.

possibleFraction = (item.amount * modifier);
                item.amount = (int)(possibleFraction);
                if (possibleFraction > 0 && possibleFraction < 1)
                    if (UnityEngine.Random.Range(0f, 1f) < possibleFraction) 
                        item.amount = 1;
                    } else {

I came here to check to see if there was a way to reduce the rates rather than increase them. I hope that the author can officially integrate the above edit into the plugin!

If you use my code you will have to initialize the possibleFraction float in all of the functions with this code, I remember there being a couple of spots where I had to do so; hopefully the author integrates this and possibly makes it more pretty, but it does the job as it stands and can handle all sorts of fractions for different rates.

I also tried to use this for server-wide 0.5x, and noticed that if you gathered a single item like a picked a mushroom for example, you would get the item in your inventory but not be able to eat it or store it anywhere.

I implemented this simple fix using Math.Max() and now I am able to eat mushrooms again.
/change lines:
item.amount = (int)(item.amount * modifier);
item.amount = Math.Max((int)(item.amount * modifier), 1);

Basically this makes sure the item amount is at least 1 if the calculation ends up being less than 1.  However this has not been fully tested, so far I have only tested a few resources I was having issued with.

Merged post

I think both of these approaches could be implemented, with a config option to decide if you want fractional items to be possibly deleted or rounded up to 1