Team-RTG / Realistic-Terrain-Generation

The Realistic Terrain Generation mod for Minecraft.
GNU General Public License v3.0
245 stars 117 forks source link

IllegalArgumentException in DecoFallenTree #1316

Closed Tommsy64 closed 5 years ago

Tommsy64 commented 5 years ago
Affected Mod Versions:

Crash report

Affected method:

    public boolean isValidLogCondition(float strength, Random rand) {
        switch (this.logCondition) {
            case ALWAYS_GENERATE:
                return true;
            case RANDOM_CHANCE:
                return (rand.nextInt(this.logConditionChance) == 0);
            case X_DIVIDED_BY_STRENGTH:
                return (rand.nextInt((int) (this.logConditionNoise / strength)) == 0);
            default:
                return false;
        }
    }

Seems like either logConditionChance is 0 or logConditionNoise is 0 or strength >> logConditionNoise.

The only two Biomes I see that use X_DIVIDED_BY_STRENGTH are RealisticBiomeBOPGrove and RealisticBiomeBOPMapleWoods.

Commit 1496705 removed the lines .setLogConditionNoise(8f); statements from these two Biomes while keeping the logCondition as X_DIVIDED_BY_STRENGTH. Therefore, the IllegalArgumentException is probably caused by the 0 valued logConditionNoise.

Right now, the private field logConditionNoise has its only reference in #isValidLogCondition(float, rand) and in its getter. The getter has no reference, and the field has no setter.

Proposed Solutions

  1. Add back the setter for logConditionNoise and set it to 8f and add check to make sure logConditionNoise is not 0 before using it in rand.nextInt(). OR
  2. Completely remove logConditionNoise and X_DIVIDED_BY_STRENGTH
whichonespink44 commented 5 years ago

Thanks for submitting the bug report - this has already been squashed in a local dev branch and will be pushed soon.

If you're interested in being a beta tester, consider joining our Discord server and letting us know. We're about to release a proper build for testing.

whichonespink44 commented 5 years ago

Fixed in af2f20c