diff --git a/dependencies.gradle b/dependencies.gradle index 34788eaeed..a57b1ac59a 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,10 +2,12 @@ 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.12.6-GTNH:dev") compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:api") {} //For TiC to work compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.6.26-GTNH:dev") compileOnly("curse.maven:skinport-234948:3212017") + compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.49.05:dev") // Temporary option compileOnly("com.github.GTNewHorizons:Mobs-Info:0.4.2-GTNH:dev") // For Thaumcraft runtime diff --git a/src/main/java/twilightforest/TwilightForestMod.java b/src/main/java/twilightforest/TwilightForestMod.java index b69c1159dd..e07530a0bb 100644 --- a/src/main/java/twilightforest/TwilightForestMod.java +++ b/src/main/java/twilightforest/TwilightForestMod.java @@ -64,6 +64,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) @@ -249,6 +250,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"); diff --git a/src/main/java/twilightforest/world/GTGenCaveStalactite.java b/src/main/java/twilightforest/world/GTGenCaveStalactite.java new file mode 100644 index 0000000000..15abf8b98e --- /dev/null +++ b/src/main/java/twilightforest/world/GTGenCaveStalactite.java @@ -0,0 +1,28 @@ +package twilightforest.world; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.common.blocks.GT_TileEntity_Ores; + +public class GTGenCaveStalactite extends TFGenCaveStalactite { + + boolean isSmallOre; + boolean air; + + /** + * Initializes a stalactite builder + */ + public GTGenCaveStalactite(int meta, float size, int maxLength, int minHeight, boolean isSmallOre, boolean air) { + super(GregTech_API.sBlockOres1, meta, size, maxLength, minHeight); + this.isSmallOre = isSmallOre; + this.air = air; + } + + @Override + protected void setBlockAndMetadata(World world, int x, int y, int z, Block block, int meta) { + GT_TileEntity_Ores.setOreBlock(world, x, y, z, blockMeta, isSmallOre, air); + } + +} diff --git a/src/main/java/twilightforest/world/TFGenCaveStalactite.java b/src/main/java/twilightforest/world/TFGenCaveStalactite.java index 673845f35d..a3085b5f34 100644 --- a/src/main/java/twilightforest/world/TFGenCaveStalactite.java +++ b/src/main/java/twilightforest/world/TFGenCaveStalactite.java @@ -1,5 +1,7 @@ package twilightforest.world; +import java.util.ArrayList; +import java.util.List; import java.util.Random; import net.minecraft.block.Block; @@ -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 hill3 = new ArrayList(); + private static List hill2 = new ArrayList(); + private static List hill1 = new ArrayList(); + public Block blockID; + public int blockMeta; public boolean hang; public float sizeFactor; public int maxLength; @@ -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; @@ -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 * @@ -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())); } /** @@ -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); } } }