2015-08-18 20:40:55 -04:00
package team.chisel.config ;
2015-01-08 05:46:10 -05:00
2015-08-06 00:00:22 -04:00
import java.util.Locale ;
2015-04-22 21:47:44 -04:00
2015-02-08 23:37:56 -05:00
import net.minecraft.item.ItemDye ;
2015-01-11 20:59:16 +00:00
import net.minecraftforge.common.config.Configuration ;
2015-04-22 21:47:44 -04:00
2015-01-08 05:46:10 -05:00
import org.apache.commons.lang3.StringUtils ;
2015-08-18 20:40:55 -04:00
import team.chisel.Chisel ;
import team.chisel.Features ;
2015-08-25 22:06:38 -04:00
import team.chisel.ctmlib.CTM ;
2014-07-17 22:05:29 +01:00
2015-01-07 19:50:18 -05:00
public class Configurations {
public static Configuration config ;
public static boolean configExists ;
2015-01-09 01:50:32 -05:00
public static double concreteVelocity ;
2015-01-07 19:50:18 -05:00
public static boolean ghostCloud ;
2015-01-09 01:50:32 -05:00
public static int factoryBlockAmount ;
2015-01-07 19:50:18 -05:00
public static boolean allowMossy ;
2015-01-14 11:10:29 +01:00
public static boolean allowSmoothStone ;
2015-01-07 19:50:18 -05:00
public static boolean chiselRecipe ;
public static boolean enableFMP ;
2015-01-09 01:50:32 -05:00
public static boolean chiselStoneToCobbleBricks ;
2015-01-24 23:32:51 -05:00
public static boolean chiselBackToVanillaLeaves ;
2015-01-07 19:50:18 -05:00
public static int marbleAmount ;
public static int limestoneAmount ;
public static int graniteAmount ;
public static int dioriteAmount ;
public static int andesiteAmount ;
2015-01-09 01:50:32 -05:00
public static int particlesTickrate ;
public static boolean oldPillars ;
public static boolean disableCTM ;
2015-03-04 00:27:19 -05:00
public static boolean connectInsideCTM ;
2015-01-09 01:50:32 -05:00
public static boolean blockDescriptions ;
2015-06-23 14:42:37 -04:00
public static boolean imTooGoodForDescriptions ;
2015-01-09 01:50:32 -05:00
public static boolean allowChiselDamage ;
public static int ironChiselMaxDamage ;
public static int diamondChiselMaxDamage ;
2015-02-19 17:13:16 -05:00
public static int obsidianChiselMaxDamage ;
2015-01-09 03:03:37 -05:00
public static boolean ironChiselCanLeftClick ;
2015-01-19 11:23:11 -05:00
public static boolean ironChiselHasModes ;
2015-01-19 21:12:11 -05:00
public static int ironChiselAttackDamage ;
public static int diamondChiselAttackDamage ;
2015-02-19 17:13:16 -05:00
public static int obsidianChiselAttackDamage ;
2015-02-04 20:20:01 -05:00
public static boolean allowChiselCrossColors ;
2015-01-19 11:23:11 -05:00
2015-01-11 11:42:50 -08:00
public static boolean useRoadLineTool ;
public static String getRoadLineTool ;
public static int roadLineToolLevel ;
2015-01-19 11:23:11 -05:00
2015-04-02 14:52:26 -04:00
public static int [] configColors = new int [ ItemDye . field_150923_a . length ] ;
2015-02-08 23:37:56 -05:00
2015-04-12 17:20:08 +01:00
public static boolean fullBlockConcrete ;
2015-01-07 19:50:18 -05:00
public static boolean refreshConfig () {
2015-01-09 01:50:32 -05:00
String category ;
/* general */
category = "general" ;
concreteVelocity = config . get ( category , "concreteVelocity" , 0 . 45 ,
2015-01-07 19:50:18 -05:00
"Traversing concrete roads, players will acceleration to this velocity. For reference, normal running speed is about 0.28. Set to 0 to disable acceleration." ). getDouble ( 0 . 45 );
2015-04-12 17:20:08 +01:00
fullBlockConcrete = config . get ( category , "fullBlockConcrete" , false , "Should concrete be a full block. This will also unavoidably disable speed increase if set to true." ). getBoolean ( false );
2015-01-09 01:50:32 -05:00
ghostCloud = config . get ( category , "doesCloudRenderLikeGhost" , true ). getBoolean ( true );
factoryBlockAmount = config . get ( category , "amountYouGetFromFactoryBlockCrafting" , 32 ). getInt ( 32 );
2015-04-02 14:52:26 -04:00
allowMossy = config . get ( category , "allowBrickToMossyInChisel" , true , "If true, you can chisel stone brick to mossy stone brick." ). getBoolean ( true );
2015-01-14 11:10:29 +01:00
allowSmoothStone = config . get ( category , "allowSmoothStoneToStoneBricksAndBack" , true ). getBoolean ( true );
2015-01-09 01:50:32 -05:00
chiselRecipe = config . get ( category , "chiselAlternateRecipe" , false , "Use alternative crafting recipe for the chisel" ). getBoolean ( false );
enableFMP = config . get ( category , "enableFMP" , true , "Do you want to enable FMP" ). getBoolean ( true );
chiselStoneToCobbleBricks = config . get ( category , "chiselStoneToCobbleBricks" , true , "Chisel stone to cobblestone and bricks by left clicking." ). getBoolean ( false );
2015-04-02 14:52:26 -04:00
chiselBackToVanillaLeaves = config
. get ( category , "chiselBackToVanillaLeaves" , false , "If this is true, you can chisel from the chisel leaves back to vanilla ones. If it is false, you cannot." ). getBoolean ( false );
2015-01-09 01:50:32 -05:00
/* worldgen */
category = "worldgen" ;
marbleAmount = config . get ( category , "marbleAmount" , 7 , "Amount of marble to generate in the world; use 0 for none" ). getInt ( 7 );
limestoneAmount = config . get ( category , "limestoneAmount" , 8 , "Amount of limestone to generate in the world; use 0 for none" ). getInt ( 8 );
graniteAmount = config . get ( category , "graniteAmount" , 8 , "Amount of granite to generate in the world; use 0 for none." ). getInt ( 8 );
dioriteAmount = config . get ( category , "dioriteAmount" , 8 , "Amount of diorite to generate in the world; use 0 for none." ). getInt ( 8 );
andesiteAmount = config . get ( category , "andesiteAmount" , 8 , "Amount of andesite to generate in the world; use 0 for none." ). getInt ( 8 );
/* client */
category = "client" ;
particlesTickrate = config . get ( category , "particleTickrate" , 1 , "Particle tick rate. Greater value = less particles." ). getInt ( 1 );
oldPillars = config . get ( category , "pillarOldGraphics" , false , "Use old pillar textures" ). getBoolean ( false );
disableCTM = ! config . get ( category , "connectedTextures" , true , "Enable connected textures" ). getBoolean ( true );
2015-04-24 16:43:30 -04:00
CTM . disableObscuredFaceCheckConfig = connectInsideCTM = config . get ( category , "connectInsideCTM" , false ,
2015-04-22 21:47:44 -04:00
"Choose whether the inside corner is disconnected on a CTM block - http://imgur.com/eUywLZ4" ). getBoolean ( false );
2015-01-09 01:50:32 -05:00
blockDescriptions = config . get ( category , "tooltipsUseBlockDescriptions" , true , "Make variations of blocks have the same name, and use the description in tooltip to distinguish them." )
2015-01-07 19:50:18 -05:00
. getBoolean ( true );
2015-06-23 15:34:06 -04:00
imTooGoodForDescriptions = config . get ( category , "imTooGoodForBlockDescriptions" , false , "For those people who just hate block descriptions on the world gen!" ). getBoolean ();
2015-01-09 01:50:32 -05:00
/* chisel */
category = "chisel" ;
allowChiselDamage = config . get ( category , "allowChiselDamage" , true , "Should the chisel be damageable and take damage when it chisels something." ). getBoolean ();
2015-02-28 14:12:08 -05:00
ironChiselMaxDamage = config . getInt ( "ironChiselMaxDamage" , category , 500 , 1 , Short . MAX_VALUE , "The max damage of the standard iron chisel." );
diamondChiselMaxDamage = config . getInt ( "diamondChiselMaxDamage" , category , 5000 , 1 , Short . MAX_VALUE , "The max damage of the diamond chisel." );
obsidianChiselMaxDamage = config . getInt ( "obsidianChiselMaxDamage" , category , 2500 , 1 , Short . MAX_VALUE , "The max damage of the obsidian chisel." );
2015-01-09 03:04:39 -05:00
ironChiselCanLeftClick = config . get ( category , "ironChiselCanLeftClick" , true , "If this is true, the iron chisel can left click chisel blocks. If false, it cannot." ). getBoolean ();
2015-01-19 11:23:11 -05:00
ironChiselHasModes = config . get ( category , "ironChiselHasModes" , false , "If this is true, the iron chisel can change its chisel mode just as the diamond chisel can." ). getBoolean ();
2015-02-04 20:20:01 -05:00
allowChiselCrossColors = config . get ( category , "allowChiselCrossColors" , true , "Should someone be able to chisel something into a different color." ). getBoolean ();
2015-04-22 21:56:10 -04:00
2015-04-02 14:52:26 -04:00
ironChiselAttackDamage = config
. get ( category , "ironChiselAttackDamage" , 2 , "The extra attack damage points (in half hearts) that the iron chisel inflicts when it is used to attack an entity." ). getInt ();
diamondChiselAttackDamage = config . get ( category , "diamondChiselAttackDamage" , 2 ,
"The extra attack damage points (in half hearts) that the diamond chisel inflicts when it is used to attack an entity." ). getInt ();
obsidianChiselAttackDamage = config . get ( category , "obsidianChiselAttackDamage" , 4 ,
"The extra attack damage points (in half hearts) that the obsidian chisel inflicts when it is used to attack an entity." ). getInt ();
2015-01-19 11:23:11 -05:00
2015-01-11 11:42:50 -08:00
/* block */
category = "block" ;
useRoadLineTool = config . get ( category , "useRoadLineTool" , false , "Should the road line require a tool to break (If false, road lines can be broken in Adventure)" ). getBoolean ();
2015-01-19 11:23:11 -05:00
getRoadLineTool = config . get ( category , "getRoadLineTool" , "pickaxe" , "The tool that is able to break roadLines (requires useRoadLineTool to be true to take effect)" ). getString ();
roadLineToolLevel = config . get ( category , "roadLineToolLevel" , 0 ,
"The lowest harvest level of the tool able to break the road lines (requires useRoadLineTool to be true to take effect) (0 = Wood/Gold, 1 = Stone, 2 = Iron, 3 = Diamond) Default: 0" )
. getInt ();
2015-04-02 14:52:26 -04:00
/* hexColors */
category = "hexColors" ;
for ( int i = 0 ; i < ItemDye . field_150923_a . length ; i ++ ) {
// tterrag... don't kill me over this formatting.
String temp = config . get ( category , "hex" + ItemDye . field_150923_a [ i ] , "#" + Integer . toHexString ( ItemDye . field_150922_c [ i ] ),
Character . toUpperCase ( ItemDye . field_150923_a [ i ] . charAt ( 0 )) + ItemDye . field_150923_a [ i ] . substring ( 1 ) + " color for hex block overlay #RRGGBB" ). getString ();
// Or this
try {
configColors [ i ] = Integer . decode ( temp );
} catch ( NumberFormatException e ) {
Chisel . logger . warn ( "Configuration error, " + temp + " was not recognized as a color. Using default: #" + Integer . toHexString ( ItemDye . field_150922_c [ i ] ));
configColors [ i ] = ItemDye . field_150922_c [ i ] ;
}
}
2015-02-08 23:37:56 -05:00
2015-01-07 19:50:18 -05:00
if ( config . hasChanged ()) {
config . save ();
}
return true ;
}
2015-01-08 05:46:10 -05:00
public static boolean featureEnabled ( Features feature ) {
return config . get ( "features" , featureName ( feature ), true ). getBoolean ( true ) && refreshConfig ();
}
2015-01-09 01:50:32 -05:00
2015-02-19 17:13:16 -05:00
/**
* Makes the old camelCase names from the new CONSTANT_CASE names
*/
2015-01-19 18:59:25 -05:00
public static String featureName ( Features feature ) {
2015-01-08 05:46:10 -05:00
String [] words = feature . name (). toLowerCase ( Locale . ENGLISH ). split ( "_" );
if ( words . length == 1 ) {
return words [ 0 ] ;
}
2015-01-09 01:50:32 -05:00
2015-01-08 05:46:10 -05:00
String ret = words [ 0 ] ;
for ( int i = 1 ; i < words . length ; i ++ ) {
ret += StringUtils . capitalize ( words [ i ] );
}
return ret ;
2015-01-07 19:50:18 -05:00
}
2015-01-09 01:50:32 -05:00
2015-01-08 05:46:10 -05:00
@Deprecated
2015-01-09 01:50:32 -05:00
public static boolean featureEnabled ( String feature ) {
return false ;
}
2014-07-17 22:05:29 +01:00
}