Skip to content

Commit

Permalink
add in parsing of TwilightForest config to get its dimension ID, addi…
Browse files Browse the repository at this point in the history
…tion of blacklist for slime island generation in ages, config option to add to that list.
  • Loading branch information
progwml6 committed Sep 9, 2013
1 parent 44afbcd commit b5fd270
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/tconstruct/TConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
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;
Expand Down Expand Up @@ -73,7 +75,8 @@ public 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");
Expand Down Expand Up @@ -136,6 +139,8 @@ public void postInit (FMLPostInitializationEvent evt)
TContent.modRecipes();
content.createEntities();
content.modRecipes();
Tforest.initProps(PHConstruct.cfglocation);
dimblacklist.getbaddimensions();
}

public static LiquidCasting getTableCasting ()
Expand Down
36 changes: 36 additions & 0 deletions src/tconstruct/compat/Tforest.java
Original file line number Diff line number Diff line change
@@ -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;
}
31 changes: 31 additions & 0 deletions src/tconstruct/compat/dimensions/dimblacklist.java
Original file line number Diff line number Diff line change
@@ -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;

}
}
8 changes: 6 additions & 2 deletions src/tconstruct/util/PHConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void initProps (File location)

/* [Forge] Configuration class, used as config method */
Configuration config = new Configuration(newFile);

cfglocation = location;
/* Load the configuration file */
config.load();

Expand Down Expand Up @@ -355,7 +355,8 @@ public static void initProps (File location)
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();

Expand Down Expand Up @@ -671,4 +672,7 @@ public static void initProps (File location)

//Looks
public static int connectedTexturesMode;
public static File cfglocation;
//dimensionblacklist
public static int[] cfgDimBlackList;
}
3 changes: 2 additions & 1 deletion src/tconstruct/worldgen/SlimeIslandGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;

Expand All @@ -32,7 +33,7 @@ public SlimeIslandGen(int id, int meta)
@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);
Expand Down

0 comments on commit b5fd270

Please sign in to comment.