Regions Unexplored (forge/fabric)

Regions Unexplored (forge/fabric)

18M Downloads

Bug Report: Non-deterministic feature generation

davenonymous opened this issue ยท 0 comments

commented

Describe the bug
Some features use a custom random source additionally to the one provided by the place feature call.
With this you still get random trees when placing the feature with a fixed random seed.

Why does this matter? I'm currently working on the next version of Bonsai Trees with better support for auto-generating tree models. I basically run the gametest server to generate all trees for all installed mods. One important part of this is that the generated trees/features are deterministic - otherwise they would look different with every build, trigger resource pack rebuilds and be resistent to fixing their model with a specific random seed.

Screenshots / Affected trees

(there may be more randomly choosing the same condition branches each time)

On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/ashen_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/big_blackwood_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/blue_magnolia_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/brim_willow_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/enchanted_birch_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/giant_blue_bioshroom.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/giant_green_bioshroom.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/giant_yellow_bioshroom.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/larch_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/magnolia_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/maple_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/orange_maple_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/pink_magnolia_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/red_maple_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/silver_birch_tree.json
        modified:   assets/bonsaitrees4/models/multiblock/regions_unexplored/white_magnolia_tree.json

Code snippet
For example in

public boolean placeRandomChanceLeaves(LevelAccessor level, BlockPos pos, RandomSource randomSource, RuTreeConfiguration treeConfiguration) {
Random random = new Random();
if(random.nextInt(3)==0){
placeLeavesBlock(level,pos,randomSource,treeConfiguration);
}
return true;
}

This could simply use the already existing randomSource for the decision whether to place additional leaves.

How To Reproduce
Since the place command does not support placing features with a fixed seed this is currently only possible with custom code.

Repeatedly place the feature from code with a fixed RandomSource and get different trees each time, e.g.

BlockPos placePosition; // should be a position where the feature can grow
WorldgenRandom worldgenrandom = new WorldgenRandom(new LegacyRandomSource(1234));
feature.place(level, level.getChunkSource().getGenerator(), worldgenrandom, placePosition);