In TraitBrittle.class,
The crash is happening because of this line:
IntegerdamageDone = random.nextInt(Math.min(5, durability - 1));
The problem:
When durability = 1:
durability - 1 = 0Math.min(5, 0) = 0random.nextInt(0) -> IllegalArgumentException: bound must be positive
Random.nextInt(n) requires n > 0. You can't call nextInt(0).
fix:
publicvoidbeforeBlockBreak(@NonnullItemStacktool, @NonnullBreakEventevent) {
Blockblock = event.getState().func_177230_c();
if (block.func_176223_P().func_185904_a() == Material.field_151576_e) {
Integerdurability = ToolHelper.getCurrentDurability(tool);
if (durability > 1) { // Add this checkIntegerdamageDone = random.nextInt(Math.min(5, durability - 1));
ToolHelper.damageTool(tool, damageDone, event.getPlayer());
}
}
}or you can just do
IntegermaxDamage = Math.max(1, Math.min(5, durability - 1)); // Ensure at least 1IntegerdamageDone = random.nextInt(maxDamage);
Found this while working on my modpack, thought I should report it.
In TraitBrittle.class,
The crash is happening because of this line:
The problem:
When
durability = 1:durability - 1 = 0Math.min(5, 0) = 0random.nextInt(0)-> IllegalArgumentException: bound must be positiveRandom.nextInt(n)requiresn > 0. You can't callnextInt(0).fix:
or you can just do
Found this while working on my modpack, thought I should report it.