@@ -84,6 +84,21 @@ protected void generateTrees(LevelContext levelContext, BiomeDatabase biomeDatab
8484 }
8585 }
8686
87+ private BlockPos OffsetPosIfOnFoliage (LevelAccessor level , BlockPos groundPos ){
88+ if (isNonReplaceableFoliage (level , groundPos )){
89+ if (isNonReplaceableFoliage (level , groundPos .below ())){
90+ return groundPos .below (2 );
91+ }
92+ return groundPos .below ();
93+ }
94+ return groundPos ;
95+ }
96+
97+ private boolean isNonReplaceableFoliage (LevelAccessor pLevel , BlockPos pPos ){
98+ BlockState state = pLevel .getBlockState (pPos );
99+ return !state .isAir () && validTreePos (pLevel , pPos );
100+ }
101+
87102 public static boolean validTreePos (LevelSimulatedReader pLevel , BlockPos pPos ) {
88103 return pLevel .isStateAtPosition (pPos , (state ) ->
89104 state .isAir () || state .is (BlockTags .REPLACEABLE_BY_TREES ) || state .is (DTBlockTags .FOLIAGE ));
@@ -94,6 +109,8 @@ protected GeneratorResult generateTree(LevelContext levelContext, BiomeDatabase.
94109 return GeneratorResult .NO_GROUND ;
95110 }
96111
112+ groundPos = OffsetPosIfOnFoliage (levelContext .accessor (), groundPos );;
113+
97114 // If there is already a rooty block, a cave rooted tree has taken this disc, so ignore
98115 if (levelContext .accessor ().getBlockState (groundPos ).getBlock () instanceof RootyBlock ) {
99116 return GeneratorResult .ALREADY_GENERATED ;
0 commit comments