Skip to content

Commit

Permalink
Merge pull request #758 from Team-RTG/dev
Browse files Browse the repository at this point in the history
Merge dev into master (1.7.10-1.0-snapshot-2)
  • Loading branch information
whichonespink44 authored Jun 17, 2016
2 parents 2407f00 + 550af4d commit 73e2a0f
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 2 deletions.
5 changes: 5 additions & 0 deletions etc/config/RTG/rtg.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ boulders {

# [default: true]
B:"Enable Cobblestone Boulders"=true

# Set this to TRUE to allow UBC to override cobblestone boulders.
# This setting doesn't have any effect if UBC is not installed.
# [default: true]
B:"UBC Boulders"=true
}


Expand Down
11 changes: 11 additions & 0 deletions src/main/java/rtg/config/rtg/ConfigRTG.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ConfigRTG

public static boolean enableCobblestoneBoulders = true;
public static int cobblestoneBoulderChance = 1;
public static boolean enableUBCBoulders = true;

/* ==================== Caves ==================== */

Expand Down Expand Up @@ -262,6 +263,16 @@ public static void init(File configFile)
enableCobblestoneBoulders = config.getBoolean("Enable Cobblestone Boulders", "Boulders", enableCobblestoneBoulders, "");
cobblestoneBoulderChance = config.getInt("1/x chance that Cobblestone Boulders will generate if given the opportunity to do so during world gen", "Boulders", cobblestoneBoulderChance, 1, 100, "1 = Always generate if possible; 2 = 50% chance; 4 = 25% chance" + Configuration.NEW_LINE);

enableUBCBoulders = config.getBoolean(
"UBC Boulders",
"Boulders",
enableUBCStoneShadowing,
"Set this to TRUE to allow UBC to override cobblestone boulders."
+ Configuration.NEW_LINE +
"This setting doesn't have any effect if UBC is not installed."
+ Configuration.NEW_LINE
);

/* ==================== Caves ==================== */

enableCaveModifications = config.getBoolean(
Expand Down
70 changes: 70 additions & 0 deletions src/main/java/rtg/util/BoulderUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package rtg.util;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import rtg.config.rtg.ConfigRTG;
import cpw.mods.fml.common.registry.GameData;
import exterminatorJeff.undergroundBiomes.api.BlockCodes;

public class BoulderUtil
{
private final static ModPresenceTester undergroundBiomesMod = new ModPresenceTester("UndergroundBiomes");
private final static ModPresenceTester harderUndergroundMod = new ModPresenceTester("HarderUnderground");

// Create UBColumnCache only if UB is present.
private static UBColumnCache ubColumnCache = undergroundBiomesMod.present() ? new UBColumnCache() : null;

// If the Harder Underground mod is installed, then let's use unstable cobble instead of vanilla cobble.
private static Block unstableCobbleBlock = harderUndergroundMod.present() ? GameData.getBlockRegistry().getObject("HarderUnderground:unstable_stone") : Blocks.cobblestone;
private static byte unstableCobbleMeta = harderUndergroundMod.present() ? (byte)3 : (byte)0;

public Block getBoulderBlock(Block defaultBlock, int worldX, int worldY, int worldZ)
{
if (defaultBlock == Blocks.cobblestone) {

if (undergroundBiomesMod.present() && ConfigRTG.enableUBCBoulders) {

BlockCodes cobble = ubColumnCache.column(worldX, worldZ).cobblestone(worldY);

return cobble.block;
}
else if (harderUndergroundMod.present()) {

return unstableCobbleBlock;
}
else {

return defaultBlock;
}
}
else {

return defaultBlock;
}
}

public byte getBoulderMeta(Block defaultBlock, byte defaultMeta, int worldX, int worldY, int worldZ)
{
if (defaultBlock == Blocks.cobblestone) {

if ((undergroundBiomesMod.present())) {

BlockCodes cobble = ubColumnCache.column(worldX, worldZ).cobblestone(worldY);

return (byte) cobble.metadata;
}
else if (harderUndergroundMod.present()) {

return unstableCobbleMeta;
}
else {

return defaultMeta;
}
}
else {

return defaultMeta;
}
}
}
10 changes: 8 additions & 2 deletions src/main/java/rtg/world/gen/feature/WorldGenBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import rtg.config.rtg.ConfigRTG;
import rtg.util.BoulderUtil;
import rtg.util.RandomUtil;

public class WorldGenBlob extends WorldGenerator
Expand All @@ -18,6 +19,7 @@ public class WorldGenBlob extends WorldGenerator
private boolean booShouldGenerate;
private static final String __OBFID = "CL_00000402";
protected boolean water;
protected BoulderUtil boulderUtil;

public WorldGenBlob(Block b, int s, Random rand)
{
Expand All @@ -27,6 +29,7 @@ public WorldGenBlob(Block b, int s, Random rand)
this.blobSize = s;
booShouldGenerate = true;
this.water = true;
this.boulderUtil = new BoulderUtil();

if (blobBlock == Blocks.mossy_cobblestone || blobBlock == Blocks.cobblestone) {
if (!ConfigRTG.enableCobblestoneBoulders) {
Expand Down Expand Up @@ -67,7 +70,7 @@ public void generate(World world, Random rand, int x, int y, int z, boolean hono
}
}
}

generate(world, rand, x, y, z);
}

Expand All @@ -77,6 +80,9 @@ public boolean generate(World world, Random rand, int x, int y, int z)
return false;
}

Block boulderBlock = this.boulderUtil.getBoulderBlock(this.blobBlock, x, y, z);
byte boulderMeta = this.boulderUtil.getBoulderMeta(this.blobBlock, this.blobMeta, x, y, z);

while (true)
{
if (y > 3)
Expand Down Expand Up @@ -138,7 +144,7 @@ public boolean generate(World world, Random rand, int x, int y, int z)

if (f1 * f1 + f2 * f2 + f3 * f3 <= f * f)
{
world.setBlock(l1, j2, i2, this.blobBlock, this.blobMeta, 2);
world.setBlock(l1, j2, i2, boulderBlock, boulderMeta, 2);
}
}
}
Expand Down

0 comments on commit 73e2a0f

Please sign in to comment.