mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
universal system for JSON based recipe configuration
This commit is contained in:
parent
3b70d57dde
commit
b01e260db9
@ -262,14 +262,21 @@ public class OreDictManager {
|
||||
/*
|
||||
* COLLECTIONS
|
||||
*/
|
||||
/** Any post oil polymer like teflon ("polymer") or bakelite */
|
||||
public static final DictGroup ANY_PLASTIC = new DictGroup("AnyPlastic", POLYMER, BAKELITE); //using the Any prefix means that it's just the secondary prefix, and that shape prefixes are applicable
|
||||
/** Any "powder" propellant like gunpowder, ballistite and cordite */
|
||||
public static final DictFrame ANY_GUNPOWDER = new DictFrame("AnyPropellant");
|
||||
/** Any smokeless powder like ballistite and cordite */
|
||||
public static final DictFrame ANY_SMOKELESS = new DictFrame("AnySmokeless");
|
||||
/** Any plastic explosive like semtex H or C-4 */
|
||||
public static final DictFrame ANY_PLASTICEXPLOSIVE = new DictFrame("AnyPlasticexplosive");
|
||||
/** Any higher tier high explosive (therefore excluding dynamite) like TNT */
|
||||
public static final DictFrame ANY_HIGHEXPLOSIVE = new DictFrame("AnyHighexplosive");
|
||||
public static final DictFrame ANY_COKE = new DictFrame("AnyCoke", "Coke");
|
||||
public static final DictFrame ANY_CONCRETE = new DictFrame("Concrete"); //no any prefix means that any has to be appended with the any() or anys() getters, registering works with the any (i.e. no shape) setter
|
||||
public static final DictGroup ANY_TAR = new DictGroup("Tar", KEY_OIL_TAR, KEY_COAL_TAR, KEY_CRACK_TAR);
|
||||
/** Any special psot-RBMK gating material, namely bismuth and arsenic */
|
||||
public static final DictFrame ANY_BISMOID = new DictFrame("AnyBismoid");
|
||||
|
||||
public static void registerOres() {
|
||||
|
||||
@ -422,6 +429,7 @@ public class OreDictManager {
|
||||
ANY_HIGHEXPLOSIVE .ingot(ball_tnt);
|
||||
ANY_CONCRETE .any(concrete, concrete_smooth, concrete_colored, concrete_asbestos, ducrete, ducrete_smooth);
|
||||
ANY_COKE .gem(fromAll(coke, EnumCokeType.class));
|
||||
ANY_BISMOID .ingot(ingot_bismuth, ingot_arsenic).nugget(nugget_bismuth, nugget_arsenic).block(block_bismuth);
|
||||
|
||||
OreDictionary.registerOre(KEY_OIL_TAR, fromOne(oil_tar, EnumTarType.CRUDE));
|
||||
OreDictionary.registerOre(KEY_CRACK_TAR, fromOne(oil_tar, EnumTarType.CRACK));
|
||||
|
||||
@ -259,7 +259,7 @@ public class AssemblerRecipes {
|
||||
makeRecipe(new ComparableStack(ModBlocks.seal_frame, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 3), new ComparableStack(ModItems.wire_aluminium, 4), new OreDictStack(REDSTONE.dust(), 2), new ComparableStack(ModBlocks.steel_roof, 5), },50);
|
||||
makeRecipe(new ComparableStack(ModBlocks.seal_controller, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 3), new OreDictStack(ANY_PLASTIC.ingot(), 4), new OreDictStack(MINGRADE.ingot(), 1), new OreDictStack(REDSTONE.dust(), 4), new ComparableStack(ModBlocks.steel_roof, 5), },100);
|
||||
makeRecipe(new ComparableStack(ModBlocks.machine_centrifuge, 1), new AStack[] {new ComparableStack(ModItems.centrifuge_tower, 1), new OreDictStack(STEEL.ingot(), 4), new OreDictStack(IRON.ingot(), 4), new OreDictStack(STEEL.plate(), 2), new OreDictStack(CU.plate(), 2), new ComparableStack(ModItems.wire_red_copper, 8), },250);
|
||||
makeRecipe(new ComparableStack(ModBlocks.machine_gascent, 1), new AStack[] {new ComparableStack(ModItems.centrifuge_tower, 1), new OreDictStack(STEEL.ingot(), 8), new OreDictStack(DESH.ingot(), 2), new ComparableStack(ModItems.coil_tungsten, 4), new ComparableStack(ModItems.wire_red_copper, 32) },300);
|
||||
makeRecipe(new ComparableStack(ModBlocks.machine_gascent, 1), new AStack[] {new ComparableStack(ModItems.centrifuge_tower, 1), new OreDictStack(STEEL.ingot(), 4), new OreDictStack(DESH.ingot(), 2), new ComparableStack(ModItems.coil_tungsten, 4), new ComparableStack(ModItems.wire_red_copper, 16) },300);
|
||||
makeRecipe(new ComparableStack(ModBlocks.machine_rtg_furnace_off, 1), new AStack[] {new ComparableStack(Blocks.furnace, 1), new ComparableStack(ModItems.rtg_unit, 3), new OreDictStack(PB.plate(), 6), new OreDictStack(OreDictManager.getReflector(), 4), new OreDictStack(CU.plate(), 2), },150);
|
||||
makeRecipe(new ComparableStack(ModBlocks.machine_diesel, 1), new AStack[] {new ComparableStack(ModItems.hull_small_steel, 4), new ComparableStack(Blocks.piston, 4), new OreDictStack(STEEL.ingot(), 6), new OreDictStack(MINGRADE.ingot(), 2), new OreDictStack(CU.plate(), 4), new ComparableStack(ModItems.wire_red_copper, 6), },200);
|
||||
makeRecipe(new ComparableStack(ModBlocks.machine_selenium, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 4), new OreDictStack(TI.plate(), 6), new OreDictStack(CU.plate(), 8), new ComparableStack(ModItems.hull_big_steel, 1), new ComparableStack(ModItems.hull_small_steel, 9), new ComparableStack(ModItems.pedestal_steel, 1), new ComparableStack(ModItems.coil_copper, 4), },250);
|
||||
|
||||
@ -1,20 +1,14 @@
|
||||
package com.hbm.inventory.recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.RecipesCommon;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemBreedingRod.*;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class BreederRecipes {
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.hbm.inventory.RecipesCommon;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.items.ModItems;
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ package com.hbm.inventory.recipes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.RecipesCommon;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.machine.TileEntityHadron.EnumHadronState;
|
||||
|
||||
@ -3,21 +3,15 @@ package com.hbm.inventory.recipes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.GeneralConfig;
|
||||
import com.hbm.interfaces.Spaghetti;
|
||||
import com.hbm.inventory.FluidContainer;
|
||||
import com.hbm.inventory.FluidContainerRegistry;
|
||||
import com.hbm.inventory.FluidStack;
|
||||
import com.hbm.inventory.OreDictManager.DictFrame;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.items.ItemEnums.EnumTarType;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemChemistryTemplate;
|
||||
import com.hbm.items.machine.ItemFluidIcon;
|
||||
import com.hbm.items.weapon.ItemGunBase;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.util.EnchantmentUtil;
|
||||
|
||||
@ -5,7 +5,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.RecipesCommon;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
|
||||
@ -12,7 +12,6 @@ import com.hbm.inventory.recipes.RefineryRecipes;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemFluidIcon;
|
||||
import com.hbm.util.Tuple.Pair;
|
||||
import com.hbm.util.Tuple.Quartet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ public class SILEXRecipes {
|
||||
|
||||
itemTranslation.put(new ComparableStack(ModItems.fluid_icon, 1, Fluids.UF6.getID()), new ComparableStack(ModItems.ingot_uranium));
|
||||
dictTranslation.put("dustUranium", "ingotUranium");
|
||||
recipes.put("ingotUranium", new SILEXRecipe(900, 100, 2)
|
||||
recipes.put("ingotUranium", new SILEXRecipe(900, 100, EnumWavelengths.UV)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_u235), 1))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_u238), 11))
|
||||
);
|
||||
@ -243,44 +243,44 @@ public class SILEXRecipes {
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_pb209), 2 + 4 * i)) );
|
||||
|
||||
// LES //
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_les, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.ULTRAVIOLET)
|
||||
.addOut(new WeigthedRandomObject(new ItemStack(ModItems.nugget_les), 90 - i * 20))
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_les, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.UV)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_les), 90 - i * 20))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_lead), 5 + 10 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nulear_waste_tiny), 5 + 10 * i));
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i)) );
|
||||
|
||||
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_les, 1, i+5), new SILEXRecipe(600, 100, EnumWavelengths.ULTRAVIOLET)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(Moditems.nugget_les), 89 - i * 20))
|
||||
.addOut(new WeigthedRandomObject(new ItemStack(Moditems.powder_xe135_tiny), 1))
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_les, 1, i+5), new SILEXRecipe(600, 100, EnumWavelengths.UV)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_les), 89 - i * 20))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.powder_xe135_tiny), 1))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_lead), 5 + 10 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nulear_waste_tiny), 5 + 10 * i));
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i)) );
|
||||
|
||||
// MES //
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_mes, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.ULTRAVIOLET)
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_mes, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.UV)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_schrabidium_fuel), 90 - i * 20))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_lead), 5 + 10 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i));
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i)) );
|
||||
|
||||
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_mes, 1, i+5), new SILEXRecipe(600, 100, EnumWaveLengths.ULTRAVIOLET)
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_mes, 1, i+5), new SILEXRecipe(600, 100, EnumWavelengths.UV)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_schrabidium_fuel), 89 - i * 20))
|
||||
.addOut(new WeightedRandomObject(new Itemstack(ModItems.powder_xe135_tiny), 1))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.powder_xe135_tiny), 1))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_lead), 5 + 10 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i));
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i)) );
|
||||
|
||||
// HES //
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_hes, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.ULTRAVIOLET)
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_hes, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.UV)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_hes), 90 - i * 20))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_lead), 3 + 6 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_euphemium), 2 + 4 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i));
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i)) );
|
||||
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_hes, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.ULTRAVIOLET)
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_hes, 1, i), new SILEXRecipe(600, 100, EnumWavelengths.UV)
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_hes), 89 - i * 20))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.powder_xe135_tiny), 1))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_lead), 3 + 6 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nugget_euphemium), 2 + 4 * i))
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i));
|
||||
.addOut(new WeightedRandomObject(new ItemStack(ModItems.nuclear_waste_tiny), 5 + 10 * i)) );
|
||||
|
||||
// BALEFIRE //
|
||||
recipes.put(new ComparableStack(ModItems.rbmk_pellet_balefire, 1, i), new SILEXRecipe(400, 100, 3)
|
||||
|
||||
@ -7,7 +7,6 @@ import java.util.Map;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.generic.BlockBobble.BobbleType;
|
||||
import com.hbm.interfaces.Untested;
|
||||
import com.hbm.inventory.RecipesCommon;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
package com.hbm.inventory.recipes.loader;
|
||||
|
||||
public class JSONLoader {
|
||||
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
package com.hbm.inventory.recipes.loader;
|
||||
|
||||
public class JSONLoaderAssembler {
|
||||
|
||||
}
|
||||
@ -17,6 +17,7 @@ import com.hbm.main.MainRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@Deprecated
|
||||
public abstract class JSONLoaderBase {
|
||||
|
||||
public File config;
|
||||
|
||||
@ -0,0 +1,197 @@
|
||||
package com.hbm.inventory.recipes.loader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class SerializableRecipe {
|
||||
|
||||
public static final Gson gson = new Gson();
|
||||
public static List<SerializableRecipe> recipeHandlers = new ArrayList();
|
||||
|
||||
/*
|
||||
* INIT
|
||||
*/
|
||||
|
||||
public static void registerAllHanlders() {
|
||||
//nyi
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
File recDir = new File(MainRegistry.configDir.getAbsolutePath() + File.separatorChar + "hbmRecipes");
|
||||
|
||||
if(!recDir.exists()) {
|
||||
if(!recDir.mkdir()) {
|
||||
throw new IllegalStateException("Unable to make recipe directory " + recDir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
MainRegistry.logger.info("Starting recipe init!");
|
||||
|
||||
for(SerializableRecipe recipe : recipeHandlers) {
|
||||
|
||||
File recFile = new File(MainRegistry.configDir.getAbsolutePath() + File.separatorChar + recipe.getFileName());
|
||||
if(recFile.exists() && recFile.isFile()) {
|
||||
MainRegistry.logger.info("Reading recipe file " + recFile.getName());
|
||||
recipe.readRecipeFile(recFile);
|
||||
} else {
|
||||
MainRegistry.logger.info("No recipe file found, registering defaults for " + recipe.getFileName());
|
||||
recipe.registerDefaults();
|
||||
|
||||
File recTemplate = new File(MainRegistry.configDir.getAbsolutePath() + File.separatorChar + "_" + recipe.getFileName());
|
||||
MainRegistry.logger.info("Writing template file " + recTemplate.getName());
|
||||
recipe.writeTemplateFile(recTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
MainRegistry.logger.info("Finished recipe init!");
|
||||
}
|
||||
|
||||
/*
|
||||
* ABSTRACT
|
||||
*/
|
||||
|
||||
/** The machine's (or process') name used for the recipe file */
|
||||
public abstract String getFileName();
|
||||
/** Return the list object holding all the recipes, usually an ArrayList or HashMap */
|
||||
public abstract Object getRecipeObject();
|
||||
/** Will use the supplied JsonElement (usually casts to JsonArray) from the over arching recipe array and adds the recipe to the recipe list object */
|
||||
public abstract void readRecipe(JsonElement recipe);
|
||||
/** Is given a single recipe from the recipe list object (a wrapper, Tuple, array, HashMap Entry, etc) and writes it to the current ongoing GSON stream */
|
||||
public abstract void writeRecipe(Object recipe, JsonWriter writer);
|
||||
/** Registers the default recipes */
|
||||
public abstract void registerDefaults();
|
||||
|
||||
/*
|
||||
* JSON R/W WRAPPERS
|
||||
*/
|
||||
|
||||
public void writeTemplateFile(File template) {
|
||||
|
||||
try {
|
||||
/* Get the recipe list object */
|
||||
Object recipeObject = this.getRecipeObject();
|
||||
List recipeList = new ArrayList();
|
||||
|
||||
/* Try to pry all recipes from our list */
|
||||
if(recipeObject instanceof Collection) {
|
||||
recipeList.addAll((Collection) recipeList);
|
||||
}
|
||||
|
||||
if(recipeObject instanceof HashMap) {
|
||||
recipeList.addAll(((HashMap) recipeObject).entrySet());
|
||||
}
|
||||
|
||||
if(recipeList.isEmpty())
|
||||
throw new IllegalStateException("Error while writing recipes for " + this.getClass().getSimpleName() + ": Recipe list is either empty or in an unsupported format!");
|
||||
|
||||
JsonWriter writer = new JsonWriter(new FileWriter(template));
|
||||
writer.setIndent(" "); //pretty formatting
|
||||
writer.beginObject(); //initial '{'
|
||||
writer.name("recipes").beginArray(); //all recipes are stored in an array called "recipes"
|
||||
|
||||
for(Object recipe : recipeList) {
|
||||
writer.beginObject(); //begin object for a single recipe
|
||||
this.writeRecipe(recipe, writer); //serialize here
|
||||
writer.endObject(); //end recipe object
|
||||
}
|
||||
|
||||
writer.endArray(); //end recipe array
|
||||
writer.endObject(); //final '}'
|
||||
writer.close();
|
||||
} catch(Exception ex) { }
|
||||
}
|
||||
|
||||
public void readRecipeFile(File file) {
|
||||
|
||||
try {
|
||||
JsonObject json = gson.fromJson(new FileReader(file), JsonObject.class);
|
||||
JsonArray recipes = json.get("recipes").getAsJsonArray();
|
||||
for(JsonElement recipe : recipes) {
|
||||
this.readRecipe(recipe);
|
||||
}
|
||||
} catch(Exception ex) { }
|
||||
}
|
||||
|
||||
/*
|
||||
* JSON IO UTIL
|
||||
*/
|
||||
|
||||
protected static AStack readAStack(JsonArray array) {
|
||||
try {
|
||||
String type = array.get(0).getAsString();
|
||||
int stacksize = array.size() > 2 ? array.get(2).getAsInt() : 1;
|
||||
if("item".equals(type)) {
|
||||
Item item = (Item) Item.itemRegistry.getObject(array.get(1).getAsString());
|
||||
int meta = array.size() > 3 ? array.get(3).getAsInt() : 2;
|
||||
return new ComparableStack(item, stacksize, meta);
|
||||
}
|
||||
if("dict".equals("type")) {
|
||||
String dict = array.get(1).getAsString();
|
||||
return new OreDictStack(dict, stacksize);
|
||||
}
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading recipe array " + array.toString());
|
||||
return new ComparableStack(ModItems.nothing);
|
||||
}
|
||||
|
||||
protected static void writeAStack(AStack astack, JsonWriter writer) throws IOException {
|
||||
writer.beginArray();
|
||||
writer.setIndent("");
|
||||
if(astack instanceof ComparableStack) {
|
||||
ComparableStack comp = (ComparableStack) astack;
|
||||
writer.value("item"); //ITEM identifier
|
||||
writer.value(Item.itemRegistry.getNameForObject(comp.toStack().getItem())); //item name
|
||||
if(comp.stacksize != 1) writer.value(comp.stacksize); //stack size
|
||||
if(comp.meta > 0) writer.value(comp.meta); //metadata
|
||||
}
|
||||
if(astack instanceof OreDictStack) {
|
||||
OreDictStack ore = (OreDictStack) astack;
|
||||
writer.value("dict"); //DICT identifier
|
||||
writer.value(ore.name); //dict name
|
||||
writer.value(ore.stacksize); //stacksize
|
||||
}
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
|
||||
protected static ItemStack readItemStack(JsonArray array) {
|
||||
try {
|
||||
Item item = (Item) Item.itemRegistry.getObject(array.get(0).getAsString());
|
||||
int stacksize = array.size() > 1 ? array.get(1).getAsInt() : 1;
|
||||
int meta = array.size() > 2 ? array.get(2).getAsInt() : 2;
|
||||
return new ItemStack(item, stacksize, meta);
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading recipe array " + array.toString());
|
||||
return new ItemStack(ModItems.nothing);
|
||||
}
|
||||
|
||||
protected static void writeItemStack(ItemStack stack, JsonWriter writer) throws IOException {
|
||||
writer.beginArray();
|
||||
writer.setIndent("");
|
||||
writer.value(Item.itemRegistry.getNameForObject(stack.getItem())); //item name
|
||||
if(stack.stackSize != 1) writer.value(stack.stackSize); //stack size
|
||||
if(stack.getItemDamage() != 0) writer.value(stack.getItemDamage()); //metadata
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
}
|
||||
@ -757,7 +757,7 @@ public class CraftingManager {
|
||||
addRecipeAuto(new ItemStack(ModItems.upgrade_centrifuge, 1), new Object[] { "PHP", "PUP", "DTD", 'P', ModItems.centrifuge_element, 'H', Blocks.hopper, 'U', ModItems.upgrade_shredder, 'D', ANY_PLASTIC.ingot(), 'T', ModBlocks.machine_transformer });
|
||||
addRecipeAuto(new ItemStack(ModItems.upgrade_crystallizer, 1), new Object[] { "PHP", "CUC", "DTD", 'P', new ItemStack(ModItems.fluid_barrel_full, 1, Fluids.ACID.getID()), 'H', ModItems.circuit_targeting_tier4, 'C', ModBlocks.barrel_steel, 'U', ModItems.upgrade_centrifuge, 'D', ModItems.motor, 'T', ModBlocks.machine_transformer });
|
||||
addRecipeAuto(new ItemStack(ModItems.upgrade_screm, 1), new Object[] { "SUS", "SCS", "SUS", 'S', STEEL.plate(), 'U', ModItems.upgrade_template, 'C', ModItems.crystal_xen });
|
||||
addRecipeAuto(new ItemStack(ModItems.upgrade_gc_speed, 1), new Object[] {"TCT", "HUH", "TCT", 'T', ModItems.nugget_bismuth, 'C', ModItems.coil_copper, 'H', ModItems.coil_tungsten, 'U', ModItems.upgrade_template});
|
||||
addRecipeAuto(new ItemStack(ModItems.upgrade_gc_speed, 1), new Object[] { "PTP", "CBC", "PTP", 'P', CU.plate(), 'T', ModItems.upgrade_template, 'C', ModItems.coil_gold, 'B', (GeneralConfig.enableLBSM && GeneralConfig.enableLBSMSimpleCrafting) ? NB.ingot() : ANY_BISMOID.nugget() });
|
||||
|
||||
addRecipeAuto(new ItemStack(ModItems.mech_key, 1), new Object[] { "MCM", "MKM", "MMM", 'M', ModItems.ingot_meteorite_forged, 'C', ModItems.coin_maskman, 'K', ModItems.key });
|
||||
addRecipeAuto(new ItemStack(ModItems.spawn_ufo, 1), new Object[] { "MMM", "DCD", "MMM", 'M', ModItems.ingot_meteorite, 'D', DNT.ingot(), 'C', ModItems.coin_worm });
|
||||
|
||||
@ -30,6 +30,7 @@ import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.Metadata;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
@ -226,13 +227,9 @@ public class MainRegistry {
|
||||
|
||||
public static int generalOverride = 0;
|
||||
public static int polaroidID = 1;
|
||||
|
||||
public static int x;
|
||||
public static int y;
|
||||
public static int z;
|
||||
public static long time;
|
||||
|
||||
public static long startupTime = 0;
|
||||
public static File configDir;
|
||||
|
||||
Random rand = new Random();
|
||||
|
||||
@ -240,6 +237,7 @@ public class MainRegistry {
|
||||
public void PreLoad(FMLPreInitializationEvent PreEvent) {
|
||||
|
||||
startupTime = System.currentTimeMillis();
|
||||
configDir = PreEvent.getModConfigurationDirectory();
|
||||
|
||||
logger.info("Let us celebrate the fact that the logger finally works again!");
|
||||
|
||||
|
||||
@ -363,13 +363,13 @@ public class ModelHunterChopper extends ModelBase {
|
||||
GunBarrel.setRotationPoint(-10.5F, 11.5F, 0F);
|
||||
GunBarrel.setTextureSize(256, 128);
|
||||
GunBarrel.mirror = true;
|
||||
setRotation(GunBarrel, 0F, MainRegistry.x, 0F);
|
||||
setRotation(GunBarrel, 0F, 0, 0F);
|
||||
GunBack = new ModelRenderer(this, 0, 112);
|
||||
GunBack.addBox(0F, -1F, -1F, 2, 2, 2);
|
||||
GunBack.setRotationPoint(-10.5F, 12F, 0F);
|
||||
GunBack.setTextureSize(256, 128);
|
||||
GunBack.mirror = true;
|
||||
setRotation(GunBack, 0F, MainRegistry.x, 0F);
|
||||
setRotation(GunBack, 0F, 0, 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user