Advertisement
jayhillx

MysticSurfaceRules

Aug 26th, 2022
1,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.27 KB | None | 0 0
  1. package com.mysticsbiomes.common.world;
  2.  
  3. import com.google.common.collect.ImmutableList;
  4. import com.mysticsbiomes.core.init.MysticBiomes;
  5. import com.google.common.collect.ImmutableList.Builder;
  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 SurfaceRules.RuleSource AIR = makeStateRule(Blocks.AIR);
  16.     private static final SurfaceRules.RuleSource BEDROCK = makeStateRule(Blocks.BEDROCK);
  17.     private static final SurfaceRules.RuleSource WHITE_TERRACOTTA = makeStateRule(Blocks.WHITE_TERRACOTTA);
  18.     private static final SurfaceRules.RuleSource ORANGE_TERRACOTTA = makeStateRule(Blocks.ORANGE_TERRACOTTA);
  19.     private static final SurfaceRules.RuleSource TERRACOTTA = makeStateRule(Blocks.TERRACOTTA);
  20.     private static final SurfaceRules.RuleSource RED_SAND = makeStateRule(Blocks.RED_SAND);
  21.     private static final SurfaceRules.RuleSource RED_SANDSTONE = makeStateRule(Blocks.RED_SANDSTONE);
  22.     private static final SurfaceRules.RuleSource STONE = makeStateRule(Blocks.STONE);
  23.     private static final SurfaceRules.RuleSource DEEPSLATE = makeStateRule(Blocks.DEEPSLATE);
  24.     private static final SurfaceRules.RuleSource DIRT = makeStateRule(Blocks.DIRT);
  25.     private static final SurfaceRules.RuleSource PODZOL = makeStateRule(Blocks.PODZOL);
  26.     private static final SurfaceRules.RuleSource COARSE_DIRT = makeStateRule(Blocks.COARSE_DIRT);
  27.     private static final SurfaceRules.RuleSource MYCELIUM = makeStateRule(Blocks.MYCELIUM);
  28.     private static final SurfaceRules.RuleSource GRASS_BLOCK = makeStateRule(Blocks.GRASS_BLOCK);
  29.     private static final SurfaceRules.RuleSource CALCITE = makeStateRule(Blocks.CALCITE);
  30.     private static final SurfaceRules.RuleSource GRAVEL = makeStateRule(Blocks.GRAVEL);
  31.     private static final SurfaceRules.RuleSource SAND = makeStateRule(Blocks.SAND);
  32.     private static final SurfaceRules.RuleSource SANDSTONE = makeStateRule(Blocks.SANDSTONE);
  33.     private static final SurfaceRules.RuleSource PACKED_ICE = makeStateRule(Blocks.PACKED_ICE);
  34.     private static final SurfaceRules.RuleSource SNOW_BLOCK = makeStateRule(Blocks.SNOW_BLOCK);
  35.     private static final SurfaceRules.RuleSource POWDER_SNOW = makeStateRule(Blocks.POWDER_SNOW);
  36.     private static final SurfaceRules.RuleSource ICE = makeStateRule(Blocks.ICE);
  37.     private static final SurfaceRules.RuleSource WATER = makeStateRule(Blocks.WATER);
  38.  
  39.     private static RuleSource makeStateRule(Block block) {
  40.         return SurfaceRules.state(block.defaultBlockState());
  41.     }
  42.  
  43.     public static RuleSource overworld() {
  44.         return overworldLike(true, false, true);
  45.     }
  46.  
  47.     public static RuleSource overworldLike(boolean p_198381_, boolean nether, boolean overworld) {
  48.         ConditionSource conditionSource = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(97), 2);
  49.         ConditionSource conditionSource1 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(256), 0);
  50.         ConditionSource conditionSource2 = SurfaceRules.yStartCheck(VerticalAnchor.absolute(63), -1);
  51.         ConditionSource conditionSource3 = SurfaceRules.yStartCheck(VerticalAnchor.absolute(74), 1);
  52.         ConditionSource conditionSource4 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(62), 0);
  53.         ConditionSource conditionSource5 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(63), 0);
  54.         ConditionSource conditionSource6 = SurfaceRules.waterBlockCheck(-1, 0);
  55.         ConditionSource conditionSource7 = SurfaceRules.waterBlockCheck(0, 0);
  56.         ConditionSource conditionSource8 = SurfaceRules.waterStartCheck(-6, -1);
  57.         ConditionSource conditionSource9 = SurfaceRules.hole();
  58.         ConditionSource conditionSource10 = SurfaceRules.isBiome(Biomes.FROZEN_OCEAN, Biomes.DEEP_FROZEN_OCEAN);
  59.         ConditionSource conditionSource11 = SurfaceRules.steep();
  60.         RuleSource ruleSource = SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource7, GRASS_BLOCK), DIRT);
  61.         RuleSource ruleSource1 = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, SANDSTONE), SAND);
  62.         RuleSource ruleSource2 = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, STONE), GRAVEL);
  63.         ConditionSource conditionSource12 = SurfaceRules.isBiome(Biomes.WARM_OCEAN, Biomes.BEACH, Biomes.SNOWY_BEACH);
  64.         ConditionSource conditionSource13 = SurfaceRules.isBiome(Biomes.DESERT);
  65.         RuleSource ruleSource3 = SurfaceRules.sequence(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), ruleSource2), STONE)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WINDSWEPT_HILLS), SurfaceRules.ifTrue(surfaceNoiseAbove(1.0D), STONE)), SurfaceRules.ifTrue(conditionSource12, ruleSource1), SurfaceRules.ifTrue(conditionSource13, ruleSource1), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.DRIPSTONE_CAVES), STONE));
  66.         RuleSource ruleSource4 = SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.POWDER_SNOW, 0.45D, 0.58D), SurfaceRules.ifTrue(conditionSource7, POWDER_SNOW));
  67.         RuleSource ruleSource5 = SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.POWDER_SNOW, 0.35D, 0.6D), SurfaceRules.ifTrue(conditionSource7, POWDER_SNOW));
  68.         RuleSource ruleSource6 = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.FROZEN_PEAKS), SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource11, 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), SurfaceRules.ifTrue(conditionSource7, SNOW_BLOCK))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.SNOWY_SLOPES), SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource11, STONE), ruleSource4, SurfaceRules.ifTrue(conditionSource7, 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), ruleSource2), SurfaceRules.ifTrue(surfaceNoiseAbove(1.0D), STONE), SurfaceRules.ifTrue(surfaceNoiseAbove(-1.0D), DIRT), ruleSource2)), DIRT);
  69.         RuleSource ruleSource7 = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.FROZEN_PEAKS), SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource11, 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), SurfaceRules.ifTrue(conditionSource7, SNOW_BLOCK))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.SNOWY_SLOPES), SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource11, STONE), ruleSource5, SurfaceRules.ifTrue(conditionSource7, SNOW_BLOCK))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.JAGGED_PEAKS), SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource11, STONE), SurfaceRules.ifTrue(conditionSource7, SNOW_BLOCK))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.GROVE), SurfaceRules.sequence(ruleSource5, SurfaceRules.ifTrue(conditionSource7, 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), ruleSource2), SurfaceRules.ifTrue(surfaceNoiseAbove(1.0D), STONE), SurfaceRules.ifTrue(surfaceNoiseAbove(-1.0D), ruleSource), ruleSource2)), 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), SurfaceRules.ifTrue(conditionSource7, SNOW_BLOCK)), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.MUSHROOM_FIELDS), MYCELIUM), ruleSource);
  70.         ConditionSource conditionSource14 = SurfaceRules.noiseCondition(Noises.SURFACE, -0.909D, -0.5454D);
  71.         ConditionSource conditionSource15 = SurfaceRules.noiseCondition(Noises.SURFACE, -0.1818D, 0.1818D);
  72.         ConditionSource conditionSource16 = SurfaceRules.noiseCondition(Noises.SURFACE, 0.5454D, 0.909D);
  73.  
  74.         RuleSource ruleSource8 = SurfaceRules.sequence(mysticRule(), SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.WOODED_BADLANDS), SurfaceRules.ifTrue(conditionSource, SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource14, COARSE_DIRT), SurfaceRules.ifTrue(conditionSource15, COARSE_DIRT), SurfaceRules.ifTrue(conditionSource16, COARSE_DIRT), ruleSource))), SurfaceRules.ifTrue(SurfaceRules.isBiome(Biomes.SWAMP), SurfaceRules.ifTrue(conditionSource4, SurfaceRules.ifTrue(SurfaceRules.not(conditionSource5), 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(conditionSource1, ORANGE_TERRACOTTA), SurfaceRules.ifTrue(conditionSource3, SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource14, TERRACOTTA), SurfaceRules.ifTrue(conditionSource15, TERRACOTTA), SurfaceRules.ifTrue(conditionSource16, TERRACOTTA), SurfaceRules.bandlands())), SurfaceRules.ifTrue(conditionSource6, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, RED_SANDSTONE), RED_SAND)), SurfaceRules.ifTrue(SurfaceRules.not(conditionSource9), ORANGE_TERRACOTTA), SurfaceRules.ifTrue(conditionSource8, WHITE_TERRACOTTA), ruleSource2)), SurfaceRules.ifTrue(conditionSource2, SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource5, SurfaceRules.ifTrue(SurfaceRules.not(conditionSource3), ORANGE_TERRACOTTA)), SurfaceRules.bandlands())), SurfaceRules.ifTrue(SurfaceRules.UNDER_FLOOR, SurfaceRules.ifTrue(conditionSource8, WHITE_TERRACOTTA)))), SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.ifTrue(conditionSource6, SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource10, SurfaceRules.ifTrue(conditionSource9, SurfaceRules.sequence(SurfaceRules.ifTrue(conditionSource7, AIR), SurfaceRules.ifTrue(SurfaceRules.temperature(), ICE), WATER))), ruleSource7))), SurfaceRules.ifTrue(conditionSource8, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.ifTrue(conditionSource10, SurfaceRules.ifTrue(conditionSource9, WATER))), SurfaceRules.ifTrue(SurfaceRules.UNDER_FLOOR, ruleSource6), SurfaceRules.ifTrue(conditionSource12, SurfaceRules.ifTrue(SurfaceRules.DEEP_UNDER_FLOOR, SANDSTONE)), SurfaceRules.ifTrue(conditionSource13, SurfaceRules.ifTrue(SurfaceRules.VERY_DEEP_UNDER_FLOOR, SANDSTONE)))), 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), ruleSource1), ruleSource2)));
  75.         RuleSource ruleSource9 = SurfaceRules.ifTrue(SurfaceRules.abovePreliminarySurface(), ruleSource8);
  76.  
  77.         Builder<RuleSource> builder = ImmutableList.builder();
  78.         if (nether) {
  79.             builder.add(SurfaceRules.ifTrue(SurfaceRules.not(SurfaceRules.verticalGradient("bedrock_roof", VerticalAnchor.belowTop(5), VerticalAnchor.top())), BEDROCK));
  80.         }
  81.         if (overworld) {
  82.             builder.add(SurfaceRules.ifTrue(SurfaceRules.verticalGradient("bedrock_floor", VerticalAnchor.bottom(), VerticalAnchor.aboveBottom(5)), BEDROCK));
  83.         }
  84.         builder.add(p_198381_ ? ruleSource9 : ruleSource8);
  85.         builder.add(SurfaceRules.ifTrue(SurfaceRules.verticalGradient("deepslate", VerticalAnchor.absolute(0), VerticalAnchor.absolute(8)), DEEPSLATE));
  86.         return SurfaceRules.sequence(builder.build().toArray(RuleSource[]::new));
  87.     }
  88.  
  89.     private static SurfaceRules.RuleSource mysticRule() {
  90.         SurfaceRules.RuleSource bambooBlossomSurface = SurfaceRules.sequence(SurfaceRules.ifTrue(surfaceNoiseAbove(1.75D), PODZOL), SurfaceRules.ifTrue(surfaceNoiseAbove(-0.95D), GRASS_BLOCK));
  91.  
  92.         return SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(MysticBiomes.BAMBOO_BLOSSOM_FOREST.getKey()), bambooBlossomSurface));
  93.     }
  94.  
  95.     private static SurfaceRules.ConditionSource surfaceNoiseAbove(double value) {
  96.         return SurfaceRules.noiseCondition(Noises.SURFACE, value / 8.25D, Double.MAX_VALUE);
  97.     }
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement