11package com .fgtxray .config ;
22
3+ import com .fgtxray .reference .OreInfo ;
4+ import net .minecraft .block .Block ;
5+ import net .minecraft .init .Blocks ;
6+ import net .minecraftforge .common .config .Configuration ;
7+ import net .minecraftforge .oredict .OreDictionary ;
8+
39import java .util .ArrayList ;
410import java .util .HashMap ;
511import java .util .List ;
612import java .util .Map ;
713import java .util .Map .Entry ;
814
9- import com .fgtxray .reference .OreInfo ;
10-
11- import net .minecraft .block .Block ;
12- import net .minecraft .init .Blocks ;
13- import net .minecraftforge .common .config .Configuration ;
14-
1515public class DefaultConfig {
1616 // Below are the 'default' ores/blocks to add through the ore dictionary.
17- final static Map <String , OreInfo > defaults = new HashMap <String , OreInfo >()
17+ private final static Map <String , OreInfo > defaults = new HashMap <String , OreInfo >()
1818 {{
1919 put ("oreLapis" , new OreInfo ("Lapis" , 0 , 0 , new int []{0 , 0 , 255 }, false ) );
2020 put ("oreCopper" , new OreInfo ("Copper" , 0 , 0 , new int []{204 , 102 , 0 }, true ) );
@@ -26,44 +26,47 @@ public class DefaultConfig {
2626 put ("oreDiamond" , new OreInfo ("Diamond" , 0 , 0 , new int []{136 , 136 , 255 }, false ) );
2727 put ("blockDiamond" , new OreInfo ("Diamond Block" , 0 , 0 , new int []{136 , 136 , 255 }, false ) );
2828 put ("oreEmerald" , new OreInfo ("Emerald" , 0 , 0 , new int []{0 , 136 , 10 }, true ) );
29- put ("blockGold " , new OreInfo ("Gold Block " , 0 , 0 , new int []{255 , 255 , 0 }, false ) );
29+ put ("oreGold " , new OreInfo ("Gold" , 0 , 0 , new int []{255 , 255 , 0 }, false ) );
3030 put ("oreRedstone" , new OreInfo ("Redstone" , 0 , 0 , new int []{255 , 0 , 0 }, false ) );
3131 put ("oreIron" , new OreInfo ("Iron" , 0 , 0 , new int []{170 , 117 , 37 }, false ) );
3232 put ("oreSilver" , new OreInfo ("Silver" , 0 , 0 , new int []{143 ,143 ,143 }, false ) );
33- put ("mossystone" , new OreInfo ("Mossy Stone" , 0 , 0 , new int []{0 , 0 , 255 }, false ) );
3433 put ("oreQuartz" , new OreInfo ("Quartz" , 0 , 0 , new int []{30 ,74 ,0 }, false ) );
3534 put ("oreCoal" , new OreInfo ("Coal" , 0 , 0 , new int []{0 , 0 , 0 }, false ) );
3635 put ("blockGlass" , new OreInfo ("Glass" , 0 , 0 , new int []{136 , 136 , 255 }, false ) );
3736 }};
38-
37+
3938 // Default block to add. Mostly just so people can add custom blocks manually through the config until I setup a gui for it.
40- final static List <OreInfo > custom = new ArrayList <OreInfo >()
39+ private final static List <OreInfo > custom = new ArrayList <OreInfo >()
4140 {{
4241 add ( new OreInfo ("Redstone Wire" , Block .getIdFromBlock ( Blocks .REDSTONE_WIRE ), 0 , new int []{255 , 0 , 0 }, false ) );
4342 add ( new OreInfo ("Chest" , Block .getIdFromBlock ( Blocks .CHEST ), 0 , new int []{255 , 0 , 255 }, true ) );
4443 }};
45-
44+
4645
4746 public static void create (Configuration config ) // Put default blocks and settings into the config file.
4847 {
49- config .get (config .CATEGORY_GENERAL , "searchdist" , 0 ); // Default search distance is index 0 (8)
50-
48+ config .get (Configuration .CATEGORY_GENERAL , "searchdist" , 0 ); // Default search distance is index 0 (8)
49+
5150 for ( Entry <String , OreInfo > ore : defaults .entrySet () )
5251 {
5352 String key = ore .getKey ();
5453 OreInfo value = ore .getValue ();
54+
55+ if ( !OreDictionary .doesOreNameExist ( key ) )
56+ continue ;
57+
5558 String category = value .oreName .replaceAll ("\\ s+" , "" ).toLowerCase (); // No whitespace or capitals in the config file categories
56-
59+
5760 config .get ("oredict." +category , "dictname" , "SOMETHINGBROKE" ).set ( key ); // We need the capitals for the ore dictionary.
5861 config .get ("oredict." +category , "guiname" , "SOMETHINGBROKE" ).set ( value .oreName );
59- config .get ("oredict." +category , "id" , -1 ).set ( value . id );
62+ config .get ("oredict." +category , "id" , -1 ).set ( OreDictionary . getOreID ( key ) );
6063 config .get ("oredict." +category , "meta" , -1 ).set ( value .meta );
6164 config .get ("oredict." +category , "red" , -1 ).set ( value .color [0 ] );
6265 config .get ("oredict." +category , "green" , -1 ).set ( value .color [1 ] );
6366 config .get ("oredict." +category , "blue" , -1 ).set ( value .color [2 ] );
6467 config .get ("oredict." +category , "enabled" , false ).set ( value .draw );
6568 }
66-
69+
6770 for ( OreInfo ore : custom ) // Put custom block into the config file.
6871 {
6972 String name = ore .oreName .replaceAll ("\\ s+" , "" ).toLowerCase (); // No whitespace or capitals in the config file categories.
@@ -75,6 +78,6 @@ public static void create(Configuration config) // Put default blocks and settin
7578 config .get ("customores." +name , "blue" , -1 ).set ( ore .color [2 ] );
7679 config .get ("customores." +name , "enabled" , false ).set ( ore .draw );
7780 }
78-
81+
7982 }
8083}
0 commit comments