add in parsing of TwilightForest config to get its dimension ID, addition of blacklist for slime island generation in ages, config option to add to that list.

This commit is contained in:
Progwml6 committed 2013-09-08 23:36:25 -04:00
1 parent 44afbcd654
commit b5fd27013c
5 files changed
+81 -4

No files matched your search

+6 -1
View File
@@ -4,6 +4,8 @@ import net.minecraftforge.common.MinecraftForge;
import tconstruct.client.event.EventCloakRender;
import tconstruct.common.TContent;
import tconstruct.common.TProxyCommon;
import tconstruct.compat.Tforest;
import tconstruct.compat.dimensions.dimblacklist;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.Detailing;
import tconstruct.library.crafting.LiquidCasting;
@@ -73,7 +75,8 @@ public class TConstruct
@EventHandler
public void preInit (FMLPreInitializationEvent event)
{
PHConstruct.initProps(event.getModConfigurationDirectory());
PHConstruct.initProps(event.getModConfigurationDirectory());
TConstructRegistry.materialTab = new TabTools("TConstructMaterials");
TConstructRegistry.toolTab = new TabTools("TConstructTools");
TConstructRegistry.blockTab = new TabTools("TConstructBlocks");
@@ -136,6 +139,8 @@ public class TConstruct
TContent.modRecipes();
content.createEntities();
content.modRecipes();
Tforest.initProps(PHConstruct.cfglocation);
dimblacklist.getbaddimensions();
}
public static LiquidCasting getTableCasting ()
+36
View File
@@ -0,0 +1,36 @@
package tconstruct.compat;
import java.io.File;
import java.io.IOException;
import net.minecraftforge.common.Configuration;
public class Tforest {
public static void initProps (File location)
{
/* Here we will set up the config file for the mod
* First: Create a folder inside the config folder
* Second: Create the actual config file
* Note: Configs are a pain, but absolutely necessary for every mod.
*/
//File file = new File(TConstruct.proxy.getLocation() + "/config");
//file.mkdir();
//File newFile = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop.txt");
File newFile = new File(location + "/TwilightForest.cfg");
if( newFile.exists()){
/* [Forge] Configuration class, used as config method */
Configuration config = new Configuration(newFile);
/* Load the configuration file */
config.load();
tfdimid = config.get("Dimension", "DimensionID", true).getInt();
}
else {
tfdimid = -100;
}
}
public static int tfdimid;
}
@@ -0,0 +1,31 @@
package tconstruct.compat.dimensions;
import java.util.ArrayList;
import tconstruct.compat.Tforest;
import tconstruct.util.PHConstruct;
public class dimblacklist {
public static ArrayList<Integer> blacklist = new ArrayList<Integer>();
public static void getbaddimensions(){
blacklist.add(-1);
blacklist.add(1);
if (Tforest.tfdimid != -100){
blacklist.add(Tforest.tfdimid);
}
if(PHConstruct.cfgDimBlackList.length > 0){
for (int numdim = 0; numdim< PHConstruct.cfgDimBlackList.length; numdim ++){
blacklist.add(PHConstruct.cfgDimBlackList[numdim]);
}
}
}
public static boolean isDimInBlacklist(int dim){
for (int len = 0;len< blacklist.size(); len++){
if (blacklist.get(len) == dim)
return false;
}
return true;
}
}
+6 -2
View File
@@ -33,7 +33,7 @@ public class PHConstruct
/* [Forge] Configuration class, used as config method */
Configuration config = new Configuration(newFile);
cfglocation = location;
/* Load the configuration file */
config.load();
@@ -355,7 +355,8 @@ public class PHConstruct
Property conTexMode = config.get("Looks", "Connected Textures Enabled", true);
conTexMode.comment = "0 = disabled, 1 = enabled, 2 = enabled + ignore stained glass meta";
connectedTexturesMode = conTexMode.getInt(2);
//dimension blacklist
cfgDimBlackList = config.get("DimBlackList", "SlimeIslandDimBlacklist", "").getIntList();
/* Save the configuration file */
config.save();
@@ -671,4 +672,7 @@ public class PHConstruct
//Looks
public static int connectedTexturesMode;
public static File cfglocation;
//dimensionblacklist
public static int[] cfgDimBlackList;
}
+2 -1
View File
@@ -10,6 +10,7 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenerator;
import tconstruct.common.TContent;
import tconstruct.compat.dimensions.dimblacklist;
import tconstruct.util.PHConstruct;
import cpw.mods.fml.common.IWorldGenerator;
@@ -32,7 +33,7 @@ public class SlimeIslandGen extends WorldGenerator implements IWorldGenerator
@Override
public void generate (Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) //IWorldGenerator version
{
if (world.provider.dimensionId == 0 || world.provider.dimensionId >= 2)
if (!dimblacklist.isDimInBlacklist(world.provider.dimensionId))
{
if (random.nextInt(PHConstruct.islandRarity) == 0)
generateIsland(world, random, chunkX * 16, chunkZ * 16);