AgriCraft

AgriCraft

30M Downloads

[Bug/Suggestion] Breaking tallgrass crashes

Timeslice42 opened this issue ยท 9 comments

commented

If I have B:"Clear tall grass drops"=true but have nothing defined in GrassDrops.txt then when I break tallgrass the game crashes with an illegal argument exception on net.minecraft.util.WeightedRandom. (http://paste.ee/p/wFU6V)
Since I just wanted to use this as an easy way to clear all grass drops, this was not a user error on my part. Could you add this functionality/fix the exception?

commented

It appears it just doesn't like it if the list holding the possible drops is empty. This is an issue in the minecraft code meaning you will have to add one item that can drop from grass or else you will crash. I'm not sure if setting the weight to 0 for that item would crash it or not, you could try it.
There isn't much I can do about it though.

commented

I was afraid of that. A weight of zero still has a pretty high drop rate so I'll just go back to what I had before, which was a single drop of tallgrass at weight 10000.

commented

Weight doesn't really matter with only one drop registered

commented

the odds of a drop being this one is the weigth of that drop divided by the total weight of all drops

commented

I think it's using 1 in n, rather than actual weighted, because having my tallgrass have a weight of 10000 should make it the most dropped item, not a super rare drop, and yet super-rare it is. My guess is that it does 1 in n for each item in the list, in order, until it gets one. It's really hard to say without seeing the code or doing way more testing than I care to do.

commented

I know that is how weighted drops work, which is why I'm telling you that that's not what the function is doing.

commented

Okay now you have me confused

commented

Okay, weighted drops 101: If drop A has a weight of 10 and drop B has a weight of 10, each one has a 50/50 chance of being dropped. If A has a weight of 10 and B has a wieght of 20, then you'll get A 1/3rd of the time, and B 2/3rds of the time. If there's only one item in the list, then it doesn't matter what the weight is, it should drop 100% of the time. So far I haven't said anything you don't already know. If I only have one item in the GrassDrops.txt file, and have the weight set to 0 (or 1), then it drops quite frequently. However, if I have the weight set to 10000, it drops quite rarely. The weight shouldn't matter, and yet it does. This is why I'm telling you that the minecraft WeightedRandom function doesn't work quite as we might expect.

commented

Okay now I'm following, I'll have a look at the code then