Advertisement
jayhillx

MysticSurfaceRules (again)

Aug 25th, 2024
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.37 KB | None | 0 0
  1. package com.mysticsbiomes.common.world;
  2.  
  3. import com.google.common.collect.ImmutableList;
  4. import com.mysticsbiomes.init.MysticBiomes;
  5. import com.mysticsbiomes.init.MysticBlocks;
  6. import net.minecraft.world.level.biome.Biomes;
  7. import net.minecraft.world.level.block.Block;
  8. import net.minecraft.world.level.block.Blocks;
  9. import net.minecraft.world.level.levelgen.Noises;
  10. import net.minecraft.world.level.levelgen.SurfaceRules;
  11. import net.minecraft.world.level.levelgen.SurfaceRules.*;
  12. import net.minecraft.world.level.levelgen.VerticalAnchor;
  13.  
  14. public class MysticSurfaceRules {
  15.     private static final RuleSource AIR = makeStateRule(Blocks.AIR);
  16.     private static final RuleSource BEDROCK = makeStateRule(Blocks.BEDROCK);
  17.     private static final RuleSource WHITE_TERRACOTTA = makeStateRule(Blocks.WHITE_TERRACOTTA);
  18.     private static final RuleSource ORANGE_TERRACOTTA = makeStateRule(Blocks.ORANGE_TERRACOTTA);
  19.     private static final RuleSource TERRACOTTA = makeStateRule(Blocks.TERRACOTTA);
  20.     private static final RuleSource RED_SAND = makeStateRule(Blocks.RED_SAND);
  21.     private static final RuleSource RED_SANDSTONE = makeStateRule(Blocks.RED_SANDSTONE);
  22.     private static final RuleSource STONE = makeStateRule(Blocks.STONE);
  23.     private static final RuleSource DEEPSLATE = makeStateRule(Blocks.DEEPSLATE);
  24.     private static final RuleSource DIRT = makeStateRule(Blocks.DIRT);
  25.     private static final RuleSource PODZOL = makeStateRule(Blocks.PODZOL);
  26.     private static final RuleSource COARSE_DIRT = makeStateRule(Blocks.COARSE_DIRT);
  27.     private static final RuleSource MYCELIUM = makeStateRule(Blocks.MYCELIUM);
  28.     private static final RuleSource GRASS_BLOCK = makeStateRule(Blocks.GRASS_BLOCK);
  29.     private static final RuleSource CALCITE = makeStateRule(Blocks.CALCITE);
  30.     private static final RuleSource GRAVEL = makeStateRule(Blocks.GRAVEL);
  31.     private static final RuleSource SAND = makeStateRule(Blocks.SAND);
  32.     private static final RuleSource SANDSTONE = makeStateRule(Blocks.SANDSTONE);
  33.     private static final RuleSource PACKED_ICE = makeStateRule(Blocks.PACKED_ICE);
  34.     private static final RuleSource SNOW_BLOCK = makeStateRule(Blocks.SNOW_BLOCK);
  35.     private static final RuleSource POWDER_SNOW = makeStateRule(Blocks.POWDER_SNOW);
  36.     private static final RuleSource ICE = makeStateRule(Blocks.ICE);
  37.     private static final RuleSource WATER = makeStateRule(Blocks.WATER);
  38.  
  39.     private static final RuleSource GRASSY_LUSH_SAND = makeStateRule(MysticBlocks.GRASSY_LUSH_SAND.get());
  40.     private static final RuleSource LUSH_SAND = makeStateRule(MysticBlocks.LUSH_SAND.get());
  41.     private static final RuleSource LUSH_SANDSTONE = makeStateRule(MysticBlocks.LUSH_SANDSTONE.get());
  42.  
  43.     private static RuleSource makeStateRule(Block block) {
  44.         return SurfaceRules.state(block.defaultBlockState());
  45.     }
  46.  
  47.     public static RuleSource overworld() {
  48.         return overworldLike(true, false, true);
  49.     }
  50.  
  51.     public static SurfaceRules.RuleSource overworldLike(boolean surface, boolean nether, boolean overworld) {
  52.         ConditionSource above97 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(97), 2);
  53.         ConditionSource above256 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(256), 0);
  54.         ConditionSource above63_1 = SurfaceRules.yStartCheck(VerticalAnchor.absolute(63), -1);
  55.         ConditionSource above74 = SurfaceRules.yStartCheck(VerticalAnchor.absolute(74), 1);
  56.         ConditionSource above62 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(62), 0);
  57.         ConditionSource above63_0 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(63), 0);
  58.         ConditionSource isAtOrAboveWaterLevel = SurfaceRules.waterBlockCheck(-1, 0);
  59.         ConditionSource isAboveWaterLevel = SurfaceRules.waterBlockCheck(0, 0);
  60.         ConditionSource conditionSource8 = SurfaceRules.waterStartCheck(-6, -1);
  61.         ConditionSource isHole = SurfaceRules.hole();
  62.         ConditionSource isFrozenOcean = SurfaceRules.isBiome(Biomes.FROZEN_OCEAN, Biomes.DEEP_FROZEN_OCEAN);
  63.         ConditionSource isSteep = SurfaceRules.steep();
  64.         RuleSource grassSurface = SurfaceRules.sequence(SurfaceRules.ifTrue(isAtOrAboveWaterLevel, GRASS_BLOCK), DIRT);
  65.         RuleSource sandstoneLinedSand = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, SANDSTONE), SAND);
  66.         RuleSource stoneLinedGravel = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, STONE), GRAVEL);
  67.         ConditionSource isSandstoneLiningBiome = SurfaceRules.isBiome(Biomes.WARM_OCEAN, Biomes.DESERT, Biomes.BEACH, Biomes.SNOWY_BEACH, MysticBiomes.LAGOON);
  68.         RuleSource ruleSource3 = SurfaceRules.sequence(mysticRule(), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.STONY_PEAKS), SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.CALCITE, -0.0125D, 0.0125D), CALCITE), STONE)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.STONY_SHORE), SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.GRAVEL, -0.05D, 0.05D), stoneLinedGravel), STONE)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WINDSWEPT_HILLS), SurfaceRules.ifTrue(surfaceNoiseAbove(1.0D), STONE)), SurfaceRules.ifTrue(isSandstoneLiningBiome, sandstoneLinedSand), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.DRIPSTONE_CAVES), STONE));
  69.         RuleSource ruleSource4 = SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.POWDER_SNOW, 0.45D, 0.58D), POWDER_SNOW);
  70.         RuleSource ruleSource5 = SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.POWDER_SNOW, 0.35D, 0.6D), POWDER_SNOW);
  71.         RuleSource ruleSource6 = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.FROZEN_PEAKS), SurfaceRules.sequence(SurfaceRules.ifTrue(isSteep, PACKED_ICE), SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.PACKED_ICE, -0.5D, 0.2D), PACKED_ICE), SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.ICE, -0.0625D, 0.025D), ICE), SNOW_BLOCK)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.SNOWY_SLOPES), SurfaceRules.sequence(SurfaceRules.ifTrue(isSteep, STONE), ruleSource4, SNOW_BLOCK)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.JAGGED_PEAKS), STONE), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.GROVE), SurfaceRules.sequence(ruleSource4, DIRT)), ruleSource3, SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WINDSWEPT_SAVANNA), SurfaceRules.ifTrue(surfaceNoiseAbove(1.75D), STONE)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WINDSWEPT_GRAVELLY_HILLS), SurfaceRules.sequence(SurfaceRules.ifTrue(surfaceNoiseAbove(2.0D), stoneLinedGravel), SurfaceRules.ifTrue(surfaceNoiseAbove(1.0D), STONE), SurfaceRules.ifTrue(surfaceNoiseAbove(-1.0D), DIRT), stoneLinedGravel)), DIRT);
  72.         RuleSource atOrAboveWaterLevelRules = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.FROZEN_PEAKS), SurfaceRules.sequence(SurfaceRules.ifTrue(isSteep, PACKED_ICE), SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.PACKED_ICE, 0.0D, 0.2D), PACKED_ICE), SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.ICE, 0.0D, 0.025D), ICE), SNOW_BLOCK)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.SNOWY_SLOPES), SurfaceRules.sequence(SurfaceRules.ifTrue(isSteep, STONE), ruleSource5, SNOW_BLOCK)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.JAGGED_PEAKS), SurfaceRules.sequence(SurfaceRules.ifTrue(isSteep, STONE), SNOW_BLOCK)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.GROVE), SurfaceRules.sequence(ruleSource5, SNOW_BLOCK)), ruleSource3, SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WINDSWEPT_SAVANNA), SurfaceRules.sequence(SurfaceRules.ifTrue(surfaceNoiseAbove(1.75D), STONE), SurfaceRules.ifTrue(surfaceNoiseAbove(-0.5D), COARSE_DIRT))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WINDSWEPT_GRAVELLY_HILLS), SurfaceRules.sequence(SurfaceRules.ifTrue(surfaceNoiseAbove(2.0D), stoneLinedGravel), SurfaceRules.ifTrue(surfaceNoiseAbove(1.0D), STONE), SurfaceRules.ifTrue(surfaceNoiseAbove(-1.0D), grassSurface), stoneLinedGravel)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.OLD_GROWTH_PINE_TAIGA, Biomes.OLD_GROWTH_SPRUCE_TAIGA), SurfaceRules.sequence(SurfaceRules.ifTrue(surfaceNoiseAbove(1.75D), COARSE_DIRT), SurfaceRules.ifTrue(surfaceNoiseAbove(-0.95D), PODZOL))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.ICE_SPIKES), SNOW_BLOCK), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.MUSHROOM_FIELDS), MYCELIUM), grassSurface);
  73.         ConditionSource conditionSource13 = SurfaceRules.noiseCondition(Noises.SURFACE, -0.909D, -0.5454D);
  74.         ConditionSource conditionSource14 = SurfaceRules.noiseCondition(Noises.SURFACE, -0.1818D, 0.1818D);
  75.         ConditionSource conditionSource15 = SurfaceRules.noiseCondition(Noises.SURFACE, 0.5454D, 0.909D);
  76.         SurfaceRules.RuleSource isLushSandstone = SurfaceRules.sequence(LUSH_SANDSTONE);
  77.         RuleSource surfaceRules = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WOODED_BADLANDS), SurfaceRules.ifTrue(above97, SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource13, COARSE_DIRT), SurfaceRules.ifTrue(conditionSource14, COARSE_DIRT), SurfaceRules.ifTrue(conditionSource15, COARSE_DIRT), grassSurface))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.SWAMP), SurfaceRules.ifTrue(above62, SurfaceRules.ifTrue(SurfaceRules.not(above63_0), SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.SWAMP, 0.0D), WATER)))))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.BADLANDS, Biomes.ERODED_BADLANDS, Biomes.WOODED_BADLANDS), SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.sequence(SurfaceRules.ifTrue(above256, ORANGE_TERRACOTTA), SurfaceRules.ifTrue(above74, SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource13, TERRACOTTA), SurfaceRules.ifTrue(conditionSource14, TERRACOTTA), SurfaceRules.ifTrue(conditionSource15, TERRACOTTA), SurfaceRules.bandlands())), SurfaceRules.ifTrue(isAtOrAboveWaterLevel, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, RED_SANDSTONE), RED_SAND)), SurfaceRules.ifTrue(SurfaceRules.not(isHole), ORANGE_TERRACOTTA), SurfaceRules.ifTrue(conditionSource8, WHITE_TERRACOTTA), stoneLinedGravel)), SurfaceRules.ifTrue(above63_1, SurfaceRules.sequence(SurfaceRules.ifTrue(above63_0, SurfaceRules.ifTrue(SurfaceRules.not(above74), ORANGE_TERRACOTTA)), SurfaceRules.bandlands())), SurfaceRules.ifTrue(SurfaceRules.UNDER_FLOOR, SurfaceRules.ifTrue(conditionSource8, WHITE_TERRACOTTA)))), SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.ifTrue(isAtOrAboveWaterLevel, SurfaceRules.sequence(SurfaceRules.ifTrue(isFrozenOcean, SurfaceRules.ifTrue(isHole, SurfaceRules.sequence(SurfaceRules.ifTrue(isAboveWaterLevel, AIR), SurfaceRules.ifTrue(SurfaceRules.temperature(), ICE), WATER))), atOrAboveWaterLevelRules))), SurfaceRules.ifTrue(conditionSource8, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.ifTrue(isFrozenOcean, SurfaceRules.ifTrue(isHole, WATER))), SurfaceRules.ifTrue(SurfaceRules.UNDER_FLOOR, ruleSource6), SurfaceRules.ifTrue(isSandstoneLiningBiome, SurfaceRules.ifTrue(SurfaceRules.DEEP_UNDER_FLOOR, SANDSTONE)), SurfaceRules.ifTrue(SurfaceRules.isBiome(MysticBiomes.LUSH_OASIS), SurfaceRules.ifTrue(SurfaceRules.DEEP_UNDER_FLOOR, isLushSandstone)))), SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.FROZEN_PEAKS, Biomes.JAGGED_PEAKS), STONE), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WARM_OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN), sandstoneLinedSand), stoneLinedGravel)));
  78.  
  79.         ImmutableList.Builder<RuleSource> bedrockBuilder = ImmutableList.builder();
  80.         if (nether) {
  81.             bedrockBuilder.add(SurfaceRules.ifTrue(SurfaceRules.not(SurfaceRules.verticalGradient("bedrock_roof", VerticalAnchor.belowTop(5), VerticalAnchor.top())), BEDROCK));
  82.         }
  83.         if (overworld) {
  84.             bedrockBuilder.add(SurfaceRules.ifTrue(SurfaceRules.verticalGradient("bedrock_floor", VerticalAnchor.bottom(), VerticalAnchor.aboveBottom(5)), BEDROCK));
  85.         }
  86.         RuleSource ruleSource9 = SurfaceRules.ifTrue(SurfaceRules.abovePreliminarySurface(), surfaceRules);
  87.         bedrockBuilder.add(surface ? ruleSource9 : surfaceRules);
  88.         bedrockBuilder.add(SurfaceRules.ifTrue(SurfaceRules.verticalGradient("deepslate", VerticalAnchor.absolute(0), VerticalAnchor.absolute(8)), DEEPSLATE));
  89.         return SurfaceRules.sequence(bedrockBuilder.build().toArray(RuleSource[]::new));
  90.     }
  91.  
  92.     private static SurfaceRules.RuleSource mysticRule() {
  93.         ConditionSource isAtOrAboveWaterLevel = SurfaceRules.waterBlockCheck(-1, 0);
  94.         RuleSource lushSand = SurfaceRules.sequence(SurfaceRules.ifTrue(isAtOrAboveWaterLevel, LUSH_SAND), LUSH_SAND);
  95.         RuleSource grassyLush = SurfaceRules.sequence(SurfaceRules.ifTrue(isAtOrAboveWaterLevel, GRASSY_LUSH_SAND), LUSH_SAND);
  96.  
  97.         RuleSource lushOasisSurface = SurfaceRules.sequence(SurfaceRules.sequence(SurfaceRules.ifTrue(surfaceNoiseAbove(-0.6D), lushSand), grassyLush));
  98.         RuleSource lagoonSurface = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, SANDSTONE), SAND);
  99.         return SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(MysticBiomes.LUSH_OASIS), lushOasisSurface), SurfaceRules.ifTrue(SurfaceRules.isBiome(MysticBiomes.LAGOON), lagoonSurface));
  100.     }
  101.  
  102.     private static SurfaceRules.ConditionSource surfaceNoiseAbove(double value) {
  103.         return SurfaceRules.noiseCondition(Noises.SURFACE, value / 8.25D, Double.MAX_VALUE);
  104.     }
  105.    
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement