Skip to content

Commit

Permalink
Added config option for loose rock generation during worldgen.
Browse files Browse the repository at this point in the history
  • Loading branch information
wendall911 committed May 29, 2018
1 parent eb1c08e commit c175629
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/main/java/tinkersurvival/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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."})
Expand All @@ -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;
}

Expand All @@ -36,4 +40,5 @@ public static class Features {
@Comment({"I cry myself to sleep at night..."})
public static boolean NO_SLEEPING = true;
}

}
10 changes: 6 additions & 4 deletions src/main/java/tinkersurvival/world/worldgen/RockGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit c175629

Please sign in to comment.