@ -15,6 +15,8 @@ import turniplabs.halplibe.helper.BlockHelper;
import turniplabs.halplibe.helper.RecipeHelper ;
import java.io.* ;
import java.net.URISyntaxException ;
import java.net.URL ;
public class IronChestMain implements ModInitializer {
@ -31,10 +33,10 @@ public class IronChestMain implements ModInitializer {
LOGGER . info ( "AFloydIronChest initialized." ) ;
//Config
Toml toml = new Toml ( ) . read ( this . getConfig ( ) ) ;
int ironChestId = toml . getLong ( "ids.ironChestID" , ( long ) 900 ). intValue ( ) ;
int goldChestId = toml . getLong ( "ids.goldChestID" , ( long ) 901 ). intValue ( ) ;
int diamondChestId = toml . getLong ( "ids.diamondChestID" , ( long ) 902 ). intValue ( ) ;
int steelChestId = toml . getLong ( "ids.steelChestID" , ( long ) 903 ). intValue ( ) ;
int ironChestId = toml . getLong ( "ids.ironChestID" ). intValue ( ) ;
int goldChestId = toml . getLong ( "ids.goldChestID" ). intValue ( ) ;
int diamondChestId = toml . getLong ( "ids.diamondChestID" ). intValue ( ) ;
int steelChestId = toml . getLong ( "ids.steelChestID" ). intValue ( ) ;
//Blocks
@ -57,7 +59,6 @@ public class IronChestMain implements ModInitializer {
"steelchesttop.png" , "steelchestbottom.png" ,
"steelchestfront.png" , "steelchestside.png" , "steelchestside.png" , "steelchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
//Recipes
RecipeHelper . Crafting . createRecipe ( IronChest , 1 , new Object [ ] {
"AAA" ,
@ -96,17 +97,14 @@ public class IronChestMain implements ModInitializer {
} ) ;
}
public static File getConfig ( ) {
public File getConfig ( ) {
File config = new File ( "config/AstoriaIronChest.toml" ) ;
if ( ! config . exists ( ) ) {
LOGGER . warn ( "Config For afloydironchest Not Found! Creating new config based upon default :)" ) ;
InputStream in ;
OutputStream out ;
try {
File configDir = new File ( "config" ) ;
if ( ! configDir . exists ( ) )
configDir . mkdir ( ) ;
in = IronChestMain . class . getClassLoader ( ) . getResourceAsStream ( "assets/ironchest/config.toml" ) ;
in = new FileInputStream ( getDefaultConfig ( ) ) ;
out = new FileOutputStream ( config ) ;
byte [ ] buffer = new byte [ 1024 ] ;
int length ;
@ -122,4 +120,18 @@ public class IronChestMain implements ModInitializer {
return config ;
}
}
public File getDefaultConfig ( ) {
URL defaultConfig = getClass ( ) . getClassLoader ( ) . getResource ( "assets/ironchest/config.toml" ) ;
if ( defaultConfig = = null ) {
LOGGER . warn ( "Default Config For afloydironchest Not Found! REAL BAD." ) ;
} else {
try {
return new File ( defaultConfig . toURI ( ) ) ;
} catch ( URISyntaxException e ) {
throw new RuntimeException ( e ) ;
}
}
return null ;
}
}