Natura

Natura

55M Downloads

Server Crash Bug

ph1x3r opened this issue ยท 0 comments

commented

There appears to be an oversight in the NLeavesNoColor module that causes a fatal server crash.

In the following function:
@OverRide
public ArrayList getBlockDropped (World world, int x, int y, int z, int metadata, int fortune)
{
ArrayList ret = super.getBlockDropped(world, x, y, z, metadata, fortune);
if (metadata % 4 == 2 && Natura.random.nextInt(40 - fortune*10) == 0)
ret.add(new ItemStack(Item.redstone));
return ret;
}

The calculation is using (40 - fortune * 10). If someone uses a FortuneV enchanted item on a Natura tree, then the server crashes with the following:

java.lang.IllegalArgumentException: n must be positive
at java.util.Random.nextInt(Random.java:300)
at mods.natura.blocks.trees.NLeavesNocolor.getBlockDropped(NLeavesNocolo
r.java:110)
at org.yogpstop.qp.TileBasic.S_addDroppedItems(TileBasic.java:214)

To my view, (40 - (10*5)) = -10

This has happened with held items and also with the QuarryPlus mod. In all cases, this has happened in the nether.

Update: Re-tested with Minecraft shears and various levels of enchantment. If fortune is lvl 3 or less, then things work. If fortune is 4 or 5 then the crash happens.