Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mDiyo committed Sep 9, 2013
2 parents 20cbb58 + 154bf98 commit 09685b2
Show file tree
Hide file tree
Showing 5 changed files with 89 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 @@ -84,7 +86,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 @@ -147,6 +150,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;
}
35 changes: 35 additions & 0 deletions src/tconstruct/compat/dimensions/dimblacklist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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);
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){
if (dim<0)
return false;
if(PHConstruct.slimeIslGenDim0Only && dim != 0){
return false;
}
for (int len = 0;len< blacklist.size(); len++){
if (blacklist.get(len) == dim)
return false;
}
return true;

}
}
12 changes: 10 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 @@ -356,7 +356,11 @@ 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",new int[]{}).getIntList();
slimeIslGenDim0Only = config.get("DimBlackList","GenerateSlimeIslandInDim0Only" , false).getBoolean(false);

/* Save the configuration file */
config.save();

Expand Down Expand Up @@ -673,4 +677,8 @@ public static void initProps (File location)

//Looks
public static int connectedTexturesMode;
public static File cfglocation;
//dimensionblacklist
public static boolean slimeIslGenDim0Only;
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 09685b2

Please sign in to comment.