tutorial:ores
This is an old revision of the document!
Table of Contents
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.
- Make a ConfiguredFeatures. This defines how your ore block is spawned.
- Use mixin to inject feature registration into DefaultBiomeFeature
We'll assume you've already created your own ore block at this point. Quartz Ore will serve as our replacement, and our goal will be spawning it in overworld biomes. Replace references to Quartz Ore with your ore when appropriate.
Making a ConfiguredFeatures
First we need to create a ConfiguredFeatures. Make sure to register your ConfiguredFeature at onInitialize
. Feel free to change the values to suit your mod.
public class ExampleMod implements ModInitializer { public static ConfiguredFeature<?, ?> ORE_QUARTZ_OVERWORLD = Feature.ORE .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); // number of veins per chunk @Override public void onInitialize() { Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("tutorial", "ore_quartz_overworld"), ORE_QUARTZ_OVERWORLD); } }
Injecting into DefaultBiomeFeature
This adds your ore to the overworld biomes.
@Mixin(DefaultBiomeFeatures.class) public class DefaultBiomeFeaturesMixin { @Inject(method = "addDefaultOres(Lnet/minecraft/world/biome/GenerationSettings$Builder;)V", at = @At("TAIL")) private static void addDefaultOres(GenerationSettings.Builder builder, CallbackInfo ci) { builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, ExampleMod.ORE_QUARTZ_OVERWORLD); } }
Conclusion
tutorial/ores.1598441106.txt.gz · Last modified: 2020/08/26 11:25 by siglong