Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

dependencies {
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false}
compileOnly ("com.github.GTNewHorizons:Baubles:1.0.4:dev") // For Thaumcraft runtime, but can be used separately
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.11.11-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Battlegear2:1.3.5:api") {} //For TiC to work
compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.5.23-GTNH:dev")
compileOnly("curse.maven:skinport-234948:3212017")
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.95:dev") // Temporary option

// For Thaumcraft runtime
compileOnly ("com.github.GTNewHorizons:Baubles:1.0.4:dev")
}
4 changes: 4 additions & 0 deletions src/main/java/twilightforest/TwilightForestMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import twilightforest.tileentity.TileEntityTFTowerBossSpawner;
import twilightforest.tileentity.TileEntityTFTowerBuilder;
import twilightforest.tileentity.TileEntityTFTrophy;
import twilightforest.world.TFGenCaveStalactite;
import twilightforest.world.WorldProviderTwilightForest;

@Mod(modid = TwilightForestMod.ID, name = "The Twilight Forest", version = TwilightForestMod.VERSION)
Expand Down Expand Up @@ -239,6 +240,9 @@ public void preInit(FMLPreInitializationEvent event) {
// just call this so that we register structure IDs correctly
new StructureTFMajorFeatureStart();

// register vanilla stalactite ores
if (!Loader.isModLoaded("dreamcraft")) TFGenCaveStalactite.registerVanillaStalactites();

// check if various integrations are required
isSkinportLoaded = Loader.isModLoaded("skinport");
isNeiLoaded = Loader.isModLoaded("NotEnoughItems");
Expand Down
73 changes: 73 additions & 0 deletions src/main/java/twilightforest/world/GTGenCaveStalactite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package twilightforest.world;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores;

public class GTGenCaveStalactite extends TFGenCaveStalactite {

/**
* Initializes a stalactite builder
*/
public GTGenCaveStalactite(Block blockType, int meta, float size, int maxLength, int minHeight) {
super(blockType, meta, size, maxLength, minHeight);
}

@Override
public boolean makeSpike(World world, Random random, int x, int y, int z, int maxLength) {

int diameter = (int) (maxLength / 4.5); // diameter of the base

// let's see...
for (int dx = -diameter; dx <= diameter; dx++) {
for (int dz = -diameter; dz <= diameter; dz++) {
// determine how long this spike will be.
int absx = Math.abs(dx);
int absz = Math.abs(dz);
int dist = (int) (Math.max(absx, absz) + (Math.min(absx, absz) * 0.5));
int spikeLength = 0;

if (dist == 0) {
spikeLength = maxLength;
}

if (dist > 0) {
spikeLength = random.nextInt((int) (maxLength / (dist + 0.25)));
}

int dir = hang ? -1 : 1;

// check if we're generating over anything
if (!world.getBlock(x + dx, y - dir, z + dz).getMaterial().isSolid()) {
spikeLength = 0;
}

for (int dy = 0; dy != (spikeLength * dir); dy += dir) {
world.setBlock(
x,
y,
z,
blockID,
GT_TileEntity_Ores.getHarvestData(
(short) blockMeta,
((GT_Block_Ores_Abstract) blockID)
.getBaseBlockHarvestLevel(blockMeta % 16000 / 1000)),
0);
TileEntity tTileEntity = world.getTileEntity(x, y, z);
if ((tTileEntity instanceof GT_TileEntity_Ores)) {
((GT_TileEntity_Ores) tTileEntity).mMetaData = ((short) blockMeta);
((GT_TileEntity_Ores) tTileEntity).mNatural = true;
}
}
}
}

return true;
}

}
155 changes: 132 additions & 23 deletions src/main/java/twilightforest/world/TFGenCaveStalactite.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package twilightforest.world;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
Expand All @@ -18,7 +20,12 @@ public class TFGenCaveStalactite extends TFGenerator {
public static TFGenCaveStalactite coal = new TFGenCaveStalactite(Blocks.coal_ore, 0.8F, 12, 1);
public static TFGenCaveStalactite glowstone = new TFGenCaveStalactite(Blocks.glowstone, 0.5F, 8, 1);

private static List<TFGenCaveStalactite> hill3 = new ArrayList<TFGenCaveStalactite>();
private static List<TFGenCaveStalactite> hill2 = new ArrayList<TFGenCaveStalactite>();
private static List<TFGenCaveStalactite> hill1 = new ArrayList<TFGenCaveStalactite>();

public Block blockID;
public int blockMeta;
public boolean hang;
public float sizeFactor;
public int maxLength;
Expand All @@ -31,7 +38,18 @@ public class TFGenCaveStalactite extends TFGenerator {
* @param stone
*/
public TFGenCaveStalactite(Block blockType, float size, boolean down) {
this(blockType, 0, size, down);
}

/**
* Initializes a stalactite builder. Actually also makes stalagmites
*
* @param size
* @param stone
*/
public TFGenCaveStalactite(Block blockType, int meta, float size, boolean down) {
this.blockID = blockType;
this.blockMeta = meta;
this.sizeFactor = size;
this.maxLength = -1;
this.minHeight = -1;
Expand All @@ -42,13 +60,120 @@ public TFGenCaveStalactite(Block blockType, float size, boolean down) {
* Initializes a stalactite builder
*/
public TFGenCaveStalactite(Block blockType, float size, int maxLength, int minHeight) {
this(blockType, 0, size, maxLength, minHeight);
}

/**
* Initializes a stalactite builder
*/
public TFGenCaveStalactite(Block blockType, int meta, float size, int maxLength, int minHeight) {
this.blockID = blockType;
this.blockMeta = meta;
this.sizeFactor = size;
this.maxLength = maxLength;
this.minHeight = minHeight;
this.hang = true;
}

/**
* For other mods to add stalactites made of their blocks
*
* @param block Block to generate stalactite of. Most likely ore
* @param size How much space between ceiling and floor stalactite takes. From 0.0f to 1.0f
* @param maxLength Maximum stalactite length. For when you want to make it big, but not too big
* @param minHeight Minimum stalactite length. For when you want to make it small, but not too small
* @param hillLevel Level of the hill for the resource to spawn in. From 1 to 3. Resources from low-level hills will
* spawn in high level hills as well. Examples: 3 level - diamond, lapis, emerald; 2 level - gold,
* redstone; 1 level - iron, coal, glowstone
* @param weight How often should resource generate comparing to other resources of the same level. I.e. the
* larger this number is, the more often this resource will generate. Examples: diamond, lapis - 2;
* emerald - 1 | redstone - 2, gold - 1 | iron, coal - 2, glowstone - 1
*/
public static void addStalactite(Block block, float size, int maxLength, int minHeight, int hillLevel, int weight) {
addStalactite(block, 0, size, maxLength, minHeight, hillLevel, weight);
}

/**
* For other mods to add stalactites made of their blocks
*
* @param block Block to generate stalactite of. Most likely ore
* @param meta Block metadata in case it needs one
* @param size How much space between ceiling and floor stalactite takes. From 0.0f to 1.0f
* @param maxLength Maximum stalactite length. For when you want to make it big, but not too big
* @param minHeight Minimum stalactite length. For when you want to make it small, but not too small
* @param hillLevel Level of the hill for the resource to spawn in. From 1 to 3. Resources from low-level hills will
* spawn in high level hills as well. Examples: 3 level - diamond, lapis, emerald; 2 level - gold,
* redstone; 1 level - iron, coal, glowstone
* @param weight How often should resource generate comparing to other resources of the same level. I.e. the
* larger this number is, the more often this resource will generate. Examples: diamond, lapis - 2;
* emerald - 1 | redstone - 2, gold - 1 | iron, coal - 2, glowstone - 1
*/
public static void addStalactite(Block block, int meta, float size, int maxLength, int minHeight, int hillLevel,
int weight) {
addStalactite(new TFGenCaveStalactite(block, meta, size, maxLength, minHeight), hillLevel, weight);
}

/**
* For other mods to add stalactites made of their blocks
*
* @param block Block to generate stalactite of. Most likely ore
* @param meta Block metadata in case it needs one
* @param size How much space between ceiling and floor stalactite takes. From 0.0f to 1.0f
* @param hillLevel Level of the hill for the resource to spawn in. From 1 to 3. Resources from low-level hills will
* spawn in high level hills as well. Examples: 3 level - diamond, lapis, emerald; 2 level - gold,
* redstone; 1 level - iron, coal, glowstone
* @param weight How often should resource generate comparing to other resources of the same level. I.e. the
* larger this number is, the more often this resource will generate. Examples: diamond, lapis - 2;
* emerald - 1 | redstone - 2, gold - 1 | iron, coal - 2, glowstone - 1
*/
public static void addStalactite(Block block, int meta, float size, int hillLevel, int weight) {
addStalactite(block, meta, size, -1, -1, hillLevel, weight);
}

/**
* For other mods to add stalactites made of their blocks
*
* @param block Block to generate stalactite of. Most likely ore
* @param size How much space between ceiling and floor stalactite takes. From 0.0f to 1.0f
* @param hillLevel Level of the hill for the resource to spawn in. From 1 to 3. Resources from low-level hills will
* spawn in high level hills as well. Examples: 3 level - diamond, lapis, emerald; 2 level - gold,
* redstone; 1 level - iron, coal, glowstone
* @param weight How often should resource generate comparing to other resources of the same level. I.e. the
* larger this number is, the more often this resource will generate. Examples: diamond, lapis - 2;
* emerald - 1 | redstone - 2, gold - 1 | iron, coal - 2, glowstone - 1
*/
public static void addStalactite(Block block, float size, int hillLevel, int weight) {
addStalactite(block, 0, size, -1, -1, hillLevel, weight);
}

public static void addStalactite(TFGenCaveStalactite stalactite, int hillLevel, int weight) {
for (int i = 0; i < weight; i++) switch (hillLevel) {
default:
case 1:
hill1.add(stalactite);
break;
case 2:
hill2.add(stalactite);
break;
case 3:
hill3.add(stalactite);
break;
}
}

public static void registerVanillaStalactites() {
addStalactite(diamond, 3, 2);
addStalactite(lapis, 3, 2);
addStalactite(emerald, 3, 1);

addStalactite(redstone, 2, 2);
addStalactite(gold, 2, 1);

addStalactite(iron, 1, 2);
addStalactite(coal, 1, 2);
addStalactite(glowstone, 1, 1);
}

/**
* Makes a random stalactite appropriate to the cave size
*
Expand All @@ -60,33 +185,17 @@ public TFGenCaveStalactite(Block blockType, float size, int maxLength, int minHe
*/
public static TFGenCaveStalactite makeRandomOreStalactite(Random rand, int hillSize) {
if (hillSize >= 3 || (hillSize >= 2 && rand.nextInt(5) == 0)) {
int s3 = rand.nextInt(13);
if (s3 == 0 || s3 == 1) {
return diamond;
} else if (s3 == 2 || s3 == 3) {
return lapis;
} else if (s3 == 4) {
return emerald;
}
if (rand.nextInt(13) <= 4) // To keep vanilla generation chances
return hill3.get(rand.nextInt(hill3.size()));
}

if (hillSize >= 2 || (hillSize >= 1 && rand.nextInt(5) == 0)) {
int s2 = rand.nextInt(6);
if (s2 == 0) {
return gold;
} else if (s2 == 1 || s2 == 2) {
return redstone;
}
if (rand.nextInt(6) <= 2) // To keep vanilla generation chances
return hill2.get(rand.nextInt(hill2.size()));
}

// fall through to size 1
int s1 = rand.nextInt(5);
if (s1 == 0 || s1 == 1) {
return iron;
} else if (s1 == 2 || s1 == 3) {
return coal;
} else {
return glowstone;
}
return hill1.get(rand.nextInt(hill1.size()));
}

/**
Expand Down Expand Up @@ -180,7 +289,7 @@ public boolean makeSpike(World world, Random random, int x, int y, int z, int ma
}

for (int dy = 0; dy != (spikeLength * dir); dy += dir) {
setBlock(world, x + dx, y + dy, z + dz, blockID);
setBlockAndMetadata(world, x + dx, y + dy, z + dz, blockID, blockMeta);
}
}
}
Expand Down