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.Item; import net.minecraft.src.Material; import org.slf4j.Logger; 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; 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").intValue(); int goldChestId = toml.getLong("ids.goldChestID").intValue(); int diamondChestId = toml.getLong("ids.diamondChestID").intValue(); int steelChestId = toml.getLong("ids.steelChestID").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", "AAA", 'A', Item.ingotIron, 'B', Block.chestPlanksOak }); RecipeHelper.Crafting.createRecipe(IronChest, 1, new Object[]{ "AAA", "ABA", "AAA", 'A', Item.ingotIron, 'B', Block.chestPlanksOakPainted }); RecipeHelper.Crafting.createRecipe(GoldChest, 1, new Object[]{ "AAA", "ABA", "AAA", 'A', Item.ingotGold, 'B', IronChest }); RecipeHelper.Crafting.createRecipe(DiamondChest, 1, new Object[]{ "AAA", "ABA", "AAA", 'A', Item.diamond, 'B', GoldChest }); RecipeHelper.Crafting.createRecipe(SteelChest, 1, new Object[]{ "AAA", "ABA", "AAA", 'A', Item.ingotSteel, 'B', GoldChest }); } 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 { in = getClass().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; } } }