Skip to content

Commit

Permalink
Ore Features Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
UselessBullets committed Nov 10, 2023
1 parent 29e0f3d commit a93469f
Showing 1 changed file with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,54 @@ public class OverworldOreFeatures extends GeneratorFeatures {
public OverworldOreFeatures(OreConfig config){
this.config = config;
}

/**Adds a world feature entry
* @param feature WorldFeature to generate
* @param chances Number of attempts per chunk
* @param rangeModifier Fraction of the world from the bottom to the surface to generate inside, a value of -1 indicates to spawn on the surface only
*/
public void addFeature(WorldFeature feature, int chances, float rangeModifier){
addFeature(feature, chances, rangeModifier, null);
}

/**Adds a world feature entry
* @param feature WorldFeature to generate
* @param chances Number of attempts per chunk
* @param rangeModifier Fraction of the world from the bottom to the surface to generate inside, a value of -1 indicates to spawn on the surface only
* @param biomes List of biomes to generate in, generates in any biome if array is null
*/
public void addFeature(WorldFeature feature, int chances, float rangeModifier, Biome[] biomes){
addComplexFeature((Parameters x) -> feature, null, OverworldFunctions::getStandardOreBiomesDensity, new Object[]{chances, biomes}, rangeModifier);
}
/** The Object[] are the parameters passed into the provided function, index 0 will always be populated by Biome, index 1 with Random, index 2 with Chunk, index 3 with the ChunkDecorator, and index 4 with the oreHeightModifier. Additional parameters can be added in the method.
* Range Modifier of -1 indicates that the feature should only generate on the surface
*

/**Adds a world feature entry
* @param featureFunction Function that takes a Parameters object and returns a WorldFeature
* @param featureParameters Object[] of additional parameters that will be included with the Parameters object passed into the feature function
* @param densityFunction Function that takes a Parameters object and returns an Integer representing the number of attempts per chunk
* @param densityParameters Object[] of additional parameters that will be included with the Parameters object passed into the density function
* @param rangeModifier Fraction of the world from the bottom to the surface to generate inside, a value of -1 indicates to spawn on the surface only
*/
public void addComplexFeature(Function<Parameters, WorldFeature> featureFunction, Object[] featureParameters, Function<Parameters, Integer> densityFunction, Object[] densityParameters, float rangeModifier){
super.addComplexFeature(featureFunction, featureParameters, densityFunction, densityParameters);
rangeModifierList.add(rangeModifier);
}

/**Adds an WorldFeatureOre, which has its generation characteristics managed by OreConfig
* @param block Ore to generate
* @param defaultClusterSize Default size in blocks of an ore vein
* @param defaultChances Default number of chances per chunk to generate an ore patch, this values scales with world height
* @param defaultRange Value from [0, 1], it's the default fraction from the bottom of the world to the surface that the ore can generate
* @param hasStoneStates Does ore have states for each stone type
*/
public void addManagedOreFeature(String modID, Block block, int defaultClusterSize, int defaultChances, float defaultRange, boolean hasStoneStates){
config.setOreValues(modID, block, defaultClusterSize, defaultChances, defaultRange);
addManagedOreFeature(block, hasStoneStates);
}

/**Adds an WorldFeatureOre, which has its generation characteristics managed by OreConfig
* @param block Ore to generate
* @param hasStoneStates Does ore have states for each stone type
*/
public void addManagedOreFeature(Block block, boolean hasStoneStates){
String currentBlock = block.getKey();
addFeature(new WorldFeatureOre(block.id, config.clusterSize.get(currentBlock), hasStoneStates), config.chancesPerChunk.get(currentBlock), config.verticalRange.get(currentBlock));
Expand Down

0 comments on commit a93469f

Please sign in to comment.