==========================
Creating Ores From Scratch
==========================
This guide will continue the process of creating a new Terra config
pack from the beginning with creating ores.
If you haven't already, please read the
:doc:`Config Development Introduction ` &
:doc:`Creating A Pack From Scratch `
for more information before continuing.
If you're stuck or need an example, you can find reference config packs for this guide on the
`GitHub repo `_\.
Setting up Ores
===============
`PROCEDURE`
1. Create an abstract ore config
--------------------------------
.. card::
An ore config file will allow you configure ores that will generate in your world.
Open your pack manifest in your :ref:`editor of choice `.
Add the ``config-ore`` addon as a dependency, using versions ``1.+``.
This addon will allow us to create palette config files.
.. code-block:: yaml
:caption: pack.yml
:linenos:
:emphasize-lines: 6
id: YOUR_PACK_ID
version: 0.9.0
addons:
...
config-ore: "1.+"
An abstract ore config file will be necessary for ore configs to inherit from and easily configure.
:ref:`Create a blank config file ` with the file name ``abstract_ore.yml``.
Set the :ref:`config type ` via the ``type``
:ref:`parameter `, config ``id``, and ``abstract``` as shown below.
.. code-block:: yaml
:caption: abstract_ore.yml
:linenos:
id: ABSTRACT_ORE
type: ORE
abstract: true
Add the highlighted lines to add the ``replace`` parameter.
.. code-block:: yaml
:caption: abstract_ore.yml
:linenos:
:emphasize-lines: 5-7
id: ABSTRACT_ORE
type: ORE
abstract: true
replace:
- minecraft:stone
- minecraft:deepslate
The ``abstract`` parameter with a value of true will allow this abstract config to not have the mandatory
parameters required for an ore config file.
The ``replace`` parameter consists a block or list of blocks that the ore config will be able to
replace, which is stone and deepslate in this case.
2. Create an ore config file
----------------------------
.. card::
With an abstract ore config prepared, an ore config can now be created to inherit those abstract parameters.
:ref:`Create a blank config file ` with the file name ``coal_ore.yml``.
Set the :ref:`config type ` via the ``type``
:ref:`parameter `, config ``id``, and ``extends`` as shown below.
.. code-block:: yaml
:caption: coal_ore.yml
:linenos:
id: COAL_ORE
type: ORE
extends: ABSTRACT_ORE
Add the highlighted lines to set the ``material``, ``material-overrides``, and ``size``.
.. code-block:: yaml
:caption: coal_ore.yml
:linenos:
:emphasize-lines: 5-10
id: COAL_ORE
type: ORE
extends: ABSTRACT_ORE
material: minecraft:coal_ore
material-overrides:
minecraft:deepslate: minecraft:deepslate_coal_ore
size: 10
``COAL_ORE`` will extend ``ABSTRACT_ORE`` in order to be able to replace stone and deepslate blocks.
``material`` determines the block that this ore config will place, which will be coal ore.
``material-overrides`` determines different blocks to be placed if specified blocks are replaced by the ore.
In this case, a deepslate block getting replaced results in deepslate coal ore being placed
instead of regular coal ore.
``size`` determines the size of the ore vein that will generate.
3. Add ore feature config file
------------------------------
.. card::
With an ore config file created, a feature config file will be needed in order to place that ore as a feature in
a generation stage.
:ref:`Create a blank config file ` with the file name ``coal_ore_feature.yml``.
Set the :ref:`config type ` via the ``type``
:ref:`parameter `, and config ``id`` as shown below.
.. code-block:: yaml
:caption: coal_ore_feature.yml
:linenos:
id: COAL_ORE_FEATURE
type: FEATURE
Add the highlighted lines to set the :doc:`distributor `,
:doc:`locator `, and structure.
.. code-block:: yaml
:caption: coal_ore_feature.yml
:linenos:
:emphasize-lines: 4-24
id: COAL_ORE_FEATURE
type: FEATURE
distributor:
type: SAMPLER
sampler:
type: POSITIVE_WHITE_NOISE
salt: 1234
threshold: 10 * (1/256)
#averageCountPerChunk Divide by 16^2 to get % per column
locator:
type: GAUSSIAN_RANDOM
amount: 1
height:
min: -64
max: 192
standard-deviation: (192-(-64))/6
# Divide distance from min to max by 6 to fit 3 standard deviations
structures:
distribution:
type: CONSTANT
structures: COAL_ORE
The feature config for this ore is set up and configurable to best resemble ore generation.
The :doc:`distributor ` threshold utilizes a number that represents the average ore count per chunk, which proceeds
to get divided by 256.
The :doc:`locator ` utilizes ``GAUSSIAN_RANDOM`` with a standard deviation that adds the max and min range values, which get
get divided by 6 in order to fit 3 standard deviations (~99.7% of results) within the range. Furthermore, ore
generation results are higher towards the middle of the range.
The ``structures.structures`` is set to use the ``COAL_ORE`` :doc:`ORE ` config that was created
a step prior.
.. note::
A uniform ore distribution generates ore with equal chance across the entire range rather than more towards the
middle of the range with a normal distribution.
A uniform ore distribution will use the locator shown below.
.. code-block:: yaml
:caption: coal_ore_uniform.yml
:linenos:
locator:
type: RANDOM
amount: 1
height:
min: -64
max: 192
salt: 1234
4. Add ores feature stage
-------------------------
.. card::
We will now utilize the ``generation-stage-feature`` addon that was added in
:doc:`Setting up a New Feature ` to add a new generation stage for ores.
Open your pack manifest in your :ref:`editor of choice `.
Add the following lines to add a generation stage for ores.
.. code-block:: yaml
:caption: pack.yml
:linenos:
:emphasize-lines: 9-10
id: YOUR_PACK_ID
...
stages:
- id: preprocessors
type: FEATURE
- id: ores
type: FEATURE
- id: flora
type: FEATURE
- id: trees
type: FEATURE
The ``ores`` generation stage can now generate ores as features and be kept separate from other features.
5. Create an abstract ore biome config
--------------------------------------
.. card::
Instead of adding ``COAL_ORE`` to every individual biome config, an abstract biome config can be extended
by biomes for them to inherit the ore feature generation.
This eases the config development process down the line especially as more biomes and ores get added to
the config pack without having to individually update every config file.
:ref:`Create a blank config file ` with the file name ``ores_default.yml``.
Set the :ref:`config type ` via the ``type``
:ref:`parameter `, config ``id``, and abstract as shown below.
.. code-block:: yaml
:caption: ores_default.yml
:linenos:
id: ORES_DEFAULT
type: BIOME
abstract: true
Add the highlighted lines to add ore feature generation to ``ORES_DEFAULT``.
.. code-block:: yaml
:caption: ores_default.yml
:linenos:
:emphasize-lines: 5-7
id: ORES_DEFAULT
type: BIOME
abstract: true
features:
ores:
- COAL_ORE_FEATURE
``ORES_DEFAULT`` allows for the ores generation stage to be configured in one config, which can be extended to
biomes that will generate ores.
6. Extend abstract ore biome config
-----------------------------------
.. card::
Biome configs can now extend ``ORES_DEFAULT`` in order to inherit and generate ore features.
While you could extend ``ORES_DEFAULT`` to each biome individually, you already have an abstract ``BASE`` config
that is extended to each biome.
With that in mind, you can simply extend ``ORES_DEFAULT`` through ``BASE`` to allow those biomes that extend ``BASE``
to inherit ore generation with ease.
Open your ``BASE`` config in your :ref:`editor of choice `.
Add the following line to extend ``ORES_DEFAULT`` to the ``BASE`` config.
.. code-block:: yaml
:caption: base.yml
:linenos:
:emphasize-lines: 4
id: BASE
type: BIOME
abstract: true
extends: ORES_DEFAULT
ocean:
palette: BLOCK:minecraft:water
level: 62
features:
preprocessors:
- CONTAIN_FLOATING_WATER
``ORES_DEFAULT`` should now be extended to all biome configs that extend ``BASE`` and generate ``COAL_ORE_FEATURE``.
7. Load your pack
-----------------
At this stage, your pack should now be capable of generating ores! You can load up your pack by starting your
development client / server which contains the pack you have just defined. You can confirm that your pack has loaded
if the pack id (as specified in the pack manifest) appears when using the ``/packs`` command, or in your console
when starting the server / client up.
If for whatever reason your pack does not load, an error message will show up in console explaining why the pack
has failed to load, please read through any of these errors and try to interpret what you may have done wrong,
and follow through the previous steps again carefully.
If you still are unable to load the pack, feel free to :doc:`contact us ` with any relevant errors.
Conclusion
==========
Now that you've verified your pack has loaded correctly, you can
now generate a world with ores!
Reference configurations for this guide can be found on GitHub
`here `_.
.. image:: /img/config/development/pack-from-scratch/ores.png