| 1 | package net.minecraft.data.worldgen.placement;
|
| 2 |
|
| 3 | import net.minecraft.core.Direction;
|
| 4 | import net.minecraft.core.Holder;
|
| 5 | import net.minecraft.core.HolderGetter;
|
| 6 | import net.minecraft.core.registries.Registries;
|
| 7 | import net.minecraft.data.worldgen.BootstrapContext;
|
| 8 | import net.minecraft.data.worldgen.features.CaveFeatures;
|
| 9 | import net.minecraft.data.worldgen.features.VegetationFeatures;
|
| 10 | import net.minecraft.resources.ResourceKey;
|
| 11 | import net.minecraft.util.valueproviders.ClampedNormalInt;
|
| 12 | import net.minecraft.util.valueproviders.ConstantInt;
|
| 13 | import net.minecraft.util.valueproviders.UniformInt;
|
| 14 | import net.minecraft.world.level.levelgen.Heightmap;
|
| 15 | import net.minecraft.world.level.levelgen.VerticalAnchor;
|
| 16 | import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
| 17 | import net.minecraft.world.level.levelgen.feature.Feature;
|
| 18 | import net.minecraft.world.level.levelgen.placement.BiomeFilter;
|
| 19 | import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
| 20 | import net.minecraft.world.level.levelgen.placement.EnvironmentScanPlacement;
|
| 21 | import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
|
| 22 | import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
|
| 23 | import net.minecraft.world.level.levelgen.placement.OffsetPlacement;
|
| 24 | import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
| 25 | import net.minecraft.world.level.levelgen.placement.RarityFilter;
|
| 26 | import net.minecraft.world.level.levelgen.placement.SurfaceRelativeThresholdFilter;
|
| 27 |
|
| 28 | public class CavePlacements {
|
| 29 | public static final ResourceKey<PlacedFeature> MONSTER_ROOM = PlacementUtils.createKey("monster_room");
|
| 30 | public static final ResourceKey<PlacedFeature> MONSTER_ROOM_DEEP = PlacementUtils.createKey("monster_room_deep");
|
| 31 | public static final ResourceKey<PlacedFeature> FOSSIL_UPPER = PlacementUtils.createKey("fossil_upper");
|
| 32 | public static final ResourceKey<PlacedFeature> FOSSIL_LOWER = PlacementUtils.createKey("fossil_lower");
|
| 33 | public static final ResourceKey<PlacedFeature> DRIPSTONE_CLUSTER = PlacementUtils.createKey("dripstone_cluster");
|
| 34 | public static final ResourceKey<PlacedFeature> SULFUR_SPIKE_CLUSTER = PlacementUtils.createKey("sulfur_spike_cluster");
|
| 35 | public static final ResourceKey<PlacedFeature> LARGE_DRIPSTONE = PlacementUtils.createKey("large_dripstone");
|
| 36 | public static final ResourceKey<PlacedFeature> POINTED_DRIPSTONE = PlacementUtils.createKey("pointed_dripstone");
|
| 37 | public static final ResourceKey<PlacedFeature> SULFUR_SPIKE = PlacementUtils.createKey("sulfur_spike");
|
| 38 | public static final ResourceKey<PlacedFeature> UNDERWATER_MAGMA = PlacementUtils.createKey("underwater_magma");
|
| 39 | public static final ResourceKey<PlacedFeature> GLOW_LICHEN = PlacementUtils.createKey("glow_lichen");
|
| 40 | public static final ResourceKey<PlacedFeature> ROOTED_AZALEA_TREE = PlacementUtils.createKey("rooted_azalea_tree");
|
| 41 | public static final ResourceKey<PlacedFeature> ROOTED_SULFUR_SPRING = PlacementUtils.createKey("rooted_sulfur_spring");
|
| 42 | public static final ResourceKey<PlacedFeature> CAVE_VINES = PlacementUtils.createKey("cave_vines");
|
| 43 | public static final ResourceKey<PlacedFeature> LUSH_CAVES_VEGETATION = PlacementUtils.createKey("lush_caves_vegetation");
|
| 44 | public static final ResourceKey<PlacedFeature> LUSH_CAVES_CLAY = PlacementUtils.createKey("lush_caves_clay");
|
| 45 | public static final ResourceKey<PlacedFeature> LUSH_CAVES_CEILING_VEGETATION = PlacementUtils.createKey("lush_caves_ceiling_vegetation");
|
| 46 | public static final ResourceKey<PlacedFeature> SPORE_BLOSSOM = PlacementUtils.createKey("spore_blossom");
|
| 47 | public static final ResourceKey<PlacedFeature> CLASSIC_VINES = PlacementUtils.createKey("classic_vines_cave_feature");
|
| 48 | public static final ResourceKey<PlacedFeature> AMETHYST_GEODE = PlacementUtils.createKey("amethyst_geode");
|
| 49 | public static final ResourceKey<PlacedFeature> SCULK_PATCH_DEEP_DARK = PlacementUtils.createKey("sculk_patch_deep_dark");
|
| 50 | public static final ResourceKey<PlacedFeature> SCULK_PATCH_ANCIENT_CITY = PlacementUtils.createKey("sculk_patch_ancient_city");
|
| 51 | public static final ResourceKey<PlacedFeature> SCULK_VEIN = PlacementUtils.createKey("sculk_vein");
|
| 52 |
|
| 53 | public static void bootstrap(final BootstrapContext<PlacedFeature> context) {
|
| 54 | HolderGetter<Feature> configuredFeatures = context.lookup(Registries.FEATURE);
|
| 55 | Holder<Feature> monsterRoom = configuredFeatures.getOrThrow(CaveFeatures.MONSTER_ROOM);
|
| 56 | Holder<Feature> fossilCoal = configuredFeatures.getOrThrow(CaveFeatures.FOSSIL_COAL);
|
| 57 | Holder<Feature> fossilDiamonds = configuredFeatures.getOrThrow(CaveFeatures.FOSSIL_DIAMONDS);
|
| 58 | Holder<Feature> dripstoneCluster = configuredFeatures.getOrThrow(CaveFeatures.DRIPSTONE_CLUSTER);
|
| 59 | Holder<Feature> sulfurSpikeCluster = configuredFeatures.getOrThrow(CaveFeatures.SULFUR_SPIKE_CLUSTER);
|
| 60 | Holder<Feature> largeDripstone = configuredFeatures.getOrThrow(CaveFeatures.LARGE_DRIPSTONE);
|
| 61 | Holder<Feature> pointedDripstone = configuredFeatures.getOrThrow(CaveFeatures.POINTED_DRIPSTONE);
|
| 62 | Holder<Feature> sulfurSpike = configuredFeatures.getOrThrow(CaveFeatures.SULFUR_SPIKE);
|
| 63 | Holder<Feature> underwaterMagma = configuredFeatures.getOrThrow(CaveFeatures.UNDERWATER_MAGMA);
|
| 64 | Holder<Feature> glowLichen = configuredFeatures.getOrThrow(CaveFeatures.GLOW_LICHEN);
|
| 65 | Holder<Feature> rootedAzaleaTree = configuredFeatures.getOrThrow(CaveFeatures.ROOTED_AZALEA_TREE);
|
| 66 | Holder<Feature> rootedSulfurSpring = configuredFeatures.getOrThrow(CaveFeatures.ROOTED_SULFUR_SPRING);
|
| 67 | Holder<Feature> caveVine = configuredFeatures.getOrThrow(CaveFeatures.CAVE_VINE);
|
| 68 | Holder<Feature> mossPatch = configuredFeatures.getOrThrow(CaveFeatures.MOSS_PATCH);
|
| 69 | Holder<Feature> lushCavesClay = configuredFeatures.getOrThrow(CaveFeatures.LUSH_CAVES_CLAY);
|
| 70 | Holder<Feature> mossPatchCeiling = configuredFeatures.getOrThrow(CaveFeatures.MOSS_PATCH_CEILING);
|
| 71 | Holder<Feature> sporeBlossom = configuredFeatures.getOrThrow(CaveFeatures.SPORE_BLOSSOM);
|
| 72 | Holder<Feature> vines = configuredFeatures.getOrThrow(VegetationFeatures.VINES);
|
| 73 | Holder<Feature> amethystGeode = configuredFeatures.getOrThrow(CaveFeatures.AMETHYST_GEODE);
|
| 74 | Holder<Feature> sculkPatchDeepDark = configuredFeatures.getOrThrow(CaveFeatures.SCULK_PATCH_DEEP_DARK);
|
| 75 | Holder<Feature> sculkPatchAncientCity = configuredFeatures.getOrThrow(CaveFeatures.SCULK_PATCH_ANCIENT_CITY);
|
| 76 | Holder<Feature> sculkVein = configuredFeatures.getOrThrow(CaveFeatures.SCULK_VEIN);
|
| 77 | PlacementUtils.register(
|
| 78 | context,
|
| 79 | MONSTER_ROOM,
|
| 80 | monsterRoom,
|
| 81 | CountPlacement.of(10),
|
| 82 | InSquarePlacement.spread(),
|
| 83 | HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.top()),
|
| 84 | BiomeFilter.biome()
|
| 85 | );
|
| 86 | PlacementUtils.register(
|
| 87 | context,
|
| 88 | MONSTER_ROOM_DEEP,
|
| 89 | monsterRoom,
|
| 90 | CountPlacement.of(4),
|
| 91 | InSquarePlacement.spread(),
|
| 92 | HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(6), VerticalAnchor.absolute(-1)),
|
| 93 | BiomeFilter.biome()
|
| 94 | );
|
| 95 | PlacementUtils.register(
|
| 96 | context,
|
| 97 | FOSSIL_UPPER,
|
| 98 | fossilCoal,
|
| 99 | RarityFilter.onAverageOnceEvery(64),
|
| 100 | InSquarePlacement.spread(),
|
| 101 | HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.top()),
|
| 102 | BiomeFilter.biome()
|
| 103 | );
|
| 104 | PlacementUtils.register(
|
| 105 | context,
|
| 106 | FOSSIL_LOWER,
|
| 107 | fossilDiamonds,
|
| 108 | RarityFilter.onAverageOnceEvery(64),
|
| 109 | InSquarePlacement.spread(),
|
| 110 | HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(-8)),
|
| 111 | BiomeFilter.biome()
|
| 112 | );
|
| 113 | PlacementUtils.register(
|
| 114 | context,
|
| 115 | DRIPSTONE_CLUSTER,
|
| 116 | dripstoneCluster,
|
| 117 | CountPlacement.of(UniformInt.of(48, 96)),
|
| 118 | InSquarePlacement.spread(),
|
| 119 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 120 | BiomeFilter.biome()
|
| 121 | );
|
| 122 | PlacementUtils.register(
|
| 123 | context,
|
| 124 | SULFUR_SPIKE_CLUSTER,
|
| 125 | sulfurSpikeCluster,
|
| 126 | CountPlacement.of(UniformInt.of(48, 96)),
|
| 127 | InSquarePlacement.spread(),
|
| 128 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 129 | BiomeFilter.biome()
|
| 130 | );
|
| 131 | PlacementUtils.register(
|
| 132 | context,
|
| 133 | LARGE_DRIPSTONE,
|
| 134 | largeDripstone,
|
| 135 | CountPlacement.of(UniformInt.of(10, 48)),
|
| 136 | InSquarePlacement.spread(),
|
| 137 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 138 | BiomeFilter.biome()
|
| 139 | );
|
| 140 | PlacementUtils.register(
|
| 141 | context,
|
| 142 | POINTED_DRIPSTONE,
|
| 143 | pointedDripstone,
|
| 144 | CountPlacement.of(UniformInt.of(192, 256)),
|
| 145 | InSquarePlacement.spread(),
|
| 146 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 147 | CountPlacement.of(UniformInt.of(1, 5)),
|
| 148 | OffsetPlacement.of(ClampedNormalInt.of(0.0F, 3.0F, -10, 10), ClampedNormalInt.of(0.0F, 0.6F, -2, 2)),
|
| 149 | BiomeFilter.biome()
|
| 150 | );
|
| 151 | PlacementUtils.register(
|
| 152 | context,
|
| 153 | SULFUR_SPIKE,
|
| 154 | sulfurSpike,
|
| 155 | CountPlacement.of(UniformInt.of(192, 256)),
|
| 156 | InSquarePlacement.spread(),
|
| 157 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 158 | CountPlacement.of(UniformInt.of(1, 5)),
|
| 159 | OffsetPlacement.of(ClampedNormalInt.of(0.0F, 3.0F, -10, 10), ClampedNormalInt.of(0.0F, 0.6F, -2, 2)),
|
| 160 | BiomeFilter.biome()
|
| 161 | );
|
| 162 | PlacementUtils.register(
|
| 163 | context,
|
| 164 | UNDERWATER_MAGMA,
|
| 165 | underwaterMagma,
|
| 166 | CountPlacement.of(UniformInt.of(44, 52)),
|
| 167 | InSquarePlacement.spread(),
|
| 168 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 169 | SurfaceRelativeThresholdFilter.of(Heightmap.Types.OCEAN_FLOOR_WG, Integer.MIN_VALUE, -2),
|
| 170 | BiomeFilter.biome()
|
| 171 | );
|
| 172 | PlacementUtils.register(
|
| 173 | context,
|
| 174 | GLOW_LICHEN,
|
| 175 | glowLichen,
|
| 176 | CountPlacement.of(UniformInt.of(104, 157)),
|
| 177 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 178 | InSquarePlacement.spread(),
|
| 179 | SurfaceRelativeThresholdFilter.of(Heightmap.Types.OCEAN_FLOOR_WG, Integer.MIN_VALUE, -13),
|
| 180 | BiomeFilter.biome()
|
| 181 | );
|
| 182 | PlacementUtils.register(
|
| 183 | context,
|
| 184 | ROOTED_AZALEA_TREE,
|
| 185 | rootedAzaleaTree,
|
| 186 | CountPlacement.of(UniformInt.of(1, 2)),
|
| 187 | InSquarePlacement.spread(),
|
| 188 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 189 | EnvironmentScanPlacement.scanningFor(Direction.UP, BlockPredicate.solid(), BlockPredicate.ONLY_IN_AIR_PREDICATE, 12),
|
| 190 | OffsetPlacement.vertical(ConstantInt.of(-1)),
|
| 191 | BiomeFilter.biome()
|
| 192 | );
|
| 193 | PlacementUtils.register(
|
| 194 | context,
|
| 195 | ROOTED_SULFUR_SPRING,
|
| 196 | rootedSulfurSpring,
|
| 197 | CountPlacement.of(UniformInt.of(1, 2)),
|
| 198 | InSquarePlacement.spread(),
|
| 199 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 200 | EnvironmentScanPlacement.scanningFor(Direction.UP, BlockPredicate.solid(), BlockPredicate.ONLY_IN_AIR_PREDICATE, 12),
|
| 201 | OffsetPlacement.vertical(ConstantInt.of(-1)),
|
| 202 | BiomeFilter.biome()
|
| 203 | );
|
| 204 | PlacementUtils.register(
|
| 205 | context,
|
| 206 | CAVE_VINES,
|
| 207 | caveVine,
|
| 208 | CountPlacement.of(188),
|
| 209 | InSquarePlacement.spread(),
|
| 210 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 211 | EnvironmentScanPlacement.scanningFor(Direction.UP, BlockPredicate.hasSturdyFace(Direction.DOWN), BlockPredicate.ONLY_IN_AIR_PREDICATE, 12),
|
| 212 | OffsetPlacement.vertical(ConstantInt.of(-1)),
|
| 213 | BiomeFilter.biome()
|
| 214 | );
|
| 215 | PlacementUtils.register(
|
| 216 | context,
|
| 217 | LUSH_CAVES_VEGETATION,
|
| 218 | mossPatch,
|
| 219 | CountPlacement.of(125),
|
| 220 | InSquarePlacement.spread(),
|
| 221 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 222 | EnvironmentScanPlacement.scanningFor(Direction.DOWN, BlockPredicate.solid(), BlockPredicate.ONLY_IN_AIR_PREDICATE, 12),
|
| 223 | OffsetPlacement.vertical(ConstantInt.of(1)),
|
| 224 | BiomeFilter.biome()
|
| 225 | );
|
| 226 | PlacementUtils.register(
|
| 227 | context,
|
| 228 | LUSH_CAVES_CLAY,
|
| 229 | lushCavesClay,
|
| 230 | CountPlacement.of(62),
|
| 231 | InSquarePlacement.spread(),
|
| 232 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 233 | EnvironmentScanPlacement.scanningFor(Direction.DOWN, BlockPredicate.solid(), BlockPredicate.ONLY_IN_AIR_PREDICATE, 12),
|
| 234 | OffsetPlacement.vertical(ConstantInt.of(1)),
|
| 235 | BiomeFilter.biome()
|
| 236 | );
|
| 237 | PlacementUtils.register(
|
| 238 | context,
|
| 239 | LUSH_CAVES_CEILING_VEGETATION,
|
| 240 | mossPatchCeiling,
|
| 241 | CountPlacement.of(125),
|
| 242 | InSquarePlacement.spread(),
|
| 243 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 244 | EnvironmentScanPlacement.scanningFor(Direction.UP, BlockPredicate.solid(), BlockPredicate.ONLY_IN_AIR_PREDICATE, 12),
|
| 245 | OffsetPlacement.vertical(ConstantInt.of(-1)),
|
| 246 | BiomeFilter.biome()
|
| 247 | );
|
| 248 | PlacementUtils.register(
|
| 249 | context,
|
| 250 | SPORE_BLOSSOM,
|
| 251 | sporeBlossom,
|
| 252 | CountPlacement.of(25),
|
| 253 | InSquarePlacement.spread(),
|
| 254 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 255 | EnvironmentScanPlacement.scanningFor(Direction.UP, BlockPredicate.solid(), BlockPredicate.ONLY_IN_AIR_PREDICATE, 12),
|
| 256 | OffsetPlacement.vertical(ConstantInt.of(-1)),
|
| 257 | BiomeFilter.biome()
|
| 258 | );
|
| 259 | PlacementUtils.register(
|
| 260 | context, CLASSIC_VINES, vines, CountPlacement.of(256), InSquarePlacement.spread(), PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, BiomeFilter.biome()
|
| 261 | );
|
| 262 | PlacementUtils.register(
|
| 263 | context,
|
| 264 | AMETHYST_GEODE,
|
| 265 | amethystGeode,
|
| 266 | RarityFilter.onAverageOnceEvery(24),
|
| 267 | InSquarePlacement.spread(),
|
| 268 | HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(6), VerticalAnchor.absolute(30)),
|
| 269 | BiomeFilter.biome()
|
| 270 | );
|
| 271 | PlacementUtils.register(
|
| 272 | context,
|
| 273 | SCULK_PATCH_DEEP_DARK,
|
| 274 | sculkPatchDeepDark,
|
| 275 | CountPlacement.of(ConstantInt.of(256)),
|
| 276 | InSquarePlacement.spread(),
|
| 277 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 278 | BiomeFilter.biome()
|
| 279 | );
|
| 280 | PlacementUtils.register(context, SCULK_PATCH_ANCIENT_CITY, sculkPatchAncientCity);
|
| 281 | PlacementUtils.register(
|
| 282 | context,
|
| 283 | SCULK_VEIN,
|
| 284 | sculkVein,
|
| 285 | CountPlacement.of(UniformInt.of(204, 250)),
|
| 286 | InSquarePlacement.spread(),
|
| 287 | PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
|
| 288 | BiomeFilter.biome()
|
| 289 | );
|
| 290 | }
|
| 291 | }
|
| 292 |
|