| 1 | package net.minecraft.data.worldgen.placement;
|
| 2 |
|
| 3 | import java.util.List;
|
| 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.OreFeatures;
|
| 9 | import net.minecraft.resources.ResourceKey;
|
| 10 | import net.minecraft.util.valueproviders.UniformInt;
|
| 11 | import net.minecraft.world.level.levelgen.VerticalAnchor;
|
| 12 | import net.minecraft.world.level.levelgen.feature.Feature;
|
| 13 | import net.minecraft.world.level.levelgen.placement.BiomeFilter;
|
| 14 | import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
| 15 | import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
|
| 16 | import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
|
| 17 | import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
| 18 | import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
| 19 | import net.minecraft.world.level.levelgen.placement.RarityFilter;
|
| 20 |
|
| 21 | public class OrePlacements {
|
| 22 | public static final ResourceKey<PlacedFeature> ORE_MAGMA = PlacementUtils.createKey("ore_magma");
|
| 23 | public static final ResourceKey<PlacedFeature> ORE_SOUL_SAND = PlacementUtils.createKey("ore_soul_sand");
|
| 24 | public static final ResourceKey<PlacedFeature> ORE_GOLD_DELTAS = PlacementUtils.createKey("ore_gold_deltas");
|
| 25 | public static final ResourceKey<PlacedFeature> ORE_QUARTZ_DELTAS = PlacementUtils.createKey("ore_quartz_deltas");
|
| 26 | public static final ResourceKey<PlacedFeature> ORE_GOLD_NETHER = PlacementUtils.createKey("ore_gold_nether");
|
| 27 | public static final ResourceKey<PlacedFeature> ORE_QUARTZ_NETHER = PlacementUtils.createKey("ore_quartz_nether");
|
| 28 | public static final ResourceKey<PlacedFeature> ORE_GRAVEL_NETHER = PlacementUtils.createKey("ore_gravel_nether");
|
| 29 | public static final ResourceKey<PlacedFeature> ORE_BLACKSTONE = PlacementUtils.createKey("ore_blackstone");
|
| 30 | public static final ResourceKey<PlacedFeature> ORE_DIRT = PlacementUtils.createKey("ore_dirt");
|
| 31 | public static final ResourceKey<PlacedFeature> ORE_GRAVEL = PlacementUtils.createKey("ore_gravel");
|
| 32 | public static final ResourceKey<PlacedFeature> ORE_GRANITE_UPPER = PlacementUtils.createKey("ore_granite_upper");
|
| 33 | public static final ResourceKey<PlacedFeature> ORE_GRANITE_LOWER = PlacementUtils.createKey("ore_granite_lower");
|
| 34 | public static final ResourceKey<PlacedFeature> ORE_DIORITE_UPPER = PlacementUtils.createKey("ore_diorite_upper");
|
| 35 | public static final ResourceKey<PlacedFeature> ORE_DIORITE_LOWER = PlacementUtils.createKey("ore_diorite_lower");
|
| 36 | public static final ResourceKey<PlacedFeature> ORE_ANDESITE_UPPER = PlacementUtils.createKey("ore_andesite_upper");
|
| 37 | public static final ResourceKey<PlacedFeature> ORE_ANDESITE_LOWER = PlacementUtils.createKey("ore_andesite_lower");
|
| 38 | public static final ResourceKey<PlacedFeature> ORE_TUFF = PlacementUtils.createKey("ore_tuff");
|
| 39 | public static final ResourceKey<PlacedFeature> ORE_COAL_UPPER = PlacementUtils.createKey("ore_coal_upper");
|
| 40 | public static final ResourceKey<PlacedFeature> ORE_COAL_LOWER = PlacementUtils.createKey("ore_coal_lower");
|
| 41 | public static final ResourceKey<PlacedFeature> ORE_IRON_UPPER = PlacementUtils.createKey("ore_iron_upper");
|
| 42 | public static final ResourceKey<PlacedFeature> ORE_IRON_MIDDLE = PlacementUtils.createKey("ore_iron_middle");
|
| 43 | public static final ResourceKey<PlacedFeature> ORE_IRON_SMALL = PlacementUtils.createKey("ore_iron_small");
|
| 44 | public static final ResourceKey<PlacedFeature> ORE_GOLD_EXTRA = PlacementUtils.createKey("ore_gold_extra");
|
| 45 | public static final ResourceKey<PlacedFeature> ORE_GOLD = PlacementUtils.createKey("ore_gold");
|
| 46 | public static final ResourceKey<PlacedFeature> ORE_GOLD_LOWER = PlacementUtils.createKey("ore_gold_lower");
|
| 47 | public static final ResourceKey<PlacedFeature> ORE_REDSTONE = PlacementUtils.createKey("ore_redstone");
|
| 48 | public static final ResourceKey<PlacedFeature> ORE_REDSTONE_LOWER = PlacementUtils.createKey("ore_redstone_lower");
|
| 49 | public static final ResourceKey<PlacedFeature> ORE_DIAMOND = PlacementUtils.createKey("ore_diamond");
|
| 50 | public static final ResourceKey<PlacedFeature> ORE_DIAMOND_MEDIUM = PlacementUtils.createKey("ore_diamond_medium");
|
| 51 | public static final ResourceKey<PlacedFeature> ORE_DIAMOND_LARGE = PlacementUtils.createKey("ore_diamond_large");
|
| 52 | public static final ResourceKey<PlacedFeature> ORE_DIAMOND_BURIED = PlacementUtils.createKey("ore_diamond_buried");
|
| 53 | public static final ResourceKey<PlacedFeature> ORE_LAPIS = PlacementUtils.createKey("ore_lapis");
|
| 54 | public static final ResourceKey<PlacedFeature> ORE_LAPIS_BURIED = PlacementUtils.createKey("ore_lapis_buried");
|
| 55 | public static final ResourceKey<PlacedFeature> ORE_INFESTED = PlacementUtils.createKey("ore_infested");
|
| 56 | public static final ResourceKey<PlacedFeature> ORE_EMERALD = PlacementUtils.createKey("ore_emerald");
|
| 57 | public static final ResourceKey<PlacedFeature> ORE_ANCIENT_DEBRIS_LARGE = PlacementUtils.createKey("ore_ancient_debris_large");
|
| 58 | public static final ResourceKey<PlacedFeature> ORE_ANCIENT_DEBRIS_SMALL = PlacementUtils.createKey("ore_debris_small");
|
| 59 | public static final ResourceKey<PlacedFeature> ORE_COPPER = PlacementUtils.createKey("ore_copper");
|
| 60 | public static final ResourceKey<PlacedFeature> ORE_COPPER_LARGE = PlacementUtils.createKey("ore_copper_large");
|
| 61 | public static final ResourceKey<PlacedFeature> ORE_CLAY = PlacementUtils.createKey("ore_clay");
|
| 62 |
|
| 63 | private static List<PlacementModifier> orePlacement(final PlacementModifier frequencyModifier, final PlacementModifier heightRange) {
|
| 64 | return List.of(frequencyModifier, InSquarePlacement.spread(), heightRange, BiomeFilter.biome());
|
| 65 | }
|
| 66 |
|
| 67 | private static List<PlacementModifier> commonOrePlacement(final int count, final PlacementModifier heightRange) {
|
| 68 | return orePlacement(CountPlacement.of(count), heightRange);
|
| 69 | }
|
| 70 |
|
| 71 | private static List<PlacementModifier> rareOrePlacement(final int rarity, final PlacementModifier heightRange) {
|
| 72 | return orePlacement(RarityFilter.onAverageOnceEvery(rarity), heightRange);
|
| 73 | }
|
| 74 |
|
| 75 | public static void bootstrap(final BootstrapContext<PlacedFeature> context) {
|
| 76 | HolderGetter<Feature> configuredFeatures = context.lookup(Registries.FEATURE);
|
| 77 | Holder<Feature> oreMagma = configuredFeatures.getOrThrow(OreFeatures.ORE_MAGMA);
|
| 78 | Holder<Feature> oreSoulSand = configuredFeatures.getOrThrow(OreFeatures.ORE_SOUL_SAND);
|
| 79 | Holder<Feature> oreNetherGold = configuredFeatures.getOrThrow(OreFeatures.ORE_NETHER_GOLD);
|
| 80 | Holder<Feature> oreQuartz = configuredFeatures.getOrThrow(OreFeatures.ORE_QUARTZ);
|
| 81 | Holder<Feature> oreGravelNether = configuredFeatures.getOrThrow(OreFeatures.ORE_GRAVEL_NETHER);
|
| 82 | Holder<Feature> oreBlackstone = configuredFeatures.getOrThrow(OreFeatures.ORE_BLACKSTONE);
|
| 83 | Holder<Feature> oreDirt = configuredFeatures.getOrThrow(OreFeatures.ORE_DIRT);
|
| 84 | Holder<Feature> oreGravel = configuredFeatures.getOrThrow(OreFeatures.ORE_GRAVEL);
|
| 85 | Holder<Feature> oreGranite = configuredFeatures.getOrThrow(OreFeatures.ORE_GRANITE);
|
| 86 | Holder<Feature> oreDiorite = configuredFeatures.getOrThrow(OreFeatures.ORE_DIORITE);
|
| 87 | Holder<Feature> oreAndesite = configuredFeatures.getOrThrow(OreFeatures.ORE_ANDESITE);
|
| 88 | Holder<Feature> oreTuff = configuredFeatures.getOrThrow(OreFeatures.ORE_TUFF);
|
| 89 | Holder<Feature> oreCoal = configuredFeatures.getOrThrow(OreFeatures.ORE_COAL);
|
| 90 | Holder<Feature> oreCoalBuried = configuredFeatures.getOrThrow(OreFeatures.ORE_COAL_BURIED);
|
| 91 | Holder<Feature> oreIron = configuredFeatures.getOrThrow(OreFeatures.ORE_IRON);
|
| 92 | Holder<Feature> oreIronSmall = configuredFeatures.getOrThrow(OreFeatures.ORE_IRON_SMALL);
|
| 93 | Holder<Feature> oreGold = configuredFeatures.getOrThrow(OreFeatures.ORE_GOLD);
|
| 94 | Holder<Feature> oreGoldBuried = configuredFeatures.getOrThrow(OreFeatures.ORE_GOLD_BURIED);
|
| 95 | Holder<Feature> oreRedstone = configuredFeatures.getOrThrow(OreFeatures.ORE_REDSTONE);
|
| 96 | Holder<Feature> oreDiamondSmall = configuredFeatures.getOrThrow(OreFeatures.ORE_DIAMOND_SMALL);
|
| 97 | Holder<Feature> oreDiamondMedium = configuredFeatures.getOrThrow(OreFeatures.ORE_DIAMOND_MEDIUM);
|
| 98 | Holder<Feature> oreDiamondLarge = configuredFeatures.getOrThrow(OreFeatures.ORE_DIAMOND_LARGE);
|
| 99 | Holder<Feature> oreDiamondBuried = configuredFeatures.getOrThrow(OreFeatures.ORE_DIAMOND_BURIED);
|
| 100 | Holder<Feature> oreLapis = configuredFeatures.getOrThrow(OreFeatures.ORE_LAPIS);
|
| 101 | Holder<Feature> oreLapisBuried = configuredFeatures.getOrThrow(OreFeatures.ORE_LAPIS_BURIED);
|
| 102 | Holder<Feature> oreInfested = configuredFeatures.getOrThrow(OreFeatures.ORE_INFESTED);
|
| 103 | Holder<Feature> oreEmerald = configuredFeatures.getOrThrow(OreFeatures.ORE_EMERALD);
|
| 104 | Holder<Feature> oreAncientDebrisLarge = configuredFeatures.getOrThrow(OreFeatures.ORE_ANCIENT_DEBRIS_LARGE);
|
| 105 | Holder<Feature> oreAncientDebrisSmall = configuredFeatures.getOrThrow(OreFeatures.ORE_ANCIENT_DEBRIS_SMALL);
|
| 106 | Holder<Feature> oreCoppperSmall = configuredFeatures.getOrThrow(OreFeatures.ORE_COPPPER_SMALL);
|
| 107 | Holder<Feature> oreCopperLarge = configuredFeatures.getOrThrow(OreFeatures.ORE_COPPER_LARGE);
|
| 108 | Holder<Feature> oreClay = configuredFeatures.getOrThrow(OreFeatures.ORE_CLAY);
|
| 109 | PlacementUtils.register(
|
| 110 | context, ORE_MAGMA, oreMagma, commonOrePlacement(4, HeightRangePlacement.uniform(VerticalAnchor.absolute(27), VerticalAnchor.absolute(36)))
|
| 111 | );
|
| 112 | PlacementUtils.register(
|
| 113 | context, ORE_SOUL_SAND, oreSoulSand, commonOrePlacement(12, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(31)))
|
| 114 | );
|
| 115 | PlacementUtils.register(context, ORE_GOLD_DELTAS, oreNetherGold, commonOrePlacement(20, PlacementUtils.RANGE_10_10));
|
| 116 | PlacementUtils.register(context, ORE_QUARTZ_DELTAS, oreQuartz, commonOrePlacement(32, PlacementUtils.RANGE_10_10));
|
| 117 | PlacementUtils.register(context, ORE_GOLD_NETHER, oreNetherGold, commonOrePlacement(10, PlacementUtils.RANGE_10_10));
|
| 118 | PlacementUtils.register(context, ORE_QUARTZ_NETHER, oreQuartz, commonOrePlacement(16, PlacementUtils.RANGE_10_10));
|
| 119 | PlacementUtils.register(
|
| 120 | context, ORE_GRAVEL_NETHER, oreGravelNether, commonOrePlacement(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(5), VerticalAnchor.absolute(41)))
|
| 121 | );
|
| 122 | PlacementUtils.register(
|
| 123 | context, ORE_BLACKSTONE, oreBlackstone, commonOrePlacement(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(5), VerticalAnchor.absolute(31)))
|
| 124 | );
|
| 125 | PlacementUtils.register(
|
| 126 | context, ORE_DIRT, oreDirt, commonOrePlacement(7, HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.absolute(160)))
|
| 127 | );
|
| 128 | PlacementUtils.register(context, ORE_GRAVEL, oreGravel, commonOrePlacement(14, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.top())));
|
| 129 | PlacementUtils.register(
|
| 130 | context, ORE_GRANITE_UPPER, oreGranite, rareOrePlacement(6, HeightRangePlacement.uniform(VerticalAnchor.absolute(64), VerticalAnchor.absolute(128)))
|
| 131 | );
|
| 132 | PlacementUtils.register(
|
| 133 | context, ORE_GRANITE_LOWER, oreGranite, commonOrePlacement(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.absolute(60)))
|
| 134 | );
|
| 135 | PlacementUtils.register(
|
| 136 | context, ORE_DIORITE_UPPER, oreDiorite, rareOrePlacement(6, HeightRangePlacement.uniform(VerticalAnchor.absolute(64), VerticalAnchor.absolute(128)))
|
| 137 | );
|
| 138 | PlacementUtils.register(
|
| 139 | context, ORE_DIORITE_LOWER, oreDiorite, commonOrePlacement(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.absolute(60)))
|
| 140 | );
|
| 141 | PlacementUtils.register(
|
| 142 | context, ORE_ANDESITE_UPPER, oreAndesite, rareOrePlacement(6, HeightRangePlacement.uniform(VerticalAnchor.absolute(64), VerticalAnchor.absolute(128)))
|
| 143 | );
|
| 144 | PlacementUtils.register(
|
| 145 | context, ORE_ANDESITE_LOWER, oreAndesite, commonOrePlacement(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.absolute(60)))
|
| 146 | );
|
| 147 | PlacementUtils.register(context, ORE_TUFF, oreTuff, commonOrePlacement(2, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(0))));
|
| 148 | PlacementUtils.register(
|
| 149 | context, ORE_COAL_UPPER, oreCoal, commonOrePlacement(30, HeightRangePlacement.uniform(VerticalAnchor.absolute(136), VerticalAnchor.top()))
|
| 150 | );
|
| 151 | PlacementUtils.register(
|
| 152 | context, ORE_COAL_LOWER, oreCoalBuried, commonOrePlacement(20, HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(192)))
|
| 153 | );
|
| 154 | PlacementUtils.register(
|
| 155 | context, ORE_IRON_UPPER, oreIron, commonOrePlacement(90, HeightRangePlacement.triangle(VerticalAnchor.absolute(80), VerticalAnchor.absolute(384)))
|
| 156 | );
|
| 157 | PlacementUtils.register(
|
| 158 | context, ORE_IRON_MIDDLE, oreIron, commonOrePlacement(10, HeightRangePlacement.triangle(VerticalAnchor.absolute(-24), VerticalAnchor.absolute(56)))
|
| 159 | );
|
| 160 | PlacementUtils.register(
|
| 161 | context, ORE_IRON_SMALL, oreIronSmall, commonOrePlacement(10, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(72)))
|
| 162 | );
|
| 163 | PlacementUtils.register(
|
| 164 | context, ORE_GOLD_EXTRA, oreGold, commonOrePlacement(50, HeightRangePlacement.uniform(VerticalAnchor.absolute(32), VerticalAnchor.absolute(256)))
|
| 165 | );
|
| 166 | PlacementUtils.register(
|
| 167 | context, ORE_GOLD, oreGoldBuried, commonOrePlacement(4, HeightRangePlacement.triangle(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(32)))
|
| 168 | );
|
| 169 | PlacementUtils.register(
|
| 170 | context,
|
| 171 | ORE_GOLD_LOWER,
|
| 172 | oreGoldBuried,
|
| 173 | orePlacement(CountPlacement.of(UniformInt.of(0, 1)), HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(-48)))
|
| 174 | );
|
| 175 | PlacementUtils.register(
|
| 176 | context, ORE_REDSTONE, oreRedstone, commonOrePlacement(4, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(15)))
|
| 177 | );
|
| 178 | PlacementUtils.register(
|
| 179 | context,
|
| 180 | ORE_REDSTONE_LOWER,
|
| 181 | oreRedstone,
|
| 182 | commonOrePlacement(8, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-32), VerticalAnchor.aboveBottom(32)))
|
| 183 | );
|
| 184 | PlacementUtils.register(
|
| 185 | context, ORE_DIAMOND, oreDiamondSmall, commonOrePlacement(7, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-80), VerticalAnchor.aboveBottom(80)))
|
| 186 | );
|
| 187 | PlacementUtils.register(
|
| 188 | context,
|
| 189 | ORE_DIAMOND_MEDIUM,
|
| 190 | oreDiamondMedium,
|
| 191 | commonOrePlacement(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(-4)))
|
| 192 | );
|
| 193 | PlacementUtils.register(
|
| 194 | context,
|
| 195 | ORE_DIAMOND_LARGE,
|
| 196 | oreDiamondLarge,
|
| 197 | rareOrePlacement(9, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-80), VerticalAnchor.aboveBottom(80)))
|
| 198 | );
|
| 199 | PlacementUtils.register(
|
| 200 | context,
|
| 201 | ORE_DIAMOND_BURIED,
|
| 202 | oreDiamondBuried,
|
| 203 | commonOrePlacement(4, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-80), VerticalAnchor.aboveBottom(80)))
|
| 204 | );
|
| 205 | PlacementUtils.register(
|
| 206 | context, ORE_LAPIS, oreLapis, commonOrePlacement(2, HeightRangePlacement.triangle(VerticalAnchor.absolute(-32), VerticalAnchor.absolute(32)))
|
| 207 | );
|
| 208 | PlacementUtils.register(
|
| 209 | context, ORE_LAPIS_BURIED, oreLapisBuried, commonOrePlacement(4, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(64)))
|
| 210 | );
|
| 211 | PlacementUtils.register(
|
| 212 | context, ORE_INFESTED, oreInfested, commonOrePlacement(14, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(63)))
|
| 213 | );
|
| 214 | PlacementUtils.register(
|
| 215 | context, ORE_EMERALD, oreEmerald, commonOrePlacement(100, HeightRangePlacement.triangle(VerticalAnchor.absolute(-16), VerticalAnchor.absolute(480)))
|
| 216 | );
|
| 217 | PlacementUtils.register(
|
| 218 | context,
|
| 219 | ORE_ANCIENT_DEBRIS_LARGE,
|
| 220 | oreAncientDebrisLarge,
|
| 221 | InSquarePlacement.spread(),
|
| 222 | HeightRangePlacement.triangle(VerticalAnchor.absolute(8), VerticalAnchor.absolute(24)),
|
| 223 | BiomeFilter.biome()
|
| 224 | );
|
| 225 | PlacementUtils.register(context, ORE_ANCIENT_DEBRIS_SMALL, oreAncientDebrisSmall, InSquarePlacement.spread(), PlacementUtils.RANGE_8_8, BiomeFilter.biome());
|
| 226 | PlacementUtils.register(
|
| 227 | context, ORE_COPPER, oreCoppperSmall, commonOrePlacement(16, HeightRangePlacement.triangle(VerticalAnchor.absolute(-16), VerticalAnchor.absolute(112)))
|
| 228 | );
|
| 229 | PlacementUtils.register(
|
| 230 | context, ORE_COPPER_LARGE, oreCopperLarge, commonOrePlacement(16, HeightRangePlacement.triangle(VerticalAnchor.absolute(-16), VerticalAnchor.absolute(112)))
|
| 231 | );
|
| 232 | PlacementUtils.register(context, ORE_CLAY, oreClay, commonOrePlacement(46, PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT));
|
| 233 | }
|
| 234 | }
|
| 235 |
|