use of micdoodle8.mods.galacticraft.api.recipe.IRecipeUpdatable in project Galacticraft by micdoodle8.
the class RecipeManagerGC method setConfigurableRecipes.
public static void setConfigurableRecipes() {
if (GCCoreUtil.getEffectiveSide() == Side.CLIENT && CompatibilityManager.modJEILoaded)
TickHandlerClient.updateJEIhiding = true;
// Update Aluminium Wire and Battery crafting recipes and GC Advanced Metals recipes
ItemStack aluWire = new ItemStack(GCBlocks.aluminumWire, ConfigManagerCore.quickMode ? 9 : 6, 0);
ItemStack battery = new ItemStack(GCItems.battery, ConfigManagerCore.quickMode ? 3 : 2, 100);
boolean doQuickMode = ConfigManagerCore.quickMode != configSaved_QuickMode;
configSaved_QuickMode = ConfigManagerCore.quickMode;
ItemStack meteoricIronIngot = new ItemStack(GCItems.itemBasicMoon, 1, 0);
ItemStack meteoricIronPlate = new ItemStack(GCItems.itemBasicMoon, 1, 1);
boolean doMetalsToOreDict = configSaved_RequireGCmetals && !ConfigManagerCore.recipesRequireGCAdvancedMetals;
boolean doMetalsToGC = !configSaved_RequireGCmetals && ConfigManagerCore.recipesRequireGCAdvancedMetals;
configSaved_RequireGCmetals = ConfigManagerCore.recipesRequireGCAdvancedMetals;
boolean doSilicon = !ConfigManagerCore.otherModsSilicon.equals(configSaved_Silicon);
configSaved_Silicon = ConfigManagerCore.otherModsSilicon;
if (doQuickMode || doMetalsToOreDict || doMetalsToGC) {
List<IRecipe> standardRecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe recipe : standardRecipes) {
if (recipe instanceof IRecipeUpdatable) {
if (doQuickMode) {
ItemStack test = recipe.getRecipeOutput();
if (ItemStack.areItemsEqual(test, aluWire)) {
test.stackSize = aluWire.stackSize;
} else if (ItemStack.areItemsEqual(test, battery)) {
test.stackSize = battery.stackSize;
}
}
if (doMetalsToOreDict) {
((IRecipeUpdatable) recipe).replaceInput(meteoricIronIngot, OreDictionary.getOres("ingotMeteoricIron"));
((IRecipeUpdatable) recipe).replaceInput(meteoricIronPlate, OreDictionary.getOres("compressedMeteoricIron"));
if (GalacticraftCore.isPlanetsLoaded) {
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(MarsItems.marsItemBasic, 1, 2), OreDictionary.getOres("ingotDesh"));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(MarsItems.marsItemBasic, 1, 5), OreDictionary.getOres("compressedDesh"));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(AsteroidsItems.basicItem, 1, 0), OreDictionary.getOres("ingotTitanium"));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(AsteroidsItems.basicItem, 1, 6), OreDictionary.getOres("compressedTitanium"));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(VenusItems.basicItem, 1, 1), OreDictionary.getOres("ingotLead"));
}
} else if (doMetalsToGC) {
((IRecipeUpdatable) recipe).replaceInput(meteoricIronIngot);
((IRecipeUpdatable) recipe).replaceInput(meteoricIronPlate);
if (GalacticraftCore.isPlanetsLoaded) {
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(MarsItems.marsItemBasic, 1, 2));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(MarsItems.marsItemBasic, 1, 5));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(AsteroidsItems.basicItem, 1, 0));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(AsteroidsItems.basicItem, 1, 6));
((IRecipeUpdatable) recipe).replaceInput(new ItemStack(VenusItems.basicItem, 1, 1));
}
}
}
}
}
if (doSilicon) {
ItemStack siliconGC = new ItemStack(GCItems.basicItem, 1, 2);
boolean needNewList = true;
List<ItemStack> silicons = OreDictionary.getOres(ConfigManagerCore.otherModsSilicon);
if (silicons.size() > 0) {
for (ItemStack s : silicons) {
if (ItemStack.areItemsEqual(s, siliconGC)) {
needNewList = false;
break;
}
}
}
if (needNewList) {
List<ItemStack> newList = new ArrayList<>(1 + silicons.size());
newList.add((ItemStack) siliconGC);
if (silicons.size() > 0)
newList.addAll(silicons);
silicons = newList;
}
CircuitFabricatorRecipes.replaceRecipeIngredient(siliconGC, silicons);
}
if (doMetalsToOreDict || doMetalsToGC) {
if (ConfigManagerCore.recipesRequireGCAdvancedMetals) {
CompressorRecipes.replaceRecipeIngredient(meteoricIronIngot);
} else {
CompressorRecipes.replaceRecipeIngredient(meteoricIronIngot, OreDictionary.getOres("ingotMeteoricIron"));
}
if (GalacticraftCore.isPlanetsLoaded) {
setConfigurableRecipesPlanets();
}
// Update Advanced Wafer in space station recipe
ItemStack sswafer = new ItemStack(GCItems.basicItem, 1, ItemBasic.WAFER_ADVANCED);
for (SpaceStationType station : GalacticraftRegistry.getSpaceStationData()) {
HashMap<Object, Integer> ssrecipe = station.getRecipeForSpaceStation().getInput();
if (doMetalsToOreDict) {
ItemStack found = null;
for (Object test : ssrecipe.keySet()) {
if (test instanceof ItemStack && ItemStack.areItemsEqual((ItemStack) test, sswafer)) {
found = (ItemStack) test;
break;
}
}
if (found != null) {
ssrecipe.remove(found);
ssrecipe.put(OreDictionary.getOres("waferAdvanced"), 1);
}
} else if (doMetalsToGC) {
Object found = null;
for (Object test : ssrecipe.keySet()) {
if (test instanceof List<?> && OreRecipeUpdatable.itemListContains((List<?>) test, sswafer)) {
found = test;
break;
}
}
if (found != null) {
ssrecipe.remove(found);
ssrecipe.put(sswafer, 1);
}
}
}
}
}
Aggregations