Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mysticsbiomes.common.world;
- import com.google.common.collect.ImmutableList;
- import com.mysticsbiomes.init.MysticBiomes;
- import com.mysticsbiomes.init.MysticBlocks;
- import net.minecraft.world.level.biome.Biomes;
- import net.minecraft.world.level.block.Block;
- import net.minecraft.world.level.block.Blocks;
- import net.minecraft.world.level.levelgen.Noises;
- import net.minecraft.world.level.levelgen.SurfaceRules;
- import net.minecraft.world.level.levelgen.SurfaceRules.*;
- import net.minecraft.world.level.levelgen.VerticalAnchor;
- public class MysticSurfaceRules {
- private static final RuleSource AIR = makeStateRule(Blocks.AIR);
- private static final RuleSource BEDROCK = makeStateRule(Blocks.BEDROCK);
- private static final RuleSource WHITE_TERRACOTTA = makeStateRule(Blocks.WHITE_TERRACOTTA);
- private static final RuleSource ORANGE_TERRACOTTA = makeStateRule(Blocks.ORANGE_TERRACOTTA);
- private static final RuleSource TERRACOTTA = makeStateRule(Blocks.TERRACOTTA);
- private static final RuleSource RED_SAND = makeStateRule(Blocks.RED_SAND);
- private static final RuleSource RED_SANDSTONE = makeStateRule(Blocks.RED_SANDSTONE);
- private static final RuleSource STONE = makeStateRule(Blocks.STONE);
- private static final RuleSource DEEPSLATE = makeStateRule(Blocks.DEEPSLATE);
- private static final RuleSource DIRT = makeStateRule(Blocks.DIRT);
- private static final RuleSource PODZOL = makeStateRule(Blocks.PODZOL);
- private static final RuleSource COARSE_DIRT = makeStateRule(Blocks.COARSE_DIRT);
- private static final RuleSource MYCELIUM = makeStateRule(Blocks.MYCELIUM);
- private static final RuleSource GRASS_BLOCK = makeStateRule(Blocks.GRASS_BLOCK);
- private static final RuleSource CALCITE = makeStateRule(Blocks.CALCITE);
- private static final RuleSource GRAVEL = makeStateRule(Blocks.GRAVEL);
- private static final RuleSource SAND = makeStateRule(Blocks.SAND);
- private static final RuleSource SANDSTONE = makeStateRule(Blocks.SANDSTONE);
- private static final RuleSource PACKED_ICE = makeStateRule(Blocks.PACKED_ICE);
- private static final RuleSource SNOW_BLOCK = makeStateRule(Blocks.SNOW_BLOCK);
- private static final RuleSource POWDER_SNOW = makeStateRule(Blocks.POWDER_SNOW);
- private static final RuleSource ICE = makeStateRule(Blocks.ICE);
- private static final RuleSource WATER = makeStateRule(Blocks.WATER);
- private static final RuleSource GRASSY_LUSH_SAND = makeStateRule(MysticBlocks.GRASSY_LUSH_SAND.get());
- private static final RuleSource LUSH_SAND = makeStateRule(MysticBlocks.LUSH_SAND.get());
- private static final RuleSource LUSH_SANDSTONE = makeStateRule(MysticBlocks.LUSH_SANDSTONE.get());
- private static RuleSource makeStateRule(Block block) {
- return SurfaceRules.state(block.defaultBlockState());
- }
- public static RuleSource overworld() {
- return overworldLike(true, false, true);
- }
- public static SurfaceRules.RuleSource overworldLike(boolean surface, boolean nether, boolean overworld) {
- ConditionSource above97 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(97), 2);
- ConditionSource above256 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(256), 0);
- ConditionSource above63_1 = SurfaceRules.yStartCheck(VerticalAnchor.absolute(63), -1);
- ConditionSource above74 = SurfaceRules.yStartCheck(VerticalAnchor.absolute(74), 1);
- ConditionSource above62 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(62), 0);
- ConditionSource above63_0 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(63), 0);
- ConditionSource isAtOrAboveWaterLevel = SurfaceRules.waterBlockCheck(-1, 0);
- ConditionSource isAboveWaterLevel = SurfaceRules.waterBlockCheck(0, 0);
- ConditionSource conditionSource8 = SurfaceRules.waterStartCheck(-6, -1);
- ConditionSource isHole = SurfaceRules.hole();
- ConditionSource isFrozenOcean = SurfaceRules.isBiome(Biomes.FROZEN_OCEAN, Biomes.DEEP_FROZEN_OCEAN);
- ConditionSource isSteep = SurfaceRules.steep();
- RuleSource grassSurface = SurfaceRules.sequence(SurfaceRules.ifTrue(isAtOrAboveWaterLevel, GRASS_BLOCK), DIRT);
- RuleSource sandstoneLinedSand = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, SANDSTONE), SAND);
- RuleSource stoneLinedGravel = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, STONE), GRAVEL);
- ConditionSource isSandstoneLiningBiome = SurfaceRules.isBiome(Biomes.WARM_OCEAN, Biomes.DESERT, Biomes.BEACH, Biomes.SNOWY_BEACH, MysticBiomes.LAGOON);
- 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));
- RuleSource ruleSource4 = SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.POWDER_SNOW, 0.45D, 0.58D), POWDER_SNOW);
- RuleSource ruleSource5 = SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.POWDER_SNOW, 0.35D, 0.6D), POWDER_SNOW);
- 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);
- 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);
- ConditionSource conditionSource13 = SurfaceRules.noiseCondition(Noises.SURFACE, -0.909D, -0.5454D);
- ConditionSource conditionSource14 = SurfaceRules.noiseCondition(Noises.SURFACE, -0.1818D, 0.1818D);
- ConditionSource conditionSource15 = SurfaceRules.noiseCondition(Noises.SURFACE, 0.5454D, 0.909D);
- SurfaceRules.RuleSource isLushSandstone = SurfaceRules.sequence(LUSH_SANDSTONE);
- 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)));
- ImmutableList.Builder<RuleSource> bedrockBuilder = ImmutableList.builder();
- if (nether) {
- bedrockBuilder.add(SurfaceRules.ifTrue(SurfaceRules.not(SurfaceRules.verticalGradient("bedrock_roof", VerticalAnchor.belowTop(5), VerticalAnchor.top())), BEDROCK));
- }
- if (overworld) {
- bedrockBuilder.add(SurfaceRules.ifTrue(SurfaceRules.verticalGradient("bedrock_floor", VerticalAnchor.bottom(), VerticalAnchor.aboveBottom(5)), BEDROCK));
- }
- RuleSource ruleSource9 = SurfaceRules.ifTrue(SurfaceRules.abovePreliminarySurface(), surfaceRules);
- bedrockBuilder.add(surface ? ruleSource9 : surfaceRules);
- bedrockBuilder.add(SurfaceRules.ifTrue(SurfaceRules.verticalGradient("deepslate", VerticalAnchor.absolute(0), VerticalAnchor.absolute(8)), DEEPSLATE));
- return SurfaceRules.sequence(bedrockBuilder.build().toArray(RuleSource[]::new));
- }
- private static SurfaceRules.RuleSource mysticRule() {
- ConditionSource isAtOrAboveWaterLevel = SurfaceRules.waterBlockCheck(-1, 0);
- RuleSource grassSurface = SurfaceRules.sequence(SurfaceRules.ifTrue(isAtOrAboveWaterLevel, GRASSY_LUSH_SAND), LUSH_SAND);
- SurfaceRules.RuleSource lushSand = SurfaceRules.sequence(SurfaceRules.ifTrue(surfaceNoiseAbove(-0.6D), SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, LUSH_SANDSTONE), LUSH_SAND)), grassSurface);
- SurfaceRules.RuleSource sand = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_CEILING, SANDSTONE), SAND);
- return SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(MysticBiomes.LUSH_OASIS), lushSand), SurfaceRules.ifTrue(SurfaceRules.isBiome(MysticBiomes.LAGOON), sand));
- }
- private static SurfaceRules.ConditionSource surfaceNoiseAbove(double value) {
- return SurfaceRules.noiseCondition(Noises.SURFACE, value / 8.25D, Double.MAX_VALUE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement