From c17562952fd73cc440a4cd93eff25dddfcecaac0 Mon Sep 17 00:00:00 2001 From: Wendall Cada Date: Tue, 29 May 2018 10:14:15 -0700 Subject: [PATCH] Added config option for loose rock generation during worldgen. --- src/main/java/tinkersurvival/config/Config.java | 11 ++++++++--- .../tinkersurvival/world/worldgen/RockGenerator.java | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/tinkersurvival/config/Config.java b/src/main/java/tinkersurvival/config/Config.java index 584cee4..fb2ddcc 100644 --- a/src/main/java/tinkersurvival/config/Config.java +++ b/src/main/java/tinkersurvival/config/Config.java @@ -5,6 +5,7 @@ @net.minecraftforge.common.config.Config(modid=TinkerSurvival.MODID) public class Config { + public static Tools tools; public static class Tools { @Comment({"List of mods that tools will always work for. All other mod tools will become wet noodles."}) @@ -18,13 +19,16 @@ public static class Tools { public static Balance balance; public static class Balance { - @Comment({"Chance for a sucessful flint knapping."}) + @Comment({"Chance for a rocks to generate on surface. Default 100% - 1.0D"}) + public static double ROCKGEN_CHANCE = 1.0D; + + @Comment({"Chance for a sucessful flint knapping. Default 60% - 0.6D"}) public static double FLINT_CHANCE = 0.6D; - @Comment({"Chance for tall grass to drop plant fibers."}) + @Comment({"Chance for tall grass to drop plant fibers. Default 60% - 0.6D. Knives are 40% more effective."}) public static double GRASS_FIBER_CHANCE = 0.5D; - @Comment("Heal rate for bandages. Crude bandages are 50% less effective.") + @Comment({"Heal rate for bandages. Crude bandages are 50% less effective."}) public static double HEAL_RATE = 0.14D; } @@ -36,4 +40,5 @@ public static class Features { @Comment({"I cry myself to sleep at night..."}) public static boolean NO_SLEEPING = true; } + } diff --git a/src/main/java/tinkersurvival/world/worldgen/RockGenerator.java b/src/main/java/tinkersurvival/world/worldgen/RockGenerator.java index 1041268..9a8b062 100644 --- a/src/main/java/tinkersurvival/world/worldgen/RockGenerator.java +++ b/src/main/java/tinkersurvival/world/worldgen/RockGenerator.java @@ -16,6 +16,7 @@ import net.minecraftforge.fml.common.IWorldGenerator; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import tinkersurvival.config.Config; import tinkersurvival.world.block.BlockRock; import tinkersurvival.world.TinkerSurvivalWorld; @@ -58,7 +59,8 @@ private boolean generateRocks(World world, Random random, int i, int j, int k) { Material atMat = atBl.getMaterial(atBl.getBlockState().getBaseState()); - if ((world.isAirBlock(new BlockPos(i, j + 1, k)) + if (random.nextDouble() < Config.Balance.ROCKGEN_CHANCE + && (world.isAirBlock(new BlockPos(i, j + 1, k)) || upBl== Blocks.SNOW_LAYER || upBl == Blocks.TALLGRASS || upBl == Blocks.SNOW) @@ -67,8 +69,8 @@ private boolean generateRocks(World world, Random random, int i, int j, int k) { || atMat == Material.SAND) && atBl.isOpaqueCube(atBl.getDefaultState())) { BlockRock.EnumMineralType type; - if(downBl == Blocks.STONE){ - switch(downBl.getMetaFromState(world.getBlockState(new BlockPos(i, j - 5, k)))) { + if (downBl == Blocks.STONE) { + switch (downBl.getMetaFromState(world.getBlockState(new BlockPos(i, j - 5, k)))) { case 1: type = GRANITE; break; @@ -82,7 +84,7 @@ private boolean generateRocks(World world, Random random, int i, int j, int k) { type = STONE; } } else { - switch(downBl.getUnlocalizedName()){ + switch (downBl.getUnlocalizedName()) { default: type = STONE; }