Fix wild crops never generating when lighting is deferred - #747
Open
andystaples wants to merge 1 commit into
Open
Fix wild crops never generating when lighting is deferred#747andystaples wants to merge 1 commit into
andystaples wants to merge 1 commit into
Conversation
CroptopiaCropBlock.canSurvive delegated to CropBlock.canSurvive on the worldgen path, which requires hasSufficientLight. Feature placement runs at the `features` chunk status, before `initialize_light` and `light`, so the value a light lookup returns there depends on the light engine rather than on the world. Under engines that report 0, SimpleBlockFeature's canSurvive gate rejects every placement and no wild crop ever generates. Check mayPlaceOn directly on the worldgen path instead. Player placement is untouched and keeps the vanilla light requirement. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
hey thanks for taking a look at this, i'll give it a test and see when i can implement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the long-standing "trees generate but crops don't" reports: #737, #689, #590.
Tested on MC 26.1.2 / NeoForge, Croptopia 4.3.1, with Terralith + Biomes O' Plenty + ScalableLux.
The bug
CroptopiaCropBlock.canSurvivedelegates toCropBlock.canSurviveon the worldgen path.CropBlock.canSurviverequireshasSufficientLight, i.e.getRawBrightness(pos, 0) >= 8.Feature placement runs at the
featureschunk status. The status order is:featuresruns beforeinitialize_lightandlight, so nothing has computed lighting yet when a crop is placed. What a light lookup returns at that point is up to the light engine implementation, not the world.SimpleBlockFeature.placegates entirely onstate.canSurvive(level, pos), so when the engine reports 0 the gate rejects every placement and no wild crop ever generates.This explains the pieces of the reports that never lined up:
croptopia:*_treeplacements use awould_survivepredicate againstminecraft:oak_saplingandTreeFeature, neither of which goes throughCropBlock.canSurvive.CropBlock.canSurvivefirst callscanSustainPlanton the block below and returns immediately if the result is non-default. Farmland short-circuits there, before the light check is ever reached. Structure-placed crops on farmland were the only Croptopia crops in my world.The fix
Check
mayPlaceOndirectly on the worldgen path. It is the same soil testVegetationBlock.canSurviveperforms, minus the light requirement, andCroptopiaCropBlockalready overrides it to accept dirt/grass/sand/farmland. The player-placement branch is untouched and keeps vanilla light behaviour, so planting rules are unchanged.Confirmed in the compiled artifact, not just the source: the current class calls
CropBlock.canSurvivetwice (both branches); the patched class calls it once, only in the player-placement branch.Before / after
Same world, same seed, same modlist. I scanned the region files directly, then purged and regenerated chunks with MCA Selector on the patched build.
Before, across 26,970 generated chunks — of which 19,922 (73.9%) were in a
has_crop-tagged biome, including 7,651 chunks of vanillaplains, 880jungle, 582bamboo_jungle, 446desert, 1,780 BOPwoodlandand 3,394 BOPscrubland— there was not a single crop on a natural block. The only 128 crop blocks in the entire world sat onminecraft:farmlandin one CTOV village farm plot. Meanwhile 31,064 cinnamon leaves and 23,694 salt ore had generated normally.After regeneration, ground beneath the 11,874 wild crops: 11,669
grass_block, 125sand, 36podzol, 29coarse_dirt, 6dirt. Biome spread: BOPscrubland5,941, BOPwoodland3,353, Terralithbrushland859,sparse_jungle737, BOPmediterranean_forest436, Terralithrocky_jungle293, plus savanna/jungle/forest tails.Notes
minecraft:disk→DiskFeature, which never callscanSurvive, so it was never exposed to this gate. Salt generated normally throughout my testing (23,694 blocks, 99.4% in y48–63) with ScalableLux installed. Whatever that reporter hit on 4.1.0 / 1.21.1 is a separate matter.v4-26.2carries the identical method and should need the same one-line change.:fabric— all three modules depend oncom.epherical.epherolib:*:1.3.0,buildSrcdeclares only mavenCentral/Sponge/BlameJared, andmaven.epherical.comreturned HTTP 522 on every attempt. I worked around it locally for:neoforgewith the EpheroLib jar from my mods folder. Not part of this PR, but you may want the repository declaration back inbuildSrc.Root-cause analysis and patch drafted with Claude Opus 5 (Claude Code), then hand-reviewed by me and verified in-game on a purged-and-regenerated world before submitting. Bytecode claims, chunk-status ordering and the before/after counts were checked against the 26.1.2 artifacts and my own save files rather than taken on trust.
🤖 Generated with Claude Code