Skip to content

Commit

Permalink
fix biome height scaling, ground + rootHeight*17
Browse files Browse the repository at this point in the history
Evidence:
- TerrainControl:
  https://github.com/MCTCP/TerrainControl/wiki/World-height#biomeheight
- BiomesOPlenty vanilla biome handling code
  • Loading branch information
lawremi committed Oct 9, 2016
1 parent 91c56bd commit 11b2d0b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 101 deletions.
25 changes: 1 addition & 24 deletions src/main/java/CustomOreGen/Server/WorldConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ public class WorldConfig
public boolean debuggingMode;
public boolean vanillaOreGen;
public boolean custom;
public double rootHeightFactor;
public double heightVarFactor;
public double rootHeightVarFactor;
private Map<String,IOreDistribution> oreDistributions;
private Map<String,ConfigOption> configOptions;
private Map<String,String> loadedOptions;
Expand Down Expand Up @@ -93,9 +90,6 @@ private WorldConfig(File globalConfigDir, WorldInfo worldInfo, File worldBaseDir
this.deferredPopulationRange = 0;
this.debuggingMode = false;
this.vanillaOreGen = false;
this.rootHeightFactor = 17;
this.heightVarFactor = 0;
this.rootHeightVarFactor = 0;
this.oreDistributions = new LinkedHashMap<String,IOreDistribution>();
this.configOptions = new CIStringMap<ConfigOption>(new LinkedHashMap<String, ConfigOption>());
this.loadedOptions = new CIStringMap<String>(new LinkedHashMap<String, String>());
Expand Down Expand Up @@ -193,7 +187,7 @@ private WorldConfig(File globalConfigDir, WorldInfo worldInfo, File worldBaseDir
File[] optionsFileList = new File[3];
this.buildFileList(CustomOreGenBase.OPTIONS_FILENAME, optionsFileList, false);
File optionsFile = optionsFileList[2];
ConfigOption vangen, rootHeightOption, heightVarOption, rootHeightVarOption;
ConfigOption vangen;

for (int defpopOption = configFileDepth; defpopOption < optionsFileList.length; ++defpopOption)
{
Expand Down Expand Up @@ -260,23 +254,6 @@ private WorldConfig(File globalConfigDir, WorldInfo worldInfo, File worldBaseDir
CustomOreGenBase.log.warn("Choice Option \'" + vangen + "\' not found in config file - defaulting to \'" + this.vanillaOreGen + "\'.");
}

rootHeightOption = (ConfigOption)this.configOptions.get("rootHeightFactor");
if (rootHeightOption != null && rootHeightOption instanceof NumericOption)
{
this.rootHeightFactor = (Double)rootHeightOption.getValue();
}

heightVarOption = (ConfigOption)this.configOptions.get("heightVarFactor");
if (heightVarOption != null && heightVarOption instanceof NumericOption)
{
this.heightVarFactor = (Double)heightVarOption.getValue();
}

rootHeightVarOption = (ConfigOption)this.configOptions.get("rootHeightVarFactor");
if (rootHeightVarOption != null && rootHeightVarOption instanceof NumericOption)
{
this.rootHeightVarFactor = (Double)rootHeightVarOption.getValue();
}
}
}

Expand Down
13 changes: 3 additions & 10 deletions src/main/java/CustomOreGen/Util/BiomeHeightScale.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package CustomOreGen.Util;

import CustomOreGen.Server.ServerState;
import CustomOreGen.Server.WorldConfig;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
Expand All @@ -14,19 +12,14 @@ public int getHeight(World world, int x, int z) {
if (biome == null) {
return new WorldHeightScale().getHeight(world, x, z);
}
return this.calcBlockHeight(world, biome.rootHeight, biome.heightVariation);
return this.calcBlockHeight(world, biome.rootHeight);
}

private int calcBlockHeight(World world, float rootHeight, float heightVariation) {
WorldConfig config = ServerState.getWorldConfig(world);
private int calcBlockHeight(World world, float rootHeight) {
if (world.provider.terrainType == WorldType.AMPLIFIED && rootHeight > 0) {
rootHeight = 1.0F + rootHeight * 2.0F;
}
return (int)(
world.provider.getAverageGroundLevel() +
rootHeight * config.rootHeightFactor +
heightVariation * config.heightVarFactor +
rootHeight * heightVariation * config.rootHeightVarFactor);
return (int)(world.provider.getAverageGroundLevel() + rootHeight * 17);
}

@Override
Expand Down
67 changes: 0 additions & 67 deletions src/main/resources/config/CustomOreGen_Config_Default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,73 +119,6 @@
<Choice value='false' displayValue='Off'/>
</OptionChoice>

<OptionNumeric name='rootHeightFactor' default='17'
displayGroup='groupInternal'>
<Description>
Multiplier for rootHeight during biome height scaling
</Description>
<Comment>
This is a "magic" option - it has meaning outside of
this file in the COG engine itelf. You can change the
value, but do not remove the option itself.

Biome height scaling needs to estimate the average
height of a biome. This is non-trivial, because
terrain generation is complex and varies across biomes
and dimensions/worlds. There are two explicit
parameters: root height and height variation. The
offset from the dimension ground level is a linear
combination of those, as well as their
interaction.

This option represents the factor for the root height.
</Comment>
<DisplayState>hidden</DisplayState>
<DisplayName>Root Height Factor</DisplayName>
<Min>0</Min>
<Max>128</Max>
</OptionNumeric>

<OptionNumeric name='heightVarFactor' default='0'
displayGroup='groupInternal'>
<Description>
Multiplier for heightVariation during biome height scaling
</Description>
<Comment>
This is a "magic" option - it has meaning outside of
this file in the COG engine itelf. You can change the
value, but do not remove the option itself.

See the coment for 'rootHeightFactor'. This option
represents the factor for the height variation.
</Comment>
<DisplayState>hidden</DisplayState>
<DisplayName>Height Variation Factor</DisplayName>
<Min>0</Min>
<Max>128</Max>
</OptionNumeric>

<OptionNumeric name='rootHeightVarFactor' default='0'
displayGroup='groupInternal'>
<Description>
Multiplier for the product of the rootHeight and
heightVariation during biome height scaling
</Description>
<Comment>
This is a "magic" option - it has meaning outside of
this file in the COG engine itelf. You can change the
value, but do not remove the option itself.

See the coment for 'rootHeightFactor'. This option
represents the factor for the product (interaction) of
the root height and height variation.
</Comment>
<DisplayState>hidden</DisplayState>
<DisplayName>Root Height * Variation Factor</DisplayName>
<Min>0</Min>
<Max>128</Max>
</OptionNumeric>

<OptionChoice name='drawWireframes' default='true' displayGroup='groupGeneral'>
<Description>
Default wireframe state for distributions.
Expand Down

0 comments on commit 11b2d0b

Please sign in to comment.