From eb1d359bf4b294d606c26852c3c22668d0aaf328 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Sat, 31 Dec 2016 12:30:18 -0800 Subject: [PATCH] Make some noise params from vanilla configurable Specifically: - Main Noise X/Y/Z - Coordinate Scale - Height Scale - Lower/Upper Limit Scale --- .../client/gui/GuiBOPConfigureWorld.java | 50 +++++++++++++++++-- .../common/world/BOPWorldSettings.java | 38 ++++++++++++-- .../world/ChunkProviderGenerateBOP.java | 16 +++--- 3 files changed, 87 insertions(+), 17 deletions(-) diff --git a/src/main/java/biomesoplenty/client/gui/GuiBOPConfigureWorld.java b/src/main/java/biomesoplenty/client/gui/GuiBOPConfigureWorld.java index d18085590..b4402c415 100644 --- a/src/main/java/biomesoplenty/client/gui/GuiBOPConfigureWorld.java +++ b/src/main/java/biomesoplenty/client/gui/GuiBOPConfigureWorld.java @@ -192,8 +192,15 @@ public class GuiBOPConfigureWorld extends GuiScreen implements GuiSlider.FormatH GENERATE_HOT_SPRINGS (123), GENERATE_NETHER_HIVES (124), GENERATE_NETHER_PLANTS (125), - GENERATE_END_FEATURES (126); - + GENERATE_END_FEATURES (126), + MAIN_NOISE_SCALE_X (127), + MAIN_NOISE_SCALE_Y (128), + MAIN_NOISE_SCALE_Z (129), + COORDINATE_SCALE (130), + HEIGHT_SCALE (131), + UPPER_LIMIT_SCALE (132), + LOWER_LIMIT_SCALE (133); + private int id; private GuiEntries(int id) @@ -229,7 +236,14 @@ public class GuiBOPConfigureWorld extends GuiScreen implements GuiSlider.FormatH new GuiBOPPageList.GuiEnumButtonEntry(GuiEntries.LAND_SCHEME.getId(), "Land Mass: %s", true, this.settings.landScheme), new GuiBOPPageList.GuiEnumButtonEntry(GuiEntries.TEMP_SCHEME.getId(), "Temperature: %s", true, this.settings.tempScheme), new GuiBOPPageList.GuiEnumButtonEntry(GuiEntries.RAIN_SCHEME.getId(), "Rainfall: %s", true, this.settings.rainScheme), - new GuiBOPPageList.GuiSlideEntry(GuiEntries.AMPLITUDE.getId(), "Amplitude", true, this, 0.2F, 3.0F, this.settings.amplitude) + new GuiBOPPageList.GuiSlideEntry(GuiEntries.AMPLITUDE.getId(), "Amplitude", true, this, 0.2F, 3.0F, this.settings.amplitude), + new GuiBOPPageList.GuiSlideEntry(GuiEntries.MAIN_NOISE_SCALE_X.getId(), "Main Noise Scale X", true, this, 1.0F, 5000.0F, this.settings.mainNoiseScaleX), + new GuiBOPPageList.GuiSlideEntry(GuiEntries.MAIN_NOISE_SCALE_Y.getId(), "Main Noise Scale Y", true, this, 1.0F, 5000.0F, this.settings.mainNoiseScaleY), + new GuiBOPPageList.GuiSlideEntry(GuiEntries.MAIN_NOISE_SCALE_Z.getId(), "Main Noise Scale Z", true, this, 1.0F, 5000.0F, this.settings.mainNoiseScaleZ), + new GuiBOPPageList.GuiSlideEntry(GuiEntries.COORDINATE_SCALE.getId(), "Coordinate Scale", true, this, 1.0F, 6000.0F, this.settings.coordinateScale), + new GuiBOPPageList.GuiSlideEntry(GuiEntries.HEIGHT_SCALE.getId(), "Height Scale", true, this, 1.0F, 6000.0F, this.settings.heightScale), + new GuiBOPPageList.GuiSlideEntry(GuiEntries.UPPER_LIMIT_SCALE.getId(), "Upper Limit Scale", true, this, 1.0F, 5000.0F, this.settings.upperLimitScale), + new GuiBOPPageList.GuiSlideEntry(GuiEntries.LOWER_LIMIT_SCALE.getId(), "Lower Limit Scale", true, this, 1.0F, 5000.0F, this.settings.lowerLimitScale), }; this.pageNames[1] = "Biome Settings"; @@ -301,6 +315,13 @@ public class GuiBOPConfigureWorld extends GuiScreen implements GuiSlider.FormatH switch (entry) { case AMPLITUDE: + case MAIN_NOISE_SCALE_X: + case MAIN_NOISE_SCALE_Y: + case MAIN_NOISE_SCALE_Z: + case COORDINATE_SCALE: + case HEIGHT_SCALE: + case UPPER_LIMIT_SCALE: + case LOWER_LIMIT_SCALE: return String.format("%5.3f", new Object[] {Float.valueOf(value)}); default: return ""; @@ -430,6 +451,27 @@ public class GuiBOPConfigureWorld extends GuiScreen implements GuiSlider.FormatH case AMPLITUDE: this.settings.amplitude = value; break; + case MAIN_NOISE_SCALE_X: + this.settings.mainNoiseScaleX = value; + break; + case MAIN_NOISE_SCALE_Y: + this.settings.mainNoiseScaleY = value; + break; + case MAIN_NOISE_SCALE_Z: + this.settings.mainNoiseScaleZ = value; + break; + case COORDINATE_SCALE: + this.settings.coordinateScale = value; + break; + case HEIGHT_SCALE: + this.settings.heightScale = value; + break; + case UPPER_LIMIT_SCALE: + this.settings.upperLimitScale = value; + break; + case LOWER_LIMIT_SCALE: + this.settings.lowerLimitScale = value; + break; default: break; } @@ -653,4 +695,4 @@ public class GuiBOPConfigureWorld extends GuiScreen implements GuiSlider.FormatH this.noButton.drawButton(this.mc, mouseX, mouseY); } } -} \ No newline at end of file +} diff --git a/src/main/java/biomesoplenty/common/world/BOPWorldSettings.java b/src/main/java/biomesoplenty/common/world/BOPWorldSettings.java index efe388663..f1652e8d0 100644 --- a/src/main/java/biomesoplenty/common/world/BOPWorldSettings.java +++ b/src/main/java/biomesoplenty/common/world/BOPWorldSettings.java @@ -114,7 +114,14 @@ public class BOPWorldSettings implements IBOPWorldSettings public int lavaLakeChance; public boolean useLavaOceans; - + public float coordinateScale; + public float heightScale; + public float upperLimitScale; + public float lowerLimitScale; + public float mainNoiseScaleX; + public float mainNoiseScaleY; + public float mainNoiseScaleZ; + public BOPWorldSettings() { this.setDefault(); @@ -154,7 +161,14 @@ public class BOPWorldSettings implements IBOPWorldSettings obj.addProperty("generateNetherHives", this.generateNetherHives); obj.addProperty("generateNetherPlants", this.generateNetherPlants); obj.addProperty("generateEndFeatures", this.generateEndFeatures); - + obj.addProperty("mainNoiseScaleX", this.mainNoiseScaleX); + obj.addProperty("mainNoiseScaleY", this.mainNoiseScaleY); + obj.addProperty("mainNoiseScaleZ", this.mainNoiseScaleZ); + obj.addProperty("coordinateScale", this.coordinateScale); + obj.addProperty("heightScale", this.heightScale); + obj.addProperty("upperLimitScale", this.upperLimitScale); + obj.addProperty("lowerLimitScale", this.lowerLimitScale); + return serializer.toJson(obj); } @@ -190,6 +204,13 @@ public class BOPWorldSettings implements IBOPWorldSettings this.generateNetherHives = worldConfig.getBool("generateNetherHives", this.generateNetherHives); this.generateNetherPlants = worldConfig.getBool("generateNetherPlants", this.generateNetherPlants); this.generateEndFeatures = worldConfig.getBool("generateEndFeatures", this.generateEndFeatures); + this.mainNoiseScaleX = worldConfig.getFloat("mainNoiseScaleX", this.mainNoiseScaleX); + this.mainNoiseScaleY = worldConfig.getFloat("mainNoiseScaleY", this.mainNoiseScaleY); + this.mainNoiseScaleZ = worldConfig.getFloat("mainNoiseScaleZ", this.mainNoiseScaleZ); + this.coordinateScale = worldConfig.getFloat("coordinateScale", this.coordinateScale); + this.heightScale = worldConfig.getFloat("heightScale", this.heightScale); + this.upperLimitScale = worldConfig.getFloat("upperLimitScale", this.upperLimitScale); + this.lowerLimitScale = worldConfig.getFloat("lowerLimitScale", this.lowerLimitScale); } public void setDefault() @@ -238,8 +259,15 @@ public class BOPWorldSettings implements IBOPWorldSettings this.useLavaLakes = true; this.lavaLakeChance = 80; this.useLavaOceans = false; - - + + this.mainNoiseScaleX = 80.0F; + this.mainNoiseScaleY = 160.0F; + this.mainNoiseScaleZ = 80.0F; + this.coordinateScale = 684.412F; + this.heightScale = 684.412F; + this.upperLimitScale = 512.0F; + this.lowerLimitScale = 512.0F; + // Allow defaults to be overridden from file IConfigObj worldConfig = new BOPConfig.ConfigFileObj(new File(BiomesOPlenty.configDirectory, "world.json")); this.fromConfigObj(worldConfig); @@ -296,4 +324,4 @@ public class BOPWorldSettings implements IBOPWorldSettings return true; } } -} \ No newline at end of file +} diff --git a/src/main/java/biomesoplenty/common/world/ChunkProviderGenerateBOP.java b/src/main/java/biomesoplenty/common/world/ChunkProviderGenerateBOP.java index acef17569..1c31b1b5e 100644 --- a/src/main/java/biomesoplenty/common/world/ChunkProviderGenerateBOP.java +++ b/src/main/java/biomesoplenty/common/world/ChunkProviderGenerateBOP.java @@ -379,13 +379,13 @@ public class ChunkProviderGenerateBOP implements IChunkGenerator Biome[] biomes = this.worldObj.getBiomeProvider().getBiomesForGeneration(null, chunkX * 4 - 2, chunkZ * 4 - 2, 10, 10); // values from vanilla - float coordinateScale = 684.412F; - float heightScale = 684.412F; - double upperLimitScale = 512.0D; - double lowerLimitScale = 512.0D; - float mainNoiseScaleX = 80.0F; - float mainNoiseScaleY = 160.0F; - float mainNoiseScaleZ = 80.0F; + float coordinateScale = this.settings.coordinateScale; + float heightScale = this.settings.heightScale; + double upperLimitScale = this.settings.upperLimitScale; + double lowerLimitScale = this.settings.lowerLimitScale; + float mainNoiseScaleX = this.settings.mainNoiseScaleX; + float mainNoiseScaleY = this.settings.mainNoiseScaleY; + float mainNoiseScaleZ = this.settings.mainNoiseScaleZ; int subchunkX = chunkX * 4; int subchunkY = 0; @@ -638,4 +638,4 @@ public class ChunkProviderGenerateBOP implements IChunkGenerator this.oceanMonumentGenerator.generate(this.worldObj, p_180514_2_, p_180514_3_, (ChunkPrimer)null); } } -} \ No newline at end of file +}