diff --git a/src/main/java/nc/ncpf/NCPFBuilder.java b/src/main/java/nc/ncpf/NCPFBuilder.java index 027729ada..0b6a82073 100644 --- a/src/main/java/nc/ncpf/NCPFBuilder.java +++ b/src/main/java/nc/ncpf/NCPFBuilder.java @@ -37,6 +37,28 @@ public static void translate(List list, Block... blocks) { public static void translate(List list, Block block) { translate(list, block, true); } + + private static List casingBlocks = new ArrayList<>(); + static{ + casingBlocks.add(NCBlocks.fission_casing); + casingBlocks.add(NCBlocks.fission_glass); + casingBlocks.add(NCBlocks.fission_monitor); + casingBlocks.add(NCBlocks.fission_source_manager); + casingBlocks.add(NCBlocks.fission_shield_manager); + casingBlocks.add(NCBlocks.fission_power_port); + casingBlocks.add(NCBlocks.fission_computer_port); + casingBlocks.add(NCBlocks.turbine_casing); + casingBlocks.add(NCBlocks.turbine_glass); + casingBlocks.add(NCBlocks.turbine_computer_port); + casingBlocks.add(NCBlocks.turbine_redstone_port); + casingBlocks.add(NCBlocks.machine_frame); + casingBlocks.add(NCBlocks.machine_glass); + casingBlocks.add(NCBlocks.machine_power_port); + casingBlocks.add(NCBlocks.machine_process_port); + casingBlocks.add(NCBlocks.machine_reservoir_port); + casingBlocks.add(NCBlocks.machine_redstone_port); + casingBlocks.add(NCBlocks.machine_computer_port); + } public static void translate(List list, Block block, boolean includeModules) { List newElements = new ArrayList<>(); @@ -47,7 +69,7 @@ public static void translate(List list, Block block, boolean includ for (Enum variant : blockMeta.getValues()) { NCPFLegacyBlock legacyBlock = new NCPFLegacyBlock(); legacyBlock.name = block.getRegistryName().toString(); - legacyBlock.metadata = metadata++; + legacyBlock.metadata = metadata; legacyBlock.blockstate.put("type", variant.toString()); newElements.add(legacyBlock); @@ -72,6 +94,7 @@ public static void translate(List list, Block block, boolean includ outputPort.blockstate.put("active", true); newElements.add(outputPort); } + metadata++; } } else { @@ -112,14 +135,19 @@ public static void translate(List list, Block block, boolean includ meta = legacyBlock.metadata; blockstate = legacyBlock.blockstate; } + + // Controllers - // Fission - - if (block == NCBlocks.solid_fission_controller || block == NCBlocks.salt_fission_controller || block == NCBlocks.turbine_controller) { + if (block == NCBlocks.solid_fission_controller + || block == NCBlocks.salt_fission_controller + || block == NCBlocks.turbine_controller + || block == NCBlocks.distiller_controller) { elem.modules.put("nuclearcraft:" + configContext + ":controller", new NCPFEmptyModule()); wall = true; } + // Fission + if (block == NCBlocks.fission_vent) { Map vent = new HashMap<>(); vent.put("output", blockstate.get("active")); @@ -242,7 +270,7 @@ public static void translate(List list, Block block, boolean includ translate(portElements, NCBlocks.fission_irradiator_port); ports.put("input", portElements.get(0)); ports.put("output", portElements.get(1)); - elem.modules.put("nuclearcraft:overhaul_sfr:recipe_ports", ports); + elem.modules.put("nuclearcraft:"+configContext+":recipe_ports", ports); Map recipesModule = new HashMap<>(); List recipes = new ArrayList<>(); @@ -328,7 +356,25 @@ public static void translate(List list, Block block, boolean includ if (block == NCBlocks.turbine_rotor_shaft) { elem.modules.put("nuclearcraft:" + configContext + ":shaft", new NCPFEmptyModule()); } - + + // Distiller + + if (block == NCBlocks.distiller_sieve_tray) { + elem.modules.put("nuclearcraft:" + configContext + ":sieve_tray", new NCPFEmptyModule()); + } + + if (block == NCBlocks.distiller_reflux_unit) { + elem.modules.put("nuclearcraft:" + configContext + ":reflux_unit", new NCPFEmptyModule()); + } + + if (block == NCBlocks.distiller_reboiling_unit) { + elem.modules.put("nuclearcraft:" + configContext + ":reboiling_unit", new NCPFEmptyModule()); + } + + if (block == NCBlocks.distiller_liquid_distributor) { + elem.modules.put("nuclearcraft:" + configContext + ":liquid_distributor", new NCPFEmptyModule()); + } + // CT Blocks for (CTRegistration.RegistrationInfo info : CTRegistration.INFO_LIST) { @@ -429,9 +475,9 @@ public static void translate(List list, Block block, boolean includ } } - if (wall || block == NCBlocks.fission_casing || block == NCBlocks.fission_glass || block == NCBlocks.fission_monitor || block == NCBlocks.fission_source_manager || block == NCBlocks.fission_shield_manager || block == NCBlocks.fission_power_port || block == NCBlocks.fission_computer_port || block == NCBlocks.turbine_casing || block == NCBlocks.turbine_glass || block == NCBlocks.turbine_computer_port || block == NCBlocks.turbine_redstone_port) { + if (wall || casingBlocks.contains(block)) { Map casing = new HashMap<>(); - casing.put("edge", block == NCBlocks.fission_casing || block == NCBlocks.turbine_casing); + casing.put("edge", block == NCBlocks.fission_casing || block == NCBlocks.turbine_casing || block == NCBlocks.machine_frame); elem.modules.put("nuclearcraft:" + configContext + ":casing", casing); } @@ -446,131 +492,178 @@ public static void translate(List list, BasicRecipeHandler recipes) } public static void translate(List list, BasicRecipeHandler recipes, Predicate filter) { - if (!(recipes instanceof CoolantHeaterRecipes)) { - if (recipes.getItemInputSize() + recipes.getFluidInputSize() != 1) { - throw new IllegalArgumentException("Cannot convert recipes to NCPF element unless they have exactly one input!"); - } - } - for (BasicRecipe recipe : recipes.getRecipeList()) { if (!filter.test(recipe)) { continue; } - - IIngredient ingredient = recipes.getFluidInputSize() > 0 ? recipe.getFluidIngredients().get(0) : recipe.getItemIngredients().get(0); - NCPFElement element = translateIngredient(ingredient); - if (recipes instanceof FissionHeatingRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map stats = new HashMap<>(); - stats.put("heat", recipe.getFissionHeatingHeatPerInputMB()); - stats.put("output_ratio", recipe.getFluidProducts().get(0).getStack().amount / (float) recipe.getFluidIngredients().get(0).getStack().amount); - stats.put("output", translateIngredient(recipe.getFluidProducts().get(0))); - element.modules.put("nuclearcraft:overhaul_sfr:coolant_recipe_stats", stats); - } - - if (recipes instanceof FissionModeratorRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map moderator = new HashMap<>(); - moderator.put("flux", recipe.getFissionModeratorFluxFactor()); - moderator.put("efficiency", recipe.getFissionModeratorEfficiency()); - element.modules.put("nuclearcraft:" + configContext + ":moderator", moderator); - } - - if (recipes instanceof FissionReflectorRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map reflector = new HashMap<>(); - reflector.put("efficiency", recipe.getFissionReflectorEfficiency()); - reflector.put("reflectivity", recipe.getFissionReflectorReflectivity()); - element.modules.put("nuclearcraft:" + configContext + ":reflector", reflector); - } - - if (recipes instanceof FissionIrradiatorRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map irradiator = new HashMap<>(); - irradiator.put("heat", recipe.getIrradiatorHeatPerFlux()); - irradiator.put("efficiency", recipe.getIrradiatorProcessEfficiency()); - irradiator.put("output", translateIngredient(recipe.getItemProducts().get(0))); - element.modules.put("nuclearcraft:" + configContext + ":irradiator_stats", irradiator); - } - - if (recipes instanceof SolidFissionRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map fuel = new HashMap<>(); - fuel.put("efficiency", recipe.getFissionFuelEfficiency()); - fuel.put("heat", recipe.getFissionFuelHeat()); - fuel.put("time", recipe.getFissionFuelTime()); - fuel.put("criticality", recipe.getFissionFuelCriticality()); - fuel.put("self_priming", recipe.getFissionFuelSelfPriming()); - fuel.put("output", translateIngredient(recipe.getItemProducts().get(0))); - element.modules.put("nuclearcraft:overhaul_sfr:fuel_stats", fuel); - } - - if (recipes instanceof SaltFissionRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map fuel = new HashMap<>(); - fuel.put("efficiency", recipe.getFissionFuelEfficiency()); - fuel.put("heat", recipe.getFissionFuelHeat()); - fuel.put("time", recipe.getSaltFissionFuelTime()); - fuel.put("criticality", recipe.getFissionFuelCriticality()); - fuel.put("self_priming", recipe.getFissionFuelSelfPriming()); - fuel.put("output", translateIngredient(recipe.getFluidProducts().get(0))); - element.modules.put("nuclearcraft:overhaul_msr:fuel_stats", fuel); - } - - if (recipes instanceof CoolantHeaterRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map heater = new HashMap<>(); - heater.put("cooling", recipe.getCoolantHeaterCoolingRate()); - heater.put("output", translateIngredient(recipe.getFluidProducts().get(0))); - element.modules.put("nuclearcraft:overhaul_msr:heater_stats", heater); - } - - if (recipes instanceof TurbineRecipes) { - if (element.modules == null) { - element.modules = new HashMap<>(); - } - - Map stats = new HashMap<>(); - stats.put("power", recipe.getTurbinePowerPerMB()); - stats.put("coefficient", recipe.getTurbineExpansionLevel()); - stats.put("output", translateIngredient(recipe.getFluidProducts().get(0))); - element.modules.put("nuclearcraft:overhaul_turbine:recipe_stats", stats); - } - - list.add(element); + + list.add(translate(recipes, recipe)); } } + + public static NCPFElement translate(BasicRecipeHandler recipes, BasicRecipe recipe){ + NCPFRecipe recipeElement = new NCPFRecipe(); + + boolean hasSkippedTheCoolantHeaterBlockThatThisRecipeBelongsToButThatIsNotActuallyPartOfThisRecipe = false; + + for(IItemIngredient ingredient : recipe.getItemIngredients()){ + if(recipes instanceof CoolantHeaterRecipes && !hasSkippedTheCoolantHeaterBlockThatThisRecipeBelongsToButThatIsNotActuallyPartOfThisRecipe){ + hasSkippedTheCoolantHeaterBlockThatThisRecipeBelongsToButThatIsNotActuallyPartOfThisRecipe = true; + continue; + } + if(ingredient instanceof EmptyItemIngredient)continue; + recipeElement.inputs.add(translateIngredient(ingredient)); + } + for(IFluidIngredient ingredient : recipe.getFluidIngredients()){ + if(ingredient instanceof EmptyFluidIngredient)continue; + recipeElement.inputs.add(translateIngredient(ingredient)); + } + + for(IItemIngredient ingredient : recipe.getItemProducts()){ + if(ingredient instanceof EmptyItemIngredient)continue; + recipeElement.outputs.add(translateIngredient(ingredient)); + } + for(IFluidIngredient ingredient : recipe.getFluidProducts()){ + if(ingredient instanceof EmptyFluidIngredient)continue; + recipeElement.outputs.add(translateIngredient(ingredient)); + } + + for(NCPFElement input : recipeElement.inputs)input.modules = null; + for(NCPFElement output : recipeElement.outputs)output.modules = null; + + NCPFElement element = recipeElement; + + if(recipeElement.inputs.size()==1&&recipeElement.outputs.isEmpty()){ + element = recipeElement.inputs.get(0); + element.amount = null; + } + + if (recipes instanceof FissionHeatingRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map stats = new HashMap<>(); + stats.put("heat", recipe.getFissionHeatingHeatPerInputMB()); + stats.put("output_ratio", recipe.getFluidProducts().get(0).getStack().amount / (float) recipe.getFluidIngredients().get(0).getStack().amount); + element.modules.put("nuclearcraft:overhaul_sfr:coolant_recipe_stats", stats); + } + + if (recipes instanceof FissionModeratorRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map moderator = new HashMap<>(); + moderator.put("flux", recipe.getFissionModeratorFluxFactor()); + moderator.put("efficiency", recipe.getFissionModeratorEfficiency()); + element.modules.put("nuclearcraft:" + configContext + ":moderator", moderator); + } + + if (recipes instanceof FissionReflectorRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map reflector = new HashMap<>(); + reflector.put("efficiency", recipe.getFissionReflectorEfficiency()); + reflector.put("reflectivity", recipe.getFissionReflectorReflectivity()); + element.modules.put("nuclearcraft:" + configContext + ":reflector", reflector); + } + + if (recipes instanceof FissionIrradiatorRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map irradiator = new HashMap<>(); + irradiator.put("heat", recipe.getIrradiatorHeatPerFlux()); + irradiator.put("efficiency", recipe.getIrradiatorProcessEfficiency()); + element.modules.put("nuclearcraft:" + configContext + ":irradiator_stats", irradiator); + } + + if (recipes instanceof SolidFissionRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map fuel = new HashMap<>(); + fuel.put("efficiency", recipe.getFissionFuelEfficiency()); + fuel.put("heat", recipe.getFissionFuelHeat()); + fuel.put("time", recipe.getFissionFuelTime()); + fuel.put("criticality", recipe.getFissionFuelCriticality()); + fuel.put("self_priming", recipe.getFissionFuelSelfPriming()); + element.modules.put("nuclearcraft:overhaul_sfr:fuel_stats", fuel); + } + + if (recipes instanceof SaltFissionRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map fuel = new HashMap<>(); + fuel.put("efficiency", recipe.getFissionFuelEfficiency()); + fuel.put("heat", recipe.getFissionFuelHeat()); + fuel.put("time", recipe.getSaltFissionFuelTime()); + fuel.put("criticality", recipe.getFissionFuelCriticality()); + fuel.put("self_priming", recipe.getFissionFuelSelfPriming()); + element.modules.put("nuclearcraft:overhaul_msr:fuel_stats", fuel); + } + + if (recipes instanceof CoolantHeaterRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map heater = new HashMap<>(); + heater.put("cooling", recipe.getCoolantHeaterCoolingRate()); + element.modules.put("nuclearcraft:overhaul_msr:heater_stats", heater); + } + + if (recipes instanceof TurbineRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map stats = new HashMap<>(); + stats.put("power", recipe.getTurbinePowerPerMB()); + stats.put("coefficient", recipe.getTurbineExpansionLevel()); + element.modules.put("nuclearcraft:overhaul_turbine:recipe_stats", stats); + } + + if (recipes instanceof MultiblockDistillerRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map stats = new HashMap<>(); + stats.put("time", recipe.getProcessTimeMultiplier()); + stats.put("power", recipe.getProcessPowerMultiplier()); + element.modules.put("nuclearcraft:overhaul_distiller:recipe_stats", stats); + } + + if (recipes instanceof MachineSieveAssemblyRecipes) { + if (element.modules == null) { + element.modules = new HashMap<>(); + } + + Map assembly = new HashMap<>(); + assembly.put("efficiency", recipe.getMachineSieveAssemblyEfficiency()); + element.modules.put("nuclearcraft:"+configContext+":sieve_assembly", assembly); + } + + return element; + } - public static void translateOutputs(List list, BasicRecipeHandler recipes) { + public static void translateIngredients(List list, BasicRecipeHandler recipes) { for (BasicRecipe recipe : recipes.getRecipeList()) { - for (IItemIngredient item : recipe.getItemProducts()) { - list.add(translateIngredient(item)); - } - - for (IFluidIngredient fluid : recipe.getFluidProducts()) { - list.add(translateIngredient(fluid)); - } + NCPFElement element = translate(recipes, recipe); + + if(element instanceof NCPFRecipe){ + NCPFRecipe recip = (NCPFRecipe)element; + list.addAll(recip.inputs); + list.addAll(recip.outputs); + } } } @@ -596,6 +689,7 @@ private static NCPFElement translateIngredient(IIngredient ingredient) { ItemStack stack = item.stack; NCPFLegacyFluid legacyFluid = new NCPFLegacyFluid(); legacyFluid.name = stack.getTagCompound().getString("FluidName"); + legacyFluid.amount = 1000; return legacyFluid; } return translate(item.stack); @@ -604,12 +698,14 @@ private static NCPFElement translateIngredient(IIngredient ingredient) { if (ingredient instanceof FluidIngredient fluid) { NCPFLegacyFluid legacyFluid = new NCPFLegacyFluid(); legacyFluid.name = fluid.fluidName; + legacyFluid.amount = fluid.stack.amount; return legacyFluid; } if (ingredient instanceof OreIngredient ore) { NCPFOredict oredict = new NCPFOredict(); oredict.oredict = ore.oreName; + oredict.amount = ore.stackSize; return oredict; } @@ -627,6 +723,7 @@ public static NCPFElement translate(ItemStack stack, boolean includeModules) { List list = new ArrayList<>(); translate(list, block, includeModules); for (NCPFElement elem : list) { + elem.amount = stack.getCount(); if (elem instanceof NCPFLegacyBlock ncpf && ncpf.metadata != null && ncpf.metadata == stack.getMetadata()) { return elem; } @@ -639,6 +736,7 @@ public static NCPFElement translate(ItemStack stack, boolean includeModules) { if (stack.getItem().getHasSubtypes()) { legacyItem.metadata = stack.getMetadata(); } + legacyItem.amount = stack.getCount(); return legacyItem; } diff --git a/src/main/java/nc/ncpf/NCPFWriter.java b/src/main/java/nc/ncpf/NCPFWriter.java index 03935a7a1..abe9a63aa 100644 --- a/src/main/java/nc/ncpf/NCPFWriter.java +++ b/src/main/java/nc/ncpf/NCPFWriter.java @@ -6,6 +6,7 @@ import nc.init.NCBlocks; import nc.integration.crafttweaker.CTRegistration; import nc.ncpf.element.*; +import nc.ncpf.module.*; import nc.ncpf.nuclearcraft.*; import nc.recipe.NCRecipes; import nc.util.NCUtil; @@ -24,9 +25,7 @@ public static void exportNCPF() { NCPFRoot ncpf = new NCPFRoot(); - ncpf.modules.put("nuclearcraft:generated", new Object() { - final String nuclearcraft_version = Global.VERSION; - }); + ncpf.modules.put("nuclearcraft:generated", new NCPFGeneratedModule()); // Fission SFR { @@ -84,9 +83,9 @@ public static void exportNCPF() { Map globalElementsModule = new HashMap<>(); List globalElements = new ArrayList<>(); - NCPFBuilder.translateOutputs(globalElements, NCRecipes.fission_heating); - NCPFBuilder.translateOutputs(globalElements, NCRecipes.solid_fission); - NCPFBuilder.translateOutputs(globalElements, NCRecipes.fission_irradiator); + NCPFBuilder.translateIngredients(globalElements, NCRecipes.fission_heating); + NCPFBuilder.translateIngredients(globalElements, NCRecipes.solid_fission); + NCPFBuilder.translateIngredients(globalElements, NCRecipes.fission_irradiator); List> lists = new ArrayList<>(); lists.add(cfg.blocks); @@ -216,9 +215,9 @@ public static void exportNCPF() { Map globalElementsModule = new HashMap<>(); List globalElements = new ArrayList<>(); - NCPFBuilder.translateOutputs(globalElements, NCRecipes.salt_fission); - NCPFBuilder.translateOutputs(globalElements, NCRecipes.coolant_heater); - NCPFBuilder.translateOutputs(globalElements, NCRecipes.fission_irradiator); + NCPFBuilder.translateIngredients(globalElements, NCRecipes.salt_fission); + NCPFBuilder.translateIngredients(globalElements, NCRecipes.coolant_heater); + NCPFBuilder.translateIngredients(globalElements, NCRecipes.fission_irradiator); List> lists = new ArrayList<>(); lists.add(cfg.blocks); @@ -365,7 +364,7 @@ public static void exportNCPF() { Map globalElementsModule = new HashMap<>(); List globalElements = new ArrayList<>(); - NCPFBuilder.translateOutputs(globalElements, NCRecipes.turbine); + NCPFBuilder.translateIngredients(globalElements, NCRecipes.turbine); List> lists = new ArrayList<>(); lists.add(cfg.blocks); @@ -459,6 +458,132 @@ public static void exportNCPF() { ncpf.configuration.put("nuclearcraft:overhaul_turbine", cfg); } + + // Distiller + { + NCPFBuilder.configContext = "overhaul_distiller"; + NCPFOverhaulDistillerConfiguration cfg = new NCPFOverhaulDistillerConfiguration(); + + Map settings = new HashMap<>(); + settings.put("min_size", NCConfig.machine_min_size); + settings.put("max_size", NCConfig.machine_max_size); + settings.put("base_time", NCConfig.machine_distiller_time); + settings.put("base_power", NCConfig.machine_distiller_power); + + // Blocks + NCPFBuilder.translate(cfg.blocks, NCBlocks.distiller_controller); + NCPFBuilder.translate(cfg.blocks, NCBlocks.machine_redstone_port); + NCPFBuilder.translate(cfg.blocks, NCBlocks.machine_computer_port); + NCPFBuilder.translate(cfg.blocks, NCBlocks.machine_frame); + NCPFBuilder.translate(cfg.blocks, NCBlocks.machine_glass); + NCPFBuilder.translate(cfg.blocks, NCBlocks.machine_power_port); + NCPFBuilder.translate(cfg.blocks, NCBlocks.machine_process_port); //TODO 10 times- 2 inputs, 8 outputs + NCPFBuilder.translate(cfg.blocks, NCBlocks.distiller_sieve_tray); + NCPFBuilder.translate(cfg.blocks, NCBlocks.distiller_reflux_unit); + NCPFBuilder.translate(cfg.blocks, NCBlocks.distiller_reboiling_unit); + NCPFBuilder.translate(cfg.blocks, NCBlocks.distiller_liquid_distributor); + NCPFBuilder.translate(cfg.blocks, NCRecipes.machine_sieve_assembly); + + // Recipes + NCPFBuilder.translate(cfg.recipes, NCRecipes.multiblock_distiller); + + Map globalElementsModule = new HashMap<>(); + List globalElements = new ArrayList<>(); + + NCPFBuilder.translateIngredients(globalElements, NCRecipes.multiblock_distiller); + + List> lists = new ArrayList<>(); + lists.add(cfg.blocks); + lists.add(cfg.recipes); + + globalLoop: + for (int i = 0; i < globalElements.size(); ++i) { + NCPFElement globalElem = globalElements.get(i); + for (int j = 0; j < globalElements.size(); ++j) { + if (i == j) { + continue; + } + + NCPFElement elem = globalElements.get(j); + if (gson.toJson(elem).equals(gson.toJson(globalElem))) { + globalElements.remove(j--); + } + } + + for (List list : lists) { + for (NCPFElement elem : list) { + if (gson.toJson(elem).equals(gson.toJson(globalElem))) { + globalElements.remove(i--); + continue globalLoop; + } + } + } + } + + lists.add(globalElements); + + for (NCPFElement block : cfg.blocks) { + if (block.modules == null) { + continue; + } + + Map blockRecipes = NCPFHelper.get(block.modules, "ncpf:block_recipes"); + if (blockRecipes == null) { + continue; + } + + List recipes = NCPFHelper.get(blockRecipes, "recipes"); + lists.add(recipes); + } + + List elementsToHaveOredictTagsAdded = new ArrayList<>(); + List oredictTagsToAddToThoseAforementionedElements = new ArrayList<>(); + + // Ore Dictionary + for (List elements : lists) { + //noinspection ForLoopReplaceableByForEach + for (int i = 0; i < elements.size(); ++i) { + NCPFElement elem = elements.get(i); + if (elem instanceof NCPFOredict oredict) { + oreLoop: + for (ItemStack stack : OreDictionary.getOres(oredict.oredict, false)) { + NCPFElement stackElem = NCPFBuilder.translate(stack); + for (NCPFElement globalElem : globalElements) { + if (gson.toJson(stackElem).equals(gson.toJson(globalElem))) { + elementsToHaveOredictTagsAdded.add(globalElem); + oredictTagsToAddToThoseAforementionedElements.add(oredict.oredict); + continue oreLoop; + } + } + + elementsToHaveOredictTagsAdded.add(stackElem); + oredictTagsToAddToThoseAforementionedElements.add(oredict.oredict); + globalElements.add(stackElem); + } + } + } + } + + for (int i = 0; i < elementsToHaveOredictTagsAdded.size(); ++i) { + NCPFElement elem = elementsToHaveOredictTagsAdded.get(i); + if (elem.modules == null) { + elem.modules = new HashMap<>(); + } + + if (!elem.modules.containsKey("plannerator:tags")) { + Map tags = new HashMap<>(); + tags.put("tags", new ArrayList()); + elem.modules.put("plannerator:tags", tags); + } + + NCPFHelper.>get(NCPFHelper.get(elem.modules, "plannerator:tags"), "tags").add(oredictTagsToAddToThoseAforementionedElements.get(i)); + } + + globalElementsModule.put("elements", globalElements); + cfg.modules.put("plannerator:global_elements", globalElementsModule); + + ncpf.configuration.put("nuclearcraft:overhaul_distiller", cfg); + } try (FileWriter writer = new FileWriter(new File(Loader.instance().getConfigDir(), "nuclearcraft.ncpf.json"))) { gson.toJson(ncpf, writer); diff --git a/src/main/java/nc/ncpf/element/NCPFElement.java b/src/main/java/nc/ncpf/element/NCPFElement.java index 148dc7e0f..32376704e 100644 --- a/src/main/java/nc/ncpf/element/NCPFElement.java +++ b/src/main/java/nc/ncpf/element/NCPFElement.java @@ -5,6 +5,7 @@ public class NCPFElement extends NCPFObject { public final String type; + public Integer amount; public NCPFElement(String type) { this.type = type; diff --git a/src/main/java/nc/ncpf/element/NCPFRecipe.java b/src/main/java/nc/ncpf/element/NCPFRecipe.java new file mode 100644 index 000000000..eda923674 --- /dev/null +++ b/src/main/java/nc/ncpf/element/NCPFRecipe.java @@ -0,0 +1,13 @@ +package nc.ncpf.element; +import java.util.ArrayList; +public class NCPFRecipe extends NCPFElement{ + + public String name; + + public ArrayList inputs = new ArrayList<>(); + public ArrayList outputs = new ArrayList<>(); + + public NCPFRecipe() { + super("legacy_recipe"); + } +} diff --git a/src/main/java/nc/ncpf/module/NCPFGeneratedModule.java b/src/main/java/nc/ncpf/module/NCPFGeneratedModule.java new file mode 100644 index 000000000..fcfe28aa8 --- /dev/null +++ b/src/main/java/nc/ncpf/module/NCPFGeneratedModule.java @@ -0,0 +1,6 @@ +package nc.ncpf.module; +import nc.Global; +public class NCPFGeneratedModule{ + + final String nuclearcraft_version = Global.VERSION; +} diff --git a/src/main/java/nc/ncpf/nuclearcraft/NCPFOverhaulDistillerConfiguration.java b/src/main/java/nc/ncpf/nuclearcraft/NCPFOverhaulDistillerConfiguration.java new file mode 100644 index 000000000..aa5ecd8a3 --- /dev/null +++ b/src/main/java/nc/ncpf/nuclearcraft/NCPFOverhaulDistillerConfiguration.java @@ -0,0 +1,12 @@ +package nc.ncpf.nuclearcraft; + +import nc.ncpf.NCPFConfiguration; +import nc.ncpf.element.NCPFElement; + +import java.util.*; + +public class NCPFOverhaulDistillerConfiguration extends NCPFConfiguration { + + public final List blocks = new ArrayList<>(); + public final List recipes = new ArrayList<>(); +}