diff --git a/.gitignore b/.gitignore index 27a8ae0f17..5e80e0ae57 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,4 @@ addon.local.gradle addon.local.gradle.kts addon.late.local.gradle addon.late.local.gradle.kts -layout.json \ No newline at end of file +layout.json diff --git a/dependencies.gradle b/dependencies.gradle index 6ec12933ef..b6ebdfa530 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,6 +2,7 @@ dependencies { compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false} + compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.53:dev") compileOnly("curse.maven:skinport-234948:3212017") // For Thaumcraft runtime diff --git a/src/main/java/twilightforest/TFFeature.java b/src/main/java/twilightforest/TFFeature.java index 470db54448..3852c073fd 100644 --- a/src/main/java/twilightforest/TFFeature.java +++ b/src/main/java/twilightforest/TFFeature.java @@ -379,6 +379,18 @@ public static TFFeature generateFeatureForOldMapGen(int chunkX, int chunkZ, Worl } public static TFFeature generateFeatureFor1Point7(int chunkX, int chunkZ, World world) { + + // get random value + Random hillRNG = new Random(world.getSeed() + chunkX * 25117L + chunkZ * 151121L); + + // Modify major features (Bosses) generation rate + // 100% = default + // 50% = only 50% generation chance from default chance + + if (!getRandom(hillRNG, TwilightForestMod.majorFeatureGenChance)) { + return nothing; + } + if (TwilightForestMod.oldMapGen) { return generateFeatureForOldMapGen(chunkX, chunkZ, world); } @@ -390,8 +402,6 @@ public static TFFeature generateFeatureFor1Point7(int chunkX, int chunkZ, World // what biome is at the center of the chunk? BiomeGenBase biomeAt = world.getBiomeGenForCoords((chunkX << 4) + 8, (chunkZ << 4) + 8); - // get random value - Random hillRNG = new Random(world.getSeed() + chunkX * 25117L + chunkZ * 151121L); int randnum = hillRNG.nextInt(16); // glaciers have ice towers @@ -548,7 +558,6 @@ public static TFFeature getFeatureForRegion(int chunkX, int chunkZ, World world) * * @param cx * @param cz - * @param seed * @return */ public static int[] getNearestCenter(int cx, int cz, World world) { @@ -839,4 +848,8 @@ public ItemStack createHintBook() { return book; } + public static boolean getRandom(Random r, double chanceMul) { + return ((r.nextDouble() * 100d) < chanceMul); + + } } diff --git a/src/main/java/twilightforest/TwilightForestMod.java b/src/main/java/twilightforest/TwilightForestMod.java index 23d0e21ef8..9d1cd093ab 100644 --- a/src/main/java/twilightforest/TwilightForestMod.java +++ b/src/main/java/twilightforest/TwilightForestMod.java @@ -9,6 +9,7 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; import baubles.api.BaubleType; import cpw.mods.fml.common.FMLCommonHandler; @@ -29,6 +30,7 @@ import twilightforest.biomes.TFBiomeBase; import twilightforest.block.TFBlocks; import twilightforest.entity.TFCreatures; +import twilightforest.gt_integration.GT_Integration_Utils; import twilightforest.item.BehaviorTFMobEggDispense; import twilightforest.item.ItemTFMagicMap; import twilightforest.item.ItemTFMazeMap; @@ -57,6 +59,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) @@ -97,6 +100,34 @@ public class TwilightForestMod { public static float canopyCoverage; public static int twilightOakChance; + // Ore Balance + + public static double stalactiteOrePopulationDensity = 75; + public static boolean gregifyStalactiteOres; + + public static boolean diamondOreStal; + public static boolean lapisOreStal; + public static boolean emeraldOreStal; + public static boolean goldOreStal; + public static boolean redstoneOreStal; + public static boolean ironOreStal; + public static boolean coalOreStal; + public static boolean glowstoneStal; + + public static boolean GT_useSmallOres; + + public static int GT_diamondOreMeta; + public static int GT_lapisOreMeta; + public static int GT_emeraldOreMeta; + public static int GT_goldOreMeta; + public static int GT_redstoneOreMeta; + public static int GT_ironOreMeta; + public static int GT_coalOreMeta; + + // Major feature spawn chance + public static double majorFeatureGenChance = 100; + public static double minorFeatureGenChance = 14; + public static int idMobWildBoar; public static int idMobBighornSheep; public static int idMobWildDeer; @@ -336,6 +367,16 @@ public void postInit(FMLPostInitializationEvent evt) { FMLLog.info("[TwilightForest] Did not find Thaumcraft, did not load ThaumcraftApi integration."); } + // GT Ore + if (Loader.isModLoaded("gregtech") && gregifyStalactiteOres) { + // Doing + GT_Integration_Utils.init(); + } else { + FMLLog.warning("[TwilightForest] Did not load Gregtech integration."); + // Disable + gregifyStalactiteOres = false; + } + // final check for biome ID conflicts TwilightForestMod.hasBiomeIdConflicts = TFBiomeBase.areThereBiomeIdConflicts(); } @@ -945,6 +986,46 @@ private void loadConfiguration(Configuration configFile) { "TwilightOakChance", 48).comment = "Chance that a chunk in the Twilight Forest will contain a twilight oak tree. Higher numbers reduce the number of trees, increasing performance."; + // Ore in Stalactites + // Toggle gen + + diamondOreStal = configFile.get("Stalactites", "Diamond Ore Stalactites", true).getBoolean(true); + lapisOreStal = configFile.get("Stalactites", "Lapis Ore Stalactites", true).getBoolean(true); + emeraldOreStal = configFile.get("Stalactites", "Emerald Ore Stalactites", true).getBoolean(true); + goldOreStal = configFile.get("Stalactites", "Gold Ore Stalactites", true).getBoolean(true); + redstoneOreStal = configFile.get("Stalactites", "Redstone Ore Stalactites", true).getBoolean(true); + ironOreStal = configFile.get("Stalactites", "Iron Ore Stalactites", true).getBoolean(true); + coalOreStal = configFile.get("Stalactites", "Coal Ore Stalactites", true).getBoolean(true); + glowstoneStal = configFile.get("Stalactites", "Glowstone Stalactites", true).getBoolean(true); + + // Toggle ore + TFGenCaveStalactite.configStalactites(); + + gregifyStalactiteOres = configFile.get("Stalactites", "Use Gregified ores", false).getBoolean(false); + + if (gregifyStalactiteOres) { + // GT Ore Mapping + // Show More config + GT_useSmallOres = configFile.get("GT_OreMapping", "GT_UseSmallOres", false).getBoolean(false); + GT_coalOreMeta = configFile.get("GT_OreMapping", "GT_coalOreMeta", 535).getInt(); + GT_lapisOreMeta = configFile.get("GT_OreMapping", "GT_lapisOreMeta", 526).getInt(); + GT_redstoneOreMeta = configFile.get("GT_OreMapping", "GT_redstoneOreMeta", 810).getInt(); + GT_emeraldOreMeta = configFile.get("GT_OreMapping", "GT_emeraldOreMeta", 501).getInt(); + GT_diamondOreMeta = configFile.get("GT_OreMapping", "GT_diamondOreMeta", 500).getInt(); + GT_ironOreMeta = configFile.get("GT_OreMapping", "GT_ironOreMeta", 32).getInt(); + GT_goldOreMeta = configFile.get("GT_OreMapping", "GT_goldOreMeta", 86).getInt(); + + } + + // Gen chance + Property majorGenChance = configFile.get("WorldGen", "Major Feature Generation Chance", 100); + majorGenChance.comment = "IT IS NOT RECOMMENDED TO CHANGE ON AN ALREADY CREATED WORLD! Since old dungeons can change/don't showing the icon on the magic map or will not be generated completely"; + majorFeatureGenChance = majorGenChance.getDouble(); + + minorFeatureGenChance = configFile.get("WorldGen", "Minor Feature Generation Chance", 14).getDouble(14); + + stalactiteOrePopulationDensity = configFile.get("WorldGen", "Ore density in stalactites", 100).getDouble(100); + // fixed values, don't even read the config idMobWildBoar = 177; idMobBighornSheep = 178; diff --git a/src/main/java/twilightforest/biomes/TFBiomeDecorator.java b/src/main/java/twilightforest/biomes/TFBiomeDecorator.java index 5942e4b3fb..336ed355af 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeDecorator.java +++ b/src/main/java/twilightforest/biomes/TFBiomeDecorator.java @@ -158,7 +158,8 @@ protected void genDecorations(BiomeGenBase biome) { } // random features! - if (randomGenerator.nextInt(6) == 0) { + // now with chance + if (TFFeature.getRandom(randomGenerator, TwilightForestMod.minorFeatureGenChance)) { int rx = chunk_X + randomGenerator.nextInt(16) + 8; int rz = chunk_Z + randomGenerator.nextInt(16) + 8; int ry = currentWorld.getHeightValue(rx, rz); @@ -166,6 +167,7 @@ protected void genDecorations(BiomeGenBase biome) { TFGenerator rf = randomFeature(randomGenerator); rf.generate(currentWorld, randomGenerator, rx, ry, rz); } + } // add canopy trees diff --git a/src/main/java/twilightforest/gt_integration/GT_Integration_Utils.java b/src/main/java/twilightforest/gt_integration/GT_Integration_Utils.java new file mode 100644 index 0000000000..527564c0a5 --- /dev/null +++ b/src/main/java/twilightforest/gt_integration/GT_Integration_Utils.java @@ -0,0 +1,27 @@ +package twilightforest.gt_integration; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class GT_Integration_Utils { + + private static GT_OrePlacer orePlacer; + + public static void init() { + // Create worker obj + orePlacer = new GT_OrePlacer(); + + } + + public static boolean isInit() { + return orePlacer != null; + } + + public static boolean doPlaceGTOre(World aWorld, int aX, int aY, int aZ, Block mcOreBlock) { + if (!isInit()) { + return false; + } + return orePlacer.placeGTOre(aWorld, aX, aY, aZ, mcOreBlock); + } + +} diff --git a/src/main/java/twilightforest/gt_integration/GT_OrePlacer.java b/src/main/java/twilightforest/gt_integration/GT_OrePlacer.java new file mode 100644 index 0000000000..e83e926cdd --- /dev/null +++ b/src/main/java/twilightforest/gt_integration/GT_OrePlacer.java @@ -0,0 +1,54 @@ +package twilightforest.gt_integration; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +import gregtech.common.blocks.GT_TileEntity_Ores; +import twilightforest.TwilightForestMod; + +public class GT_OrePlacer { + + public int getMappedGTMetaForOre(Block mOre) { + + if (mOre == Blocks.coal_ore) { + return TwilightForestMod.GT_coalOreMeta; + } + + if (mOre == Blocks.iron_ore) { + return TwilightForestMod.GT_ironOreMeta; + + } + if (mOre == Blocks.gold_ore) { + return TwilightForestMod.GT_goldOreMeta; + } + + if (mOre == Blocks.redstone_ore) { + return TwilightForestMod.GT_redstoneOreMeta; + } + + if (mOre == Blocks.lapis_ore) { + return TwilightForestMod.GT_lapisOreMeta; + } + + if (mOre == Blocks.emerald_ore) { + return TwilightForestMod.GT_emeraldOreMeta; + } + if (mOre == Blocks.diamond_ore) { + return TwilightForestMod.GT_diamondOreMeta; + } + + return -1; + } + + public boolean placeGTOre(World aWorld, int aX, int aY, int aZ, Block mcOreBlock) { + + int mappedMeta = getMappedGTMetaForOre(mcOreBlock); + if (mappedMeta <= 0) { + return false; + } + return GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, mappedMeta, TwilightForestMod.GT_useSmallOres, true); + + } + +} diff --git a/src/main/java/twilightforest/world/TFGenCaveStalactite.java b/src/main/java/twilightforest/world/TFGenCaveStalactite.java index 673845f35d..47317b6360 100644 --- a/src/main/java/twilightforest/world/TFGenCaveStalactite.java +++ b/src/main/java/twilightforest/world/TFGenCaveStalactite.java @@ -7,6 +7,10 @@ import net.minecraft.init.Blocks; import net.minecraft.world.World; +import twilightforest.TFFeature; +import twilightforest.TwilightForestMod; +import twilightforest.gt_integration.GT_Integration_Utils; + public class TFGenCaveStalactite extends TFGenerator { public static TFGenCaveStalactite diamond = new TFGenCaveStalactite(Blocks.diamond_ore, 0.5F, 4, 16); @@ -24,6 +28,8 @@ public class TFGenCaveStalactite extends TFGenerator { public int maxLength; public int minHeight; + public boolean doOreGen; + /** * Initializes a stalactite builder. Actually also makes stalagmites * @@ -153,6 +159,11 @@ public boolean generate(World world, Random random, int x, int y, int z) { public boolean makeSpike(World world, Random random, int x, int y, int z, int maxLength) { + // Disable ore gen + if (!doOreGen) { + blockID = Blocks.stone; + } + int diameter = (int) (maxLength / 4.5); // diameter of the base // let's see... @@ -180,7 +191,35 @@ 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); + + // Density + if (TFFeature.getRandom(random, TwilightForestMod.stalactiteOrePopulationDensity)) { + + // Just set mcOre + if (TwilightForestMod.gregifyStalactiteOres && doOreGen) { + // Stone block before place gtOre + + // Glowstone Stalactite + if (this.blockID == Blocks.glowstone) { + setBlock(world, x + dx, y + dy, z + dz, Blocks.glowstone); + + } else { + setBlock(world, x + dx, y + dy, z + dz, Blocks.stone); + // Slap GT ore over + GT_Integration_Utils.doPlaceGTOre(world, x + dx, y + dy, z + dz, blockID); + + } + + } else { + // Place MC Ore + setBlock(world, x + dx, y + dy, z + dz, blockID); + } + + } else { + // No ore just place stone + setBlock(world, x + dx, y + dy, z + dz, Blocks.stone); + } + } } } @@ -188,4 +227,21 @@ public boolean makeSpike(World world, Random random, int x, int y, int z, int ma return true; } + public static void configStalactites() { + + diamond.setDoOreGen(TwilightForestMod.diamondOreStal); + lapis.setDoOreGen(TwilightForestMod.lapisOreStal); + emerald.setDoOreGen(TwilightForestMod.emeraldOreStal); + gold.setDoOreGen(TwilightForestMod.goldOreStal); + redstone.setDoOreGen(TwilightForestMod.redstoneOreStal); + iron.setDoOreGen(TwilightForestMod.ironOreStal); + coal.setDoOreGen(TwilightForestMod.coalOreStal); + glowstone.setDoOreGen(TwilightForestMod.glowstoneStal); + + } + + public void setDoOreGen(boolean doGenOre) { + this.doOreGen = doGenOre; + } + }