@ -1,12 +1,12 @@
package net.brokenmoon.afloydironchest ;
import com.moandjiezana.toml.Toml ;
import net.brokenmoon.afloydironchest.blocks.DiamondChest ;
import net.brokenmoon.afloydironchest.blocks.IronChest ;
import net.brokenmoon.afloydironchest.blocks.GoldChest ;
import net.brokenmoon.afloydironchest.blocks.SteelChest ;
import net.fabricmc.api.ModInitializer ;
import net.minecraft.src.Block ;
import net.minecraft.src.BlockChest ;
import net.minecraft.src.Item ;
import net.minecraft.src.Material ;
import org.slf4j.Logger ;
@ -14,32 +14,51 @@ import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.BlockHelper ;
import turniplabs.halplibe.helper.RecipeHelper ;
import java.io.* ;
public class IronChestMain implements ModInitializer {
public static final String MOD_ID = "ironchest" ;
public static final Logger LOGGER = LoggerFactory . getLogger ( MOD_ID ) ;
public static Block IronChest = BlockHelper . createBlock ( MOD_ID , new IronChest ( 900 , Material . iron ) , "ironchest" ,
"ironchesttop.png" , "ironchestbottom.png" ,
"ironchestfront.png" , "ironchestside.png" , "ironchestside.png" , "ironchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
public static Block GoldChest = BlockHelper . createBlock ( MOD_ID , new GoldChest ( 901 , Material . iron ) , "goldchest" ,
"goldchesttop.png" , "goldchestbottom.png" ,
"goldchestfront.png" , "goldchestside.png" , "goldchestside.png" , "goldchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
public static Block DiamondChest = BlockHelper . createBlock ( MOD_ID , new DiamondChest ( 902 , Material . iron ) , "diamondchest" ,
"diamondchesttop.png" , "diamondchestbottom.png" ,
"diamondchestfront.png" , "diamondchestside.png" , "diamondchestside.png" , "diamondchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
public static Block SteelChest = BlockHelper . createBlock ( MOD_ID , new SteelChest ( 903 , Material . iron ) , "steelchest" ,
"steelchesttop.png" , "steelchestbottom.png" ,
"steelchestfront.png" , "steelchestside.png" , "steelchestside.png" , "steelchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
public static Block IronChest ;
public static Block GoldChest ;
public static Block DiamondChest ;
public static Block SteelChest ;
@Override
public void onInitialize ( ) {
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 ( ) ;
//Blocks
IronChest = BlockHelper . createBlock ( MOD_ID , new IronChest ( ironChestId , Material . iron ) , "ironchest" ,
"ironchesttop.png" , "ironchestbottom.png" ,
"ironchestfront.png" , "ironchestside.png" , "ironchestside.png" , "ironchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
GoldChest = BlockHelper . createBlock ( MOD_ID , new GoldChest ( goldChestId , Material . iron ) , "goldchest" ,
"goldchesttop.png" , "goldchestbottom.png" ,
"goldchestfront.png" , "goldchestside.png" , "goldchestside.png" , "goldchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
DiamondChest = BlockHelper . createBlock ( MOD_ID , new DiamondChest ( diamondChestId , Material . iron ) , "diamondchest" ,
"diamondchesttop.png" , "diamondchestbottom.png" ,
"diamondchestfront.png" , "diamondchestside.png" , "diamondchestside.png" , "diamondchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
SteelChest = BlockHelper . createBlock ( MOD_ID , new SteelChest ( steelChestId , Material . iron ) , "steelchest" ,
"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" ,
"ABA" ,
@ -76,4 +95,31 @@ public class IronChestMain implements ModInitializer {
'B' , GoldChest
} ) ;
}
}
public static 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" ) ;
out = new FileOutputStream ( config ) ;
byte [ ] buffer = new byte [ 1024 ] ;
int length ;
while ( ( length = in . read ( buffer ) ) > 0 ) {
out . write ( buffer , 0 , length ) ;
}
return getConfig ( ) ;
} catch ( IOException e ) {
throw new RuntimeException ( e ) ;
}
} else {
LOGGER . info ( "Config for afloydironchest loaded!" ) ;
return config ;
}
}
}