tutorial:ores
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
tutorial:ores [2020/02/26 15:23] – Change to new format supercoder79 | tutorial:ores [2020/08/26 11:25] – Update to 1.16.2 siglong | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Adding Ores to the World ====== | ====== Adding Ores to the World ====== | ||
A lot of mods add their own ores, and you'll need a way to place them in existing biomes for players to find. In this tutorial, we'll look at adding ores to existing biomes and biomes added by other mods. There are 2 steps that are required to add ores to biomes. | A lot of mods add their own ores, and you'll need a way to place them in existing biomes for players to find. In this tutorial, we'll look at adding ores to existing biomes and biomes added by other mods. There are 2 steps that are required to add ores to biomes. | ||
- | * Iterate over the biome registry to add your ores to existing biomes. | + | * Make a ConfiguredFeatures. This defines how your ore block is spawned. |
- | * Use the RegistryEntryAddedCallback | + | * Use mixin to inject feature registration |
We'll assume you've already created your own ore block at this point. Quartz Ore will serve as our replacement, | We'll assume you've already created your own ore block at this point. Quartz Ore will serve as our replacement, | ||
- | ==== Adding ores to a biome ==== | + | ==== Making |
+ | First we need to create a ConfiguredFeatures. Make sure to register your ConfiguredFeature at '' | ||
- | First we need to create a method to process a biome, checking if it is a valid biome then adding the ore. | + | <code java [enable_line_numbers=" |
+ | public class ExampleMod implements ModInitializer { | ||
+ | public static ConfiguredFeature<? | ||
+ | .configure(new OreFeatureConfig( | ||
+ | OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, | ||
+ | Blocks.NETHER_QUARTZ_ORE.getDefaultState(), | ||
+ | 9)) // vein size | ||
+ | .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig( | ||
+ | 0, // bottom offset | ||
+ | 0, // min y level | ||
+ | 64))) // max y level | ||
+ | .spreadHorizontally() | ||
+ | .repeat(20); | ||
- | <code java [enable_line_numbers=" | + | @Override |
- | private | + | |
- | if(biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND) { | + | |
- | biome.addFeature( | + | } |
- | GenerationStep.Feature.UNDERGROUND_ORES, | + | |
- | Feature.ORE.configure( | + | |
- | new OreFeatureConfig( | + | |
- | OreFeatureConfig.Target.NATURAL_STONE, | + | |
- | Blocks.NETHER_QUARTZ_ORE.getDefaultState(), | + | |
- | 8 //Ore vein size | + | |
- | | + | |
- | Decorator.COUNT_RANGE.configure(new RangeDecoratorConfig( | + | |
- | 8, //Number of veins per chunk | + | |
- | 0, //Bottom Offset | + | |
- | 0, //Min y level | + | |
- | 64 //Max y level | + | |
- | )))); | + | |
- | } | + | |
} | } | ||
</ | </ | ||
- | This method adds your ore to the overworld, with the provided spawn settings. Feel free to change the values to suit your mod. | + | ==== Injecting into DefaultBiomeFeature |
- | + | This adds your ore to the overworld | |
- | ==== Iterating Biome Registry | + | |
- | + | ||
- | What we need to do next is process all biomes | + | |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
- | @Override | + | @Mixin(DefaultBiomeFeatures.class) |
- | public void onInitialize() { | + | public class DefaultBiomeFeaturesMixin |
- | //Loop over existing biomes | + | |
- | Registry.BIOME.forEach(this:: | + | |
- | + | builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, ExampleMod.ORE_QUARTZ_OVERWORLD); | |
- | //Listen for other biomes being registered | + | } |
- | RegistryEntryAddedCallback.event(Registry.BIOME).register((i, identifier, biome) -> handleBiome(biome)); | + | |
} | } | ||
</ | </ | ||
==== Conclusion ==== | ==== Conclusion ==== | ||
- | You should see quartz ore spawning in the overworld: | + | You should see quartz ore spawning in the overworld. You can use fill command to remove stone blocks surrounding you like this: ''/ |
- | + | ||
- | {{https:// | + | |
+ | {{tutorial: | ||
tutorial/ores.txt · Last modified: 2023/12/18 01:03 by solidblock