| 1 | package net.minecraft.data.worldgen.placement;
|
| 2 |
|
| 3 | import com.google.common.collect.ImmutableList;
|
| 4 | import java.util.List;
|
| 5 | import net.minecraft.core.Direction;
|
| 6 | import net.minecraft.core.Holder;
|
| 7 | import net.minecraft.core.HolderGetter;
|
| 8 | import net.minecraft.core.registries.Registries;
|
| 9 | import net.minecraft.data.worldgen.BootstrapContext;
|
| 10 | import net.minecraft.data.worldgen.features.NetherFeatures;
|
| 11 | import net.minecraft.resources.ResourceKey;
|
| 12 | import net.minecraft.tags.BlockTags;
|
| 13 | import net.minecraft.util.valueproviders.BiasedToBottomInt;
|
| 14 | import net.minecraft.util.valueproviders.UniformInt;
|
| 15 | import net.minecraft.world.level.block.Block;
|
| 16 | import net.minecraft.world.level.block.Blocks;
|
| 17 | import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
| 18 | import net.minecraft.world.level.levelgen.feature.Feature;
|
| 19 | import net.minecraft.world.level.levelgen.placement.BiomeFilter;
|
| 20 | import net.minecraft.world.level.levelgen.placement.BlockPredicateFilter;
|
| 21 | import net.minecraft.world.level.levelgen.placement.CountOnEveryLayerPlacement;
|
| 22 | import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
| 23 | import net.minecraft.world.level.levelgen.placement.EnvironmentScanPlacement;
|
| 24 | import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
|
| 25 | import net.minecraft.world.level.levelgen.placement.OffsetPlacement;
|
| 26 | import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
| 27 | import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
| 28 |
|
| 29 | public class NetherPlacements {
|
| 30 | public static final ResourceKey<PlacedFeature> DELTA = PlacementUtils.createKey("delta");
|
| 31 | public static final ResourceKey<PlacedFeature> SMALL_BASALT_COLUMNS = PlacementUtils.createKey("small_basalt_columns");
|
| 32 | public static final ResourceKey<PlacedFeature> LARGE_BASALT_COLUMNS = PlacementUtils.createKey("large_basalt_columns");
|
| 33 | public static final ResourceKey<PlacedFeature> BASALT_BLOBS = PlacementUtils.createKey("basalt_blobs");
|
| 34 | public static final ResourceKey<PlacedFeature> BLACKSTONE_BLOBS = PlacementUtils.createKey("blackstone_blobs");
|
| 35 | public static final ResourceKey<PlacedFeature> GLOWSTONE_EXTRA = PlacementUtils.createKey("glowstone_extra");
|
| 36 | public static final ResourceKey<PlacedFeature> GLOWSTONE = PlacementUtils.createKey("glowstone");
|
| 37 | public static final ResourceKey<PlacedFeature> CRIMSON_FOREST_VEGETATION = PlacementUtils.createKey("crimson_forest_vegetation");
|
| 38 | public static final ResourceKey<PlacedFeature> WARPED_FOREST_VEGETATION = PlacementUtils.createKey("warped_forest_vegetation");
|
| 39 | public static final ResourceKey<PlacedFeature> NETHER_SPROUTS = PlacementUtils.createKey("nether_sprouts");
|
| 40 | public static final ResourceKey<PlacedFeature> TWISTING_VINES = PlacementUtils.createKey("twisting_vines");
|
| 41 | public static final ResourceKey<PlacedFeature> WEEPING_VINES = PlacementUtils.createKey("weeping_vines");
|
| 42 | public static final ResourceKey<PlacedFeature> PATCH_CRIMSON_ROOTS = PlacementUtils.createKey("patch_crimson_roots");
|
| 43 | public static final ResourceKey<PlacedFeature> BASALT_PILLAR = PlacementUtils.createKey("basalt_pillar");
|
| 44 | public static final ResourceKey<PlacedFeature> SPRING_DELTA = PlacementUtils.createKey("spring_delta");
|
| 45 | public static final ResourceKey<PlacedFeature> SPRING_CLOSED = PlacementUtils.createKey("spring_closed");
|
| 46 | public static final ResourceKey<PlacedFeature> SPRING_CLOSED_DOUBLE = PlacementUtils.createKey("spring_closed_double");
|
| 47 | public static final ResourceKey<PlacedFeature> SPRING_OPEN = PlacementUtils.createKey("spring_open");
|
| 48 | public static final ResourceKey<PlacedFeature> PATCH_SOUL_FIRE = PlacementUtils.createKey("patch_soul_fire");
|
| 49 | public static final ResourceKey<PlacedFeature> PATCH_FIRE = PlacementUtils.createKey("patch_fire");
|
| 50 |
|
| 51 | public static void bootstrap(final BootstrapContext<PlacedFeature> context) {
|
| 52 | HolderGetter<Feature> configuredFeatures = context.lookup(Registries.FEATURE);
|
| 53 | Holder<Feature> delta = configuredFeatures.getOrThrow(NetherFeatures.DELTA);
|
| 54 | Holder<Feature> smallBasaltColumns = configuredFeatures.getOrThrow(NetherFeatures.SMALL_BASALT_COLUMNS);
|
| 55 | Holder<Feature> largeBasaltColumns = configuredFeatures.getOrThrow(NetherFeatures.LARGE_BASALT_COLUMNS);
|
| 56 | Holder<Feature> basaltBlobs = configuredFeatures.getOrThrow(NetherFeatures.BASALT_BLOBS);
|
| 57 | Holder<Feature> blackstoneBlobs = configuredFeatures.getOrThrow(NetherFeatures.BLACKSTONE_BLOBS);
|
| 58 | Holder<Feature> glowstoneExtra = configuredFeatures.getOrThrow(NetherFeatures.GLOWSTONE_EXTRA);
|
| 59 | Holder<Feature> crimsonForestVegetation = configuredFeatures.getOrThrow(NetherFeatures.CRIMSON_FOREST_VEGETATION);
|
| 60 | Holder<Feature> warpedForestVegetation = configuredFeatures.getOrThrow(NetherFeatures.WARPED_FOREST_VEGETION);
|
| 61 | Holder<Feature> netherSprouts = configuredFeatures.getOrThrow(NetherFeatures.NETHER_SPROUTS);
|
| 62 | Holder<Feature> twistingVines = configuredFeatures.getOrThrow(NetherFeatures.TWISTING_VINES);
|
| 63 | Holder<Feature> weepingVines = configuredFeatures.getOrThrow(NetherFeatures.WEEPING_VINES);
|
| 64 | Holder<Feature> crimsonRoots = configuredFeatures.getOrThrow(NetherFeatures.CRIMSON_ROOTS);
|
| 65 | Holder<Feature> basaltPillar = configuredFeatures.getOrThrow(NetherFeatures.BASALT_PILLAR);
|
| 66 | Holder<Feature> springLavaNether = configuredFeatures.getOrThrow(NetherFeatures.SPRING_LAVA_NETHER);
|
| 67 | Holder<Feature> springNetherClosed = configuredFeatures.getOrThrow(NetherFeatures.SPRING_NETHER_CLOSED);
|
| 68 | Holder<Feature> springNetherOpen = configuredFeatures.getOrThrow(NetherFeatures.SPRING_NETHER_OPEN);
|
| 69 | Holder<Feature> soulFire = configuredFeatures.getOrThrow(NetherFeatures.SOUL_FIRE);
|
| 70 | Holder<Feature> fire = configuredFeatures.getOrThrow(NetherFeatures.FIRE);
|
| 71 | PlacementUtils.register(context, DELTA, delta, CountOnEveryLayerPlacement.of(40), BiomeFilter.biome());
|
| 72 | PlacementUtils.register(context, SMALL_BASALT_COLUMNS, smallBasaltColumns, CountOnEveryLayerPlacement.of(4), BiomeFilter.biome());
|
| 73 | PlacementUtils.register(context, LARGE_BASALT_COLUMNS, largeBasaltColumns, CountOnEveryLayerPlacement.of(2), BiomeFilter.biome());
|
| 74 | PlacementUtils.register(context, BASALT_BLOBS, basaltBlobs, CountPlacement.of(75), InSquarePlacement.spread(), PlacementUtils.FULL_RANGE, BiomeFilter.biome());
|
| 75 | PlacementUtils.register(
|
| 76 | context, BLACKSTONE_BLOBS, blackstoneBlobs, CountPlacement.of(25), InSquarePlacement.spread(), PlacementUtils.FULL_RANGE, BiomeFilter.biome()
|
| 77 | );
|
| 78 | PlacementUtils.register(
|
| 79 | context,
|
| 80 | GLOWSTONE_EXTRA,
|
| 81 | glowstoneExtra,
|
| 82 | CountPlacement.of(BiasedToBottomInt.of(0, 9)),
|
| 83 | InSquarePlacement.spread(),
|
| 84 | PlacementUtils.RANGE_4_4,
|
| 85 | BlockPredicateFilter.forPredicate(
|
| 86 | BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.UP, Blocks.NETHERRACK, Blocks.BASALT, Blocks.BLACKSTONE))
|
| 87 | ),
|
| 88 | BiomeFilter.biome()
|
| 89 | );
|
| 90 | PlacementUtils.register(
|
| 91 | context,
|
| 92 | GLOWSTONE,
|
| 93 | glowstoneExtra,
|
| 94 | CountPlacement.of(10),
|
| 95 | InSquarePlacement.spread(),
|
| 96 | PlacementUtils.FULL_RANGE,
|
| 97 | BlockPredicateFilter.forPredicate(
|
| 98 | BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.UP, Blocks.NETHERRACK, Blocks.BASALT, Blocks.BLACKSTONE))
|
| 99 | ),
|
| 100 | BiomeFilter.biome()
|
| 101 | );
|
| 102 | PlacementUtils.register(
|
| 103 | context,
|
| 104 | CRIMSON_FOREST_VEGETATION,
|
| 105 | crimsonForestVegetation,
|
| 106 | CountOnEveryLayerPlacement.of(6),
|
| 107 | BiomeFilter.biome(),
|
| 108 | BlockPredicateFilter.forPredicate(BlockPredicate.matchesTag(Direction.DOWN, BlockTags.NYLIUM)),
|
| 109 | CountPlacement.of(64),
|
| 110 | OffsetPlacement.ofTriangle(7, 3),
|
| 111 | BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE)
|
| 112 | );
|
| 113 | PlacementUtils.register(
|
| 114 | context,
|
| 115 | WARPED_FOREST_VEGETATION,
|
| 116 | warpedForestVegetation,
|
| 117 | CountOnEveryLayerPlacement.of(5),
|
| 118 | BiomeFilter.biome(),
|
| 119 | BlockPredicateFilter.forPredicate(BlockPredicate.matchesTag(Direction.DOWN, BlockTags.NYLIUM)),
|
| 120 | CountPlacement.of(64),
|
| 121 | OffsetPlacement.ofTriangle(7, 3),
|
| 122 | BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE)
|
| 123 | );
|
| 124 | PlacementUtils.register(
|
| 125 | context,
|
| 126 | NETHER_SPROUTS,
|
| 127 | netherSprouts,
|
| 128 | CountOnEveryLayerPlacement.of(4),
|
| 129 | BiomeFilter.biome(),
|
| 130 | BlockPredicateFilter.forPredicate(BlockPredicate.matchesTag(Direction.DOWN, BlockTags.NYLIUM)),
|
| 131 | CountPlacement.of(64),
|
| 132 | OffsetPlacement.ofTriangle(7, 3),
|
| 133 | BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE)
|
| 134 | );
|
| 135 | PlacementUtils.register(
|
| 136 | context,
|
| 137 | TWISTING_VINES,
|
| 138 | twistingVines,
|
| 139 | ImmutableList.<PlacementModifier>builder()
|
| 140 | .add(CountPlacement.of(10), InSquarePlacement.spread(), PlacementUtils.FULL_RANGE, BiomeFilter.biome())
|
| 141 | .addAll(spreadTwistingVines(8, 4))
|
| 142 | .build()
|
| 143 | );
|
| 144 | PlacementUtils.register(
|
| 145 | context,
|
| 146 | WEEPING_VINES,
|
| 147 | weepingVines,
|
| 148 | CountPlacement.of(10),
|
| 149 | InSquarePlacement.spread(),
|
| 150 | PlacementUtils.FULL_RANGE,
|
| 151 | BiomeFilter.biome(),
|
| 152 | BlockPredicateFilter.forPredicate(
|
| 153 | BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.UP, Blocks.NETHERRACK, Blocks.NETHER_WART_BLOCK))
|
| 154 | )
|
| 155 | );
|
| 156 | PlacementUtils.register(
|
| 157 | context,
|
| 158 | PATCH_CRIMSON_ROOTS,
|
| 159 | crimsonRoots,
|
| 160 | PlacementUtils.FULL_RANGE,
|
| 161 | BiomeFilter.biome(),
|
| 162 | CountPlacement.of(96),
|
| 163 | OffsetPlacement.ofTriangle(7, 3),
|
| 164 | BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE)
|
| 165 | );
|
| 166 | PlacementUtils.register(
|
| 167 | context,
|
| 168 | BASALT_PILLAR,
|
| 169 | basaltPillar,
|
| 170 | CountPlacement.of(10),
|
| 171 | InSquarePlacement.spread(),
|
| 172 | PlacementUtils.FULL_RANGE,
|
| 173 | BlockPredicateFilter.forPredicate(
|
| 174 | BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.not(BlockPredicate.matchesTag(Direction.UP, BlockTags.AIR)))
|
| 175 | ),
|
| 176 | BiomeFilter.biome()
|
| 177 | );
|
| 178 | PlacementUtils.register(
|
| 179 | context, SPRING_DELTA, springLavaNether, CountPlacement.of(16), InSquarePlacement.spread(), PlacementUtils.RANGE_4_4, BiomeFilter.biome()
|
| 180 | );
|
| 181 | PlacementUtils.register(
|
| 182 | context, SPRING_CLOSED, springNetherClosed, CountPlacement.of(16), InSquarePlacement.spread(), PlacementUtils.RANGE_10_10, BiomeFilter.biome()
|
| 183 | );
|
| 184 | PlacementUtils.register(
|
| 185 | context, SPRING_CLOSED_DOUBLE, springNetherClosed, CountPlacement.of(32), InSquarePlacement.spread(), PlacementUtils.RANGE_10_10, BiomeFilter.biome()
|
| 186 | );
|
| 187 | PlacementUtils.register(
|
| 188 | context, SPRING_OPEN, springNetherOpen, CountPlacement.of(8), InSquarePlacement.spread(), PlacementUtils.RANGE_4_4, BiomeFilter.biome()
|
| 189 | );
|
| 190 | PlacementUtils.register(context, PATCH_SOUL_FIRE, soulFire, firePlacement(Blocks.SOUL_SOIL));
|
| 191 | PlacementUtils.register(context, PATCH_FIRE, fire, firePlacement(Blocks.NETHERRACK));
|
| 192 | }
|
| 193 |
|
| 194 | private static List<PlacementModifier> firePlacement(final Block onlyOnBlock) {
|
| 195 | return List.of(
|
| 196 | CountPlacement.of(UniformInt.of(0, 5)),
|
| 197 | InSquarePlacement.spread(),
|
| 198 | PlacementUtils.RANGE_4_4,
|
| 199 | BiomeFilter.biome(),
|
| 200 | CountPlacement.of(96),
|
| 201 | OffsetPlacement.ofTriangle(7, 3),
|
| 202 | BlockPredicateFilter.forPredicate(BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.DOWN, onlyOnBlock)))
|
| 203 | );
|
| 204 | }
|
| 205 |
|
| 206 | public static List<PlacementModifier> spreadTwistingVines(final int spreadWidth, final int spreadHeight) {
|
| 207 | BlockPredicateFilter placementFilter = BlockPredicateFilter.forPredicate(
|
| 208 | BlockPredicate.allOf(
|
| 209 | BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.DOWN, Blocks.NETHERRACK, Blocks.WARPED_NYLIUM, Blocks.WARPED_WART_BLOCK)
|
| 210 | )
|
| 211 | );
|
| 212 | return List.of(
|
| 213 | placementFilter,
|
| 214 | CountPlacement.of(spreadWidth * spreadWidth),
|
| 215 | OffsetPlacement.of(UniformInt.of(-spreadWidth, spreadWidth), UniformInt.of(-spreadHeight, spreadHeight)),
|
| 216 | OffsetPlacement.of(Direction.DOWN),
|
| 217 | EnvironmentScanPlacement.scanningFor(Direction.DOWN, BlockPredicate.not(BlockPredicate.ONLY_IN_AIR_PREDICATE), 32),
|
| 218 | OffsetPlacement.of(Direction.UP),
|
| 219 | placementFilter
|
| 220 | );
|
| 221 | }
|
| 222 | }
|
| 223 |
|