| 1 | package net.minecraft.data.worldgen.features;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import java.util.function.BiFunction;
|
| 5 | import java.util.function.Function;
|
| 6 | import net.minecraft.core.Direction;
|
| 7 | import net.minecraft.core.Holder;
|
| 8 | import net.minecraft.core.HolderSet;
|
| 9 | import net.minecraft.data.worldgen.BootstrapContext;
|
| 10 | import net.minecraft.data.worldgen.placement.PlacementUtils;
|
| 11 | import net.minecraft.resources.Identifier;
|
| 12 | import net.minecraft.resources.ResourceKey;
|
| 13 | import net.minecraft.tags.BlockTags;
|
| 14 | import net.minecraft.util.random.Weighted;
|
| 15 | import net.minecraft.util.random.WeightedList;
|
| 16 | import net.minecraft.util.valueproviders.ConstantInt;
|
| 17 | import net.minecraft.util.valueproviders.UniformInt;
|
| 18 | import net.minecraft.world.level.block.Block;
|
| 19 | import net.minecraft.world.level.block.Blocks;
|
| 20 | import net.minecraft.world.level.block.PotentSulfurBlock;
|
| 21 | import net.minecraft.world.level.block.state.properties.PotentSulfurState;
|
| 22 | import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
| 23 | import net.minecraft.world.level.levelgen.feature.BlockBlobFeature;
|
| 24 | import net.minecraft.world.level.levelgen.feature.BlueIceFeature;
|
| 25 | import net.minecraft.world.level.levelgen.feature.BonusChestFeature;
|
| 26 | import net.minecraft.world.level.levelgen.feature.DiskFeature;
|
| 27 | import net.minecraft.world.level.levelgen.feature.Feature;
|
| 28 | import net.minecraft.world.level.levelgen.feature.IcebergFeature;
|
| 29 | import net.minecraft.world.level.levelgen.feature.LakeFeature;
|
| 30 | import net.minecraft.world.level.levelgen.feature.OverlayFeature;
|
| 31 | import net.minecraft.world.level.levelgen.feature.SequenceFeature;
|
| 32 | import net.minecraft.world.level.levelgen.feature.SimpleBlockFeature;
|
| 33 | import net.minecraft.world.level.levelgen.feature.SnowAndFreezeFeature;
|
| 34 | import net.minecraft.world.level.levelgen.feature.SpikeFeature;
|
| 35 | import net.minecraft.world.level.levelgen.feature.SpringFeature;
|
| 36 | import net.minecraft.world.level.levelgen.feature.TemplateFeature;
|
| 37 | import net.minecraft.world.level.levelgen.feature.VoidStartPlatformFeature;
|
| 38 | import net.minecraft.world.level.levelgen.feature.WeightedRandomSelectorFeature;
|
| 39 | import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
| 40 | import net.minecraft.world.level.levelgen.feature.stateproviders.RuleBasedStateProvider;
|
| 41 | import net.minecraft.world.level.levelgen.placement.BlockPredicateFilter;
|
| 42 | import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
| 43 | import net.minecraft.world.level.levelgen.placement.EnvironmentScanPlacement;
|
| 44 | import net.minecraft.world.level.levelgen.placement.OffsetPlacement;
|
| 45 | import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
| 46 | import net.minecraft.world.level.levelgen.placement.RandomlySelectedPlacement;
|
| 47 | import net.minecraft.world.level.levelgen.structure.templatesystem.AlwaysTrueTest;
|
| 48 | import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest;
|
| 49 | import net.minecraft.world.level.levelgen.structure.templatesystem.PosAlwaysTrueTest;
|
| 50 | import net.minecraft.world.level.levelgen.structure.templatesystem.ProcessorRule;
|
| 51 | import net.minecraft.world.level.levelgen.structure.templatesystem.RuleProcessor;
|
| 52 | import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
| 53 | import net.minecraft.world.level.levelgen.structure.templatesystem.rule.blockentity.AppendLoot;
|
| 54 | import net.minecraft.world.level.material.Fluids;
|
| 55 | import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
| 56 |
|
| 57 | public class MiscOverworldFeatures {
|
| 58 | public static final ResourceKey<Feature> ICE_SPIKE = FeatureUtils.createKey("ice_spike");
|
| 59 | public static final ResourceKey<Feature> ICE_PATCH = FeatureUtils.createKey("ice_patch");
|
| 60 | public static final ResourceKey<Feature> FOREST_ROCK = FeatureUtils.createKey("forest_rock");
|
| 61 | public static final ResourceKey<Feature> ICEBERG_PACKED = FeatureUtils.createKey("iceberg_packed");
|
| 62 | public static final ResourceKey<Feature> ICEBERG_BLUE = FeatureUtils.createKey("iceberg_blue");
|
| 63 | public static final ResourceKey<Feature> BLUE_ICE = FeatureUtils.createKey("blue_ice");
|
| 64 | public static final ResourceKey<Feature> LAKE_LAVA = FeatureUtils.createKey("lake_lava");
|
| 65 | public static final ResourceKey<Feature> SULFUR_POOL = FeatureUtils.createKey("sulfur_pool");
|
| 66 | public static final ResourceKey<Feature> SULFUR_SPRING = FeatureUtils.createKey("sulfur_spring");
|
| 67 | public static final ResourceKey<Feature> DISK_CLAY = FeatureUtils.createKey("disk_clay");
|
| 68 | public static final ResourceKey<Feature> DISK_GRAVEL = FeatureUtils.createKey("disk_gravel");
|
| 69 | public static final ResourceKey<Feature> DISK_SAND = FeatureUtils.createKey("disk_sand");
|
| 70 | public static final ResourceKey<Feature> FREEZE_TOP_LAYER = FeatureUtils.createKey("freeze_top_layer");
|
| 71 | public static final ResourceKey<Feature> DISK_GRASS = FeatureUtils.createKey("disk_grass");
|
| 72 | public static final ResourceKey<Feature> BONUS_CHEST = FeatureUtils.createKey("bonus_chest");
|
| 73 | public static final ResourceKey<Feature> VOID_START_PLATFORM = FeatureUtils.createKey("void_start_platform");
|
| 74 | public static final ResourceKey<Feature> DESERT_WELL = FeatureUtils.createKey("desert_well");
|
| 75 | public static final ResourceKey<Feature> SPRING_LAVA_OVERWORLD = FeatureUtils.createKey("spring_lava_overworld");
|
| 76 | public static final ResourceKey<Feature> SPRING_LAVA_FROZEN = FeatureUtils.createKey("spring_lava_frozen");
|
| 77 | public static final ResourceKey<Feature> SPRING_WATER = FeatureUtils.createKey("spring_water");
|
| 78 |
|
| 79 | public static void bootstrap(final BootstrapContext<Feature> context) {
|
| 80 | context.register(
|
| 81 | ICE_SPIKE,
|
| 82 | new SpikeFeature(
|
| 83 | Blocks.PACKED_ICE.defaultBlockState(), BlockPredicate.matchesBlocks(Blocks.SNOW_BLOCK), BlockPredicate.matchesTag(BlockTags.ICE_SPIKE_REPLACEABLE)
|
| 84 | )
|
| 85 | );
|
| 86 | context.register(
|
| 87 | ICE_PATCH,
|
| 88 | new DiskFeature(
|
| 89 | BlockStateProvider.holderOf(Blocks.PACKED_ICE),
|
| 90 | BlockPredicate.matchesBlocks(Blocks.DIRT, Blocks.GRASS_BLOCK, Blocks.PODZOL, Blocks.COARSE_DIRT, Blocks.MYCELIUM, Blocks.SNOW_BLOCK, Blocks.ICE),
|
| 91 | UniformInt.of(2, 3),
|
| 92 | 1
|
| 93 | )
|
| 94 | );
|
| 95 | context.register(
|
| 96 | FOREST_ROCK, new BlockBlobFeature(Blocks.MOSSY_COBBLESTONE.defaultBlockState(), BlockPredicate.matchesTag(BlockTags.FOREST_ROCK_CAN_PLACE_ON))
|
| 97 | );
|
| 98 | context.register(ICEBERG_PACKED, new IcebergFeature(Blocks.PACKED_ICE.defaultBlockState()));
|
| 99 | context.register(ICEBERG_BLUE, new IcebergFeature(Blocks.BLUE_ICE.defaultBlockState()));
|
| 100 | context.register(BLUE_ICE, new BlueIceFeature());
|
| 101 | context.register(
|
| 102 | LAKE_LAVA,
|
| 103 | new LakeFeature(
|
| 104 | BlockStateProvider.holderOf(Blocks.LAVA),
|
| 105 | BlockStateProvider.holderOf(Blocks.STONE),
|
| 106 | BlockPredicate.alwaysTrue(),
|
| 107 | BlockPredicate.not(BlockPredicate.matchesTag(BlockTags.FEATURES_CANNOT_REPLACE)),
|
| 108 | BlockPredicate.not(BlockPredicate.matchesTag(BlockTags.LAVA_POOL_STONE_CANNOT_REPLACE))
|
| 109 | )
|
| 110 | );
|
| 111 | context.register(
|
| 112 | SULFUR_POOL,
|
| 113 | new SequenceFeature(
|
| 114 | HolderSet.direct(
|
| 115 | PlacementUtils.inlinePlaced(
|
| 116 | new LakeFeature(
|
| 117 | BlockStateProvider.holderOf(Blocks.WATER),
|
| 118 | BlockStateProvider.holderOf(Blocks.SULFUR),
|
| 119 | BlockPredicate.not(BlockPredicate.matchesBlocks(Blocks.SULFUR_SPIKE)),
|
| 120 | BlockPredicate.not(BlockPredicate.matchesTag(BlockTags.FEATURES_CANNOT_REPLACE)),
|
| 121 | BlockPredicate.not(BlockPredicate.matchesTag(BlockTags.LAVA_POOL_STONE_CANNOT_REPLACE))
|
| 122 | )
|
| 123 | ),
|
| 124 | PlacementUtils.inlinePlaced(
|
| 125 | new SimpleBlockFeature(BlockStateProvider.of(Blocks.POTENT_SULFUR.defaultBlockState().setValue(PotentSulfurBlock.STATE, PotentSulfurState.WET))),
|
| 126 | EnvironmentScanPlacement.scanningFor(
|
| 127 | Direction.DOWN, BlockPredicate.allOf(BlockPredicate.solid(), BlockPredicate.matchesFluids(Direction.UP, Fluids.WATER)), 4
|
| 128 | )
|
| 129 | )
|
| 130 | )
|
| 131 | )
|
| 132 | );
|
| 133 | BiFunction<Integer, Integer, Holder<PlacedFeature>> tuffCover = (count, spread) -> PlacementUtils.inlinePlaced(
|
| 134 | new SimpleBlockFeature(BlockStateProvider.of(Blocks.TUFF)),
|
| 135 | CountPlacement.of(count),
|
| 136 | OffsetPlacement.ofTriangle(spread, 3),
|
| 137 | EnvironmentScanPlacement.scanningFor(Direction.DOWN, BlockPredicate.solid(), 4),
|
| 138 | BlockPredicateFilter.forPredicate(BlockPredicate.solid())
|
| 139 | );
|
| 140 | Function<WeightedList<TemplateFeature.TemplateEntry>, Holder<PlacedFeature>> sulfurSprings = entries -> PlacementUtils.inlinePlaced(
|
| 141 | new TemplateFeature(entries), OffsetPlacement.vertical(ConstantInt.of(-7))
|
| 142 | );
|
| 143 | context.register(
|
| 144 | SULFUR_SPRING,
|
| 145 | new WeightedRandomSelectorFeature(
|
| 146 | WeightedList.of(
|
| 147 | new Weighted<>(
|
| 148 | PlacementUtils.inlinePlaced(
|
| 149 | new SequenceFeature(
|
| 150 | HolderSet.direct(
|
| 151 | tuffCover.apply(64, 7),
|
| 152 | sulfurSprings.apply(
|
| 153 | WeightedList.of(
|
| 154 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_small_1")),
|
| 155 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_small_2")),
|
| 156 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_small_3")),
|
| 157 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_small_4"))
|
| 158 | )
|
| 159 | )
|
| 160 | )
|
| 161 | )
|
| 162 | ),
|
| 163 | 200
|
| 164 | ),
|
| 165 | new Weighted<>(
|
| 166 | PlacementUtils.inlinePlaced(
|
| 167 | new SequenceFeature(
|
| 168 | HolderSet.direct(
|
| 169 | tuffCover.apply(80, 8),
|
| 170 | sulfurSprings.apply(
|
| 171 | WeightedList.of(
|
| 172 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_medium_1")),
|
| 173 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_medium_2")),
|
| 174 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_medium_3"))
|
| 175 | )
|
| 176 | )
|
| 177 | )
|
| 178 | )
|
| 179 | ),
|
| 180 | 90
|
| 181 | ),
|
| 182 | new Weighted<>(
|
| 183 | PlacementUtils.inlinePlaced(
|
| 184 | new SequenceFeature(
|
| 185 | HolderSet.direct(
|
| 186 | tuffCover.apply(96, 9),
|
| 187 | sulfurSprings.apply(
|
| 188 | WeightedList.of(
|
| 189 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_large_1")),
|
| 190 | TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_large_2"))
|
| 191 | )
|
| 192 | )
|
| 193 | )
|
| 194 | )
|
| 195 | ),
|
| 196 | 20
|
| 197 | ),
|
| 198 | new Weighted<>(
|
| 199 | PlacementUtils.inlinePlaced(
|
| 200 | new SequenceFeature(
|
| 201 | HolderSet.direct(
|
| 202 | tuffCover.apply(128, 10),
|
| 203 | sulfurSprings.apply(WeightedList.of(TemplateFeature.TemplateEntry.of(Identifier.withDefaultNamespace("spring/sulfur_spring_extra_large_1"))))
|
| 204 | )
|
| 205 | )
|
| 206 | ),
|
| 207 | 5
|
| 208 | )
|
| 209 | )
|
| 210 | )
|
| 211 | );
|
| 212 | context.register(
|
| 213 | DISK_CLAY, new DiskFeature(BlockStateProvider.holderOf(Blocks.CLAY), BlockPredicate.matchesBlocks(Blocks.DIRT, Blocks.CLAY), UniformInt.of(2, 3), 1)
|
| 214 | );
|
| 215 | context.register(
|
| 216 | DISK_GRAVEL,
|
| 217 | new DiskFeature(BlockStateProvider.holderOf(Blocks.GRAVEL), BlockPredicate.matchesBlocks(Blocks.DIRT, Blocks.GRASS_BLOCK), UniformInt.of(2, 5), 2)
|
| 218 | );
|
| 219 | context.register(
|
| 220 | DISK_SAND,
|
| 221 | new DiskFeature(
|
| 222 | Holder.direct(
|
| 223 | new RuleBasedStateProvider(
|
| 224 | BlockStateProvider.holderOf(Blocks.SAND),
|
| 225 | List.of(new RuleBasedStateProvider.Rule(BlockPredicate.matchesBlocks(Direction.DOWN, Blocks.AIR), BlockStateProvider.holderOf(Blocks.SANDSTONE)))
|
| 226 | )
|
| 227 | ),
|
| 228 | BlockPredicate.matchesBlocks(Blocks.DIRT, Blocks.GRASS_BLOCK),
|
| 229 | UniformInt.of(2, 6),
|
| 230 | 2
|
| 231 | )
|
| 232 | );
|
| 233 | context.register(FREEZE_TOP_LAYER, new SnowAndFreezeFeature());
|
| 234 | context.register(
|
| 235 | DISK_GRASS,
|
| 236 | new DiskFeature(
|
| 237 | Holder.direct(
|
| 238 | new RuleBasedStateProvider(
|
| 239 | BlockStateProvider.holderOf(Blocks.DIRT),
|
| 240 | List.of(
|
| 241 | new RuleBasedStateProvider.Rule(
|
| 242 | BlockPredicate.not(BlockPredicate.anyOf(BlockPredicate.solid(Direction.UP), BlockPredicate.matchesFluids(Direction.UP, Fluids.WATER))),
|
| 243 | BlockStateProvider.holderOf(Blocks.GRASS_BLOCK)
|
| 244 | )
|
| 245 | )
|
| 246 | )
|
| 247 | ),
|
| 248 | BlockPredicate.matchesBlocks(Blocks.DIRT, Blocks.MUD),
|
| 249 | UniformInt.of(2, 6),
|
| 250 | 2
|
| 251 | )
|
| 252 | );
|
| 253 | context.register(BONUS_CHEST, new BonusChestFeature());
|
| 254 | context.register(VOID_START_PLATFORM, new VoidStartPlatformFeature());
|
| 255 | StructureProcessorList wellSuspiciousSandProcessor = new StructureProcessorList(
|
| 256 | List.of(
|
| 257 | new RuleProcessor(
|
| 258 | List.of(
|
| 259 | new ProcessorRule(
|
| 260 | new BlockMatchTest(Blocks.SUSPICIOUS_SAND),
|
| 261 | AlwaysTrueTest.INSTANCE,
|
| 262 | PosAlwaysTrueTest.INSTANCE,
|
| 263 | Blocks.SUSPICIOUS_SAND.defaultBlockState(),
|
| 264 | new AppendLoot(BuiltInLootTables.DESERT_WELL_ARCHAEOLOGY)
|
| 265 | )
|
| 266 | )
|
| 267 | )
|
| 268 | )
|
| 269 | );
|
| 270 | context.register(
|
| 271 | DESERT_WELL,
|
| 272 | new OverlayFeature(
|
| 273 | HolderSet.direct(
|
| 274 | PlacementUtils.inlinePlaced(TemplateFeature.simple(Identifier.withDefaultNamespace("desert_well/well")), OffsetPlacement.of(0, -2, 0)),
|
| 275 | PlacementUtils.inlinePlaced(
|
| 276 | TemplateFeature.simple(Identifier.withDefaultNamespace("desert_well/suspicious_sand"), Holder.direct(wellSuspiciousSandProcessor)),
|
| 277 | new RandomlySelectedPlacement(
|
| 278 | OffsetPlacement.of(0, -1, 0), OffsetPlacement.of(-1, -1, 0), OffsetPlacement.of(0, -1, 1), OffsetPlacement.of(1, -1, 0), OffsetPlacement.of(0, -1, -1)
|
| 279 | )
|
| 280 | ),
|
| 281 | PlacementUtils.inlinePlaced(
|
| 282 | TemplateFeature.simple(Identifier.withDefaultNamespace("desert_well/suspicious_sand"), Holder.direct(wellSuspiciousSandProcessor)),
|
| 283 | new RandomlySelectedPlacement(
|
| 284 | OffsetPlacement.of(0, -2, 0), OffsetPlacement.of(-1, -2, 0), OffsetPlacement.of(0, -2, 1), OffsetPlacement.of(1, -2, 0), OffsetPlacement.of(0, -2, -1)
|
| 285 | )
|
| 286 | )
|
| 287 | )
|
| 288 | )
|
| 289 | );
|
| 290 | context.register(
|
| 291 | SPRING_LAVA_OVERWORLD,
|
| 292 | new SpringFeature(
|
| 293 | Fluids.LAVA.defaultFluidState(),
|
| 294 | true,
|
| 295 | 4,
|
| 296 | 1,
|
| 297 | HolderSet.direct(
|
| 298 | Block::builtInRegistryHolder, Blocks.STONE, Blocks.GRANITE, Blocks.DIORITE, Blocks.ANDESITE, Blocks.DEEPSLATE, Blocks.TUFF, Blocks.CALCITE, Blocks.DIRT
|
| 299 | )
|
| 300 | )
|
| 301 | );
|
| 302 | context.register(
|
| 303 | SPRING_LAVA_FROZEN,
|
| 304 | new SpringFeature(
|
| 305 | Fluids.LAVA.defaultFluidState(), true, 4, 1, HolderSet.direct(Block::builtInRegistryHolder, Blocks.SNOW_BLOCK, Blocks.POWDER_SNOW, Blocks.PACKED_ICE)
|
| 306 | )
|
| 307 | );
|
| 308 | context.register(
|
| 309 | SPRING_WATER,
|
| 310 | new SpringFeature(
|
| 311 | Fluids.WATER.defaultFluidState(),
|
| 312 | true,
|
| 313 | 4,
|
| 314 | 1,
|
| 315 | HolderSet.direct(
|
| 316 | Block::builtInRegistryHolder,
|
| 317 | Blocks.STONE,
|
| 318 | Blocks.GRANITE,
|
| 319 | Blocks.DIORITE,
|
| 320 | Blocks.ANDESITE,
|
| 321 | Blocks.DEEPSLATE,
|
| 322 | Blocks.TUFF,
|
| 323 | Blocks.CALCITE,
|
| 324 | Blocks.DIRT,
|
| 325 | Blocks.SNOW_BLOCK,
|
| 326 | Blocks.POWDER_SNOW,
|
| 327 | Blocks.PACKED_ICE
|
| 328 | )
|
| 329 | )
|
| 330 | );
|
| 331 | }
|
| 332 | }
|
| 333 |
|