Skip to content

Add weighted multi-material mixing for log/leaf replacement#43

Merged
tastybento merged 2 commits intodevelopfrom
copilot/add-material-mixing-for-logs-leaves
Apr 13, 2026
Merged

Add weighted multi-material mixing for log/leaf replacement#43
tastybento merged 2 commits intodevelopfrom
copilot/add-material-mixing-for-logs-leaves

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Adds support for mixing multiple replacement materials with configurable percentage weights when trees grow in Nether/End dimensions. Each material slot (global, per-tree, per-gamemode) now accepts a material: weight map instead of a single string.

Config format change

nether:
  logs:
    gravel: 80        # 80% gravel
    netherrack: 20    # 20% netherrack
  leaves:
    glowstone: 70
    soul_sand: 30

  per-tree:
    logs:
      oak:
        gravel: 60
        netherrack: 40

Weight semantics

  • = 100% — each material at exact stated probability
  • > 100% — weights scaled proportionally, no AIR injected; warning logged on load
  • < 100% — remainder maps to AIR; warning logged on load

Implementation

  • MaterialWeightedPicker (new) — stateless utility; pickRandom(Map<String,Integer>) handles all three cases above
  • Settings — global fields StringMap<String,Integer>; per-tree/per-gamemode Map<String,String>Map<String,Map<String,Integer>>
  • TreeGrowEventresolveMaterial() replaced by resolveWeights() returning a weight map; applyWeightedMaterial() picks per-block via the picker
  • DimensionalTrees.loadSettings() — validates all weight maps on load, emitting warnings for totals ≠ 100%

Breaking config change: existing single-string values (logs: gravel) must be migrated to the map form (logs: {gravel: 100}).

- Add MaterialWeightedPicker utility for weighted random material selection
- Update Settings to use Map<String,Integer> for material fields (weight maps)
- Update TreeGrowEvent to use weighted picker per-block
- Add load-time validation warnings for weight maps != 100%
- Update config.yml to new weighted YAML format
- Update and add tests (52 total, all passing)

Agent-Logs-Url: https://github.com/BentoBoxWorld/DimensionalTrees/sessions/b97d7b1d-0ada-40f7-b764-6febf71e1896

Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for mixing multiple material types for logs and leaves Add weighted multi-material mixing for log/leaf replacement Apr 13, 2026
Copilot AI requested a review from tastybento April 13, 2026 05:47
@tastybento tastybento marked this pull request as ready for review April 13, 2026 05:53
@tastybento tastybento merged commit 522934a into develop Apr 13, 2026
@tastybento tastybento deleted the copilot/add-material-mixing-for-logs-leaves branch April 13, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More material types to replace Logs and Leaves

2 participants