@@ -501,6 +501,7 @@ private void smoothingPass(int currentY,
501501 int sum = 0 ;
502502 int count = 0 ;
503503 int maxCardinalNeighborValue = 0 ;
504+ boolean hasEBlockNeighbor = false ;
504505
505506 // Only consider the 4 cardinal neighbors
506507 for (int [] offset : cardinalOffsets ) {
@@ -513,6 +514,7 @@ private void smoothingPass(int currentY,
513514 } else if (eBlocks .contains (neighbor )) {
514515 sum += 0 ;
515516 count ++;
517+ hasEBlockNeighbor = true ;
516518 } else if (layerValues .containsKey (neighbor )) {
517519 int neighborValue = layerValues .get (neighbor );
518520 sum += neighborValue ;
@@ -546,9 +548,23 @@ private void smoothingPass(int currentY,
546548 if (value < 1 ) value = 1 ; // safety clamp
547549 }
548550
549- // IMPORTANT: Only apply smoothing if it INCREASES the value (preserves extended gradients)
550- if (existingValue == null || value > existingValue ) {
551- newValues .put (lBlock , value );
551+ // Apply smoothing based on priority mode
552+ if (LayerConfig .SMOOTHING_PRIORITY == LayerConfig .SmoothingPriority .UP ) {
553+ // UP: Only apply smoothing if it INCREASES the value (preserves extended gradients)
554+ if (existingValue == null || value > existingValue ) {
555+ newValues .put (lBlock , value );
556+ }
557+ } else {
558+ // DOWN: Hybrid approach
559+ if (hasEBlockNeighbor ) {
560+ // Near edges: Traditional smoothing (always apply)
561+ newValues .put (lBlock , value );
562+ } else {
563+ // Away from edges: Preserve gradients (only apply if higher, like UP mode)
564+ if (existingValue == null || value > existingValue ) {
565+ newValues .put (lBlock , value );
566+ }
567+ }
552568 }
553569 }
554570 }
@@ -567,16 +583,12 @@ private void spreadLayersFromHBlocks(int currentY,
567583 Map <BlockPos , Integer > layerValues ,
568584 int maxDistance ) {
569585
570- // 8 directions: N, NE, E, SE, S, SW, W, NW
586+ // 4 directions: N, E, S, W
571587 int [][] directions = {
572588 {0 , -1 }, // N
573- {1 , -1 }, // NE (diagonal)
574589 {1 , 0 }, // E
575- {1 , 1 }, // SE (diagonal)
576590 {0 , 1 }, // S
577- {-1 , 1 }, // SW (diagonal)
578591 {-1 , 0 }, // W
579- {-1 , -1 } // NW (diagonal)
580592 };
581593
582594 // Track path length statistics
@@ -587,7 +599,6 @@ private void spreadLayersFromHBlocks(int currentY,
587599 for (BlockPos hBlock : hBlocks ) {
588600 for (int dirIdx = 0 ; dirIdx < directions .length ; dirIdx ++) {
589601 int [] dir = directions [dirIdx ];
590- boolean isDiagonal = (dir [0 ] != 0 && dir [1 ] != 0 );
591602
592603 // Walk in this direction and collect L blocks
593604 List <BlockPos > pathLBlocks = new ArrayList <>();
@@ -619,7 +630,7 @@ private void spreadLayersFromHBlocks(int currentY,
619630 int pathLength = pathLBlocks .size ();
620631 pathLengthCounts .put (pathLength , pathLengthCounts .getOrDefault (pathLength , 0 ) + 1 );
621632 pathsWithLayers ++;
622- applyGradient (pathLBlocks , isDiagonal , layerValues );
633+ applyGradient (pathLBlocks , layerValues );
623634 }
624635 }
625636 }
@@ -645,9 +656,9 @@ private String formatPathStats(Map<Integer, Integer> pathLengthCounts) {
645656 /**
646657 * Apply gradient to a path of L blocks
647658 */
648- private void applyGradient (List <BlockPos > path , boolean isDiagonal , Map <BlockPos , Integer > layerValues ) {
659+ private void applyGradient (List <BlockPos > path , Map <BlockPos , Integer > layerValues ) {
649660 int availableBlocks = path .size ();
650- int [] gradient = getGradientForSpace (availableBlocks , isDiagonal );
661+ int [] gradient = getGradient (availableBlocks );
651662
652663 for (int i = 0 ; i < path .size () && i < gradient .length ; i ++) {
653664 BlockPos pos = path .get (i );
@@ -661,28 +672,23 @@ private void applyGradient(List<BlockPos> path, boolean isDiagonal, Map<BlockPos
661672 }
662673 }
663674
664- /**
665- * Get gradient array for given available space
666- */
667- private int [] getGradientForSpace (int space , boolean isDiagonal ) {
668- if (isDiagonal ) {
669- return getDiagonalGradient (space );
670- } else {
671- return getNormalGradient (space );
672- }
673- }
674-
675- private int [] getNormalGradient (int space ) {
675+ private int [] getGradient (int space ) {
676676 // EXTREME mode: use extreme gradients with triple repeated values
677677 if (LayerConfig .MODE == LayerConfig .GenerationMode .EXTREME ) {
678678 return getExtremeNormalGradient (space );
679679 }
680-
681680 // EXTENDED mode: use extended gradients with repeated values
682681 if (LayerConfig .MODE == LayerConfig .GenerationMode .EXTENDED ) {
683682 return getExtendedNormalGradient (space );
684683 }
684+ // BASIC mode: linear gradients
685+ if (LayerConfig .MODE == LayerConfig .GenerationMode .BASIC ) {
686+ return getNormalGradient (space );
687+ }
688+ return new int [0 ];
689+ }
685690
691+ private int [] getNormalGradient (int space ) {
686692 // BASIC mode: linear gradients
687693 if (space >= 7 ) {
688694 return new int []{7 , 6 , 5 , 4 , 3 , 2 , 1 };
@@ -724,22 +730,9 @@ private int[] getExtendedNormalGradient(int space) {
724730 return new int []{7 , 6 , 5 , 4 , 4 , 3 , 2 , 1 };
725731 }
726732 // For space <= 7, fall back to basic gradients
727- else if (space >= 7 ) {
728- return new int []{7 , 6 , 5 , 4 , 3 , 2 , 1 };
729- } else if (space >= 6 ) {
730- return new int []{7 , 6 , 5 , 3 , 2 , 1 };
731- } else if (space >= 5 ) {
732- return new int []{6 , 5 , 4 , 2 , 1 };
733- } else if (space >= 4 ) {
734- return new int []{7 , 5 , 3 , 1 };
735- } else if (space >= 3 ) {
736- return new int []{6 , 4 , 2 };
737- } else if (space >= 2 ) {
738- return new int []{5 , 2 };
739- } else if (space >= 1 ) {
740- return new int []{4 };
733+ else {
734+ return getNormalGradient (space );
741735 }
742- return new int [0 ];
743736 }
744737
745738 /**
@@ -768,12 +761,6 @@ private int[] getExtremeNormalGradient(int space) {
768761 return getExtendedNormalGradient (space );
769762 }
770763 }
771-
772- private int [] getDiagonalGradient (int space ) {
773- // Diagonal gradients are currently disabled (return empty array)
774- // You can enable them if needed for more coverage
775- return new int [0 ];
776- }
777764
778765 /**
779766 * Place all layer blocks
@@ -1027,7 +1014,15 @@ private BlockPos findSurfaceBlock(BlockPos pos) {
10271014 surfacePos = surfacePos .down ();
10281015 continue ;
10291016 }
1030-
1017+
1018+ // Skip mushroom blocks (big mushroom structures)
1019+ if (block == Blocks .BROWN_MUSHROOM_BLOCK ||
1020+ block == Blocks .RED_MUSHROOM_BLOCK ||
1021+ block == Blocks .MUSHROOM_STEM ) {
1022+ surfacePos = surfacePos .down ();
1023+ continue ;
1024+ }
1025+
10311026 // Skip plants and flowers
10321027 if (block .getDefaultState ().isIn (net .minecraft .registry .tag .BlockTags .FLOWERS ) ||
10331028 block .getDefaultState ().isIn (net .minecraft .registry .tag .BlockTags .SAPLINGS ) ||
0 commit comments