| 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.PileFeatures;
|
| 9 | import net.minecraft.data.worldgen.features.TreeFeatures;
|
| 10 | import net.minecraft.data.worldgen.features.VegetationFeatures;
|
| 11 | import net.minecraft.resources.ResourceKey;
|
| 12 | import net.minecraft.world.level.block.Blocks;
|
| 13 | import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
| 14 | import net.minecraft.world.level.levelgen.feature.Feature;
|
| 15 | import net.minecraft.world.level.levelgen.placement.BlockPredicateFilter;
|
| 16 | import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
| 17 | import net.minecraft.world.level.levelgen.placement.OffsetPlacement;
|
| 18 | import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
| 19 |
|
| 20 | public class VillagePlacements {
|
| 21 | public static final ResourceKey<PlacedFeature> PILE_HAY_VILLAGE = PlacementUtils.createKey("pile_hay");
|
| 22 | public static final ResourceKey<PlacedFeature> PILE_MELON_VILLAGE = PlacementUtils.createKey("pile_melon");
|
| 23 | public static final ResourceKey<PlacedFeature> PILE_SNOW_VILLAGE = PlacementUtils.createKey("pile_snow");
|
| 24 | public static final ResourceKey<PlacedFeature> PILE_ICE_VILLAGE = PlacementUtils.createKey("pile_ice");
|
| 25 | public static final ResourceKey<PlacedFeature> PILE_PUMPKIN_VILLAGE = PlacementUtils.createKey("pile_pumpkin");
|
| 26 | public static final ResourceKey<PlacedFeature> OAK_VILLAGE = PlacementUtils.createKey("oak");
|
| 27 | public static final ResourceKey<PlacedFeature> ACACIA_VILLAGE = PlacementUtils.createKey("acacia");
|
| 28 | public static final ResourceKey<PlacedFeature> SPRUCE_VILLAGE = PlacementUtils.createKey("spruce");
|
| 29 | public static final ResourceKey<PlacedFeature> PINE_VILLAGE = PlacementUtils.createKey("pine");
|
| 30 | public static final ResourceKey<PlacedFeature> PATCH_CACTUS_VILLAGE = PlacementUtils.createKey("patch_cactus");
|
| 31 | public static final ResourceKey<PlacedFeature> FLOWER_PLAIN_VILLAGE = PlacementUtils.createKey("flower_plain");
|
| 32 | public static final ResourceKey<PlacedFeature> PATCH_TAIGA_GRASS_VILLAGE = PlacementUtils.createKey("patch_taiga_grass");
|
| 33 | public static final ResourceKey<PlacedFeature> PATCH_BERRY_BUSH_VILLAGE = PlacementUtils.createKey("patch_berry_bush");
|
| 34 |
|
| 35 | public static void bootstrap(final BootstrapContext<PlacedFeature> context) {
|
| 36 | HolderGetter<Feature> configuredFeatures = context.lookup(Registries.FEATURE);
|
| 37 | Holder<Feature> pileHay = configuredFeatures.getOrThrow(PileFeatures.PILE_HAY);
|
| 38 | Holder<Feature> pileMelon = configuredFeatures.getOrThrow(PileFeatures.PILE_MELON);
|
| 39 | Holder<Feature> pileSnow = configuredFeatures.getOrThrow(PileFeatures.PILE_SNOW);
|
| 40 | Holder<Feature> pileIce = configuredFeatures.getOrThrow(PileFeatures.PILE_ICE);
|
| 41 | Holder<Feature> pilePumpkin = configuredFeatures.getOrThrow(PileFeatures.PILE_PUMPKIN);
|
| 42 | Holder<Feature> oak = configuredFeatures.getOrThrow(TreeFeatures.OAK);
|
| 43 | Holder<Feature> acacia = configuredFeatures.getOrThrow(TreeFeatures.ACACIA);
|
| 44 | Holder<Feature> spruce = configuredFeatures.getOrThrow(TreeFeatures.SPRUCE);
|
| 45 | Holder<Feature> pine = configuredFeatures.getOrThrow(TreeFeatures.PINE);
|
| 46 | Holder<Feature> cactus = configuredFeatures.getOrThrow(VegetationFeatures.CACTUS);
|
| 47 | Holder<Feature> flowerPlain = configuredFeatures.getOrThrow(VegetationFeatures.FLOWER_PLAIN);
|
| 48 | Holder<Feature> taigaGrass = configuredFeatures.getOrThrow(VegetationFeatures.TAIGA_GRASS);
|
| 49 | Holder<Feature> berryBush = configuredFeatures.getOrThrow(VegetationFeatures.BERRY_BUSH);
|
| 50 | PlacementUtils.register(context, PILE_HAY_VILLAGE, pileHay);
|
| 51 | PlacementUtils.register(context, PILE_MELON_VILLAGE, pileMelon);
|
| 52 | PlacementUtils.register(context, PILE_SNOW_VILLAGE, pileSnow);
|
| 53 | PlacementUtils.register(context, PILE_ICE_VILLAGE, pileIce);
|
| 54 | PlacementUtils.register(context, PILE_PUMPKIN_VILLAGE, pilePumpkin);
|
| 55 | PlacementUtils.register(context, OAK_VILLAGE, oak, PlacementUtils.filteredByBlockSurvival(Blocks.OAK_SAPLING));
|
| 56 | PlacementUtils.register(context, ACACIA_VILLAGE, acacia, PlacementUtils.filteredByBlockSurvival(Blocks.ACACIA_SAPLING));
|
| 57 | PlacementUtils.register(context, SPRUCE_VILLAGE, spruce, PlacementUtils.filteredByBlockSurvival(Blocks.SPRUCE_SAPLING));
|
| 58 | PlacementUtils.register(context, PINE_VILLAGE, pine, PlacementUtils.filteredByBlockSurvival(Blocks.SPRUCE_SAPLING));
|
| 59 | PlacementUtils.register(
|
| 60 | context,
|
| 61 | PATCH_CACTUS_VILLAGE,
|
| 62 | cactus,
|
| 63 | CountPlacement.of(10),
|
| 64 | OffsetPlacement.ofTriangle(7, 3),
|
| 65 | BlockPredicateFilter.forPredicate(BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.wouldSurvive(Blocks.CACTUS)))
|
| 66 | );
|
| 67 | PlacementUtils.register(
|
| 68 | context,
|
| 69 | FLOWER_PLAIN_VILLAGE,
|
| 70 | flowerPlain,
|
| 71 | CountPlacement.of(64),
|
| 72 | OffsetPlacement.ofTriangle(6, 2),
|
| 73 | BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE)
|
| 74 | );
|
| 75 | PlacementUtils.register(
|
| 76 | context,
|
| 77 | PATCH_TAIGA_GRASS_VILLAGE,
|
| 78 | taigaGrass,
|
| 79 | CountPlacement.of(32),
|
| 80 | OffsetPlacement.ofTriangle(7, 3),
|
| 81 | BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE)
|
| 82 | );
|
| 83 | PlacementUtils.register(
|
| 84 | context,
|
| 85 | PATCH_BERRY_BUSH_VILLAGE,
|
| 86 | berryBush,
|
| 87 | CountPlacement.of(96),
|
| 88 | OffsetPlacement.ofTriangle(7, 3),
|
| 89 | BlockPredicateFilter.forPredicate(
|
| 90 | BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.DOWN, Blocks.GRASS_BLOCK))
|
| 91 | )
|
| 92 | );
|
| 93 | }
|
| 94 | }
|
| 95 |
|