diff --git a/src/main/java/com/hbm/inventory/recipes/ElectrolyserMetalRecipes.java b/src/main/java/com/hbm/inventory/recipes/ElectrolyserMetalRecipes.java index 33e417c15..5e7318b92 100644 --- a/src/main/java/com/hbm/inventory/recipes/ElectrolyserMetalRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/ElectrolyserMetalRecipes.java @@ -1,9 +1,7 @@ package com.hbm.inventory.recipes; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.*; import java.util.Map.Entry; import com.google.gson.JsonArray; @@ -26,6 +24,7 @@ import com.hbm.items.special.ItemBedrockOreNew.BedrockOreGrade; import com.hbm.items.special.ItemBedrockOreNew.BedrockOreType; import com.hbm.util.ItemStackUtil; +import com.hbm.util.Tuple.*; import net.minecraft.item.ItemStack; public class ElectrolyserMetalRecipes extends SerializableRecipe { @@ -133,36 +132,52 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe { new ItemStack(ModItems.powder_lithium_tiny, 3))); for(BedrockOreType type : BedrockOreType.values()) { + ArrayList> productsF = new ArrayList<>(); + productsF.add(new Pair<>(type.primary1,12)); + productsF.add(new Pair<>(type.primary2,6)); + productsF.add(new Pair<>(type.byproductAcid1,3)); + productsF.add(new Pair<>(type.byproductAcid2,3)); + recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_FIRST, type)), makeBedrockOreProduct(productsF)); - MaterialStack f0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(12)); - MaterialStack f1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(6)); - recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_FIRST, type)), new ElectrolysisMetalRecipe( - f0 != null ? f0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), - f1 != null ? f1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), - 60, - f0 == null ? ItemBedrockOreNew.extract(type.primary1, 12) : new ItemStack(ModItems.dust), - f1 == null ? ItemBedrockOreNew.extract(type.primary2, 6) : new ItemStack(ModItems.dust), - ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type))); - MaterialStack s0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(6)); - MaterialStack s1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(12)); - recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_SECOND, type)), new ElectrolysisMetalRecipe( - s0 != null ? s0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), - s1 != null ? s1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), - 60, - s0 == null ? ItemBedrockOreNew.extract(type.primary1, 6) : new ItemStack(ModItems.dust), - s1 == null ? ItemBedrockOreNew.extract(type.primary2, 12) : new ItemStack(ModItems.dust), - ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type))); + ArrayList> productsS = new ArrayList<>(); + productsS.add(new Pair<>(type.primary1,6)); + productsS.add(new Pair<>(type.primary2,12)); + productsS.add(new Pair<>(type.byproductAcid2,3)); + productsS.add(new Pair<>(type.byproductAcid3,3)); - MaterialStack c0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(2)); - MaterialStack c1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(2)); - recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)), new ElectrolysisMetalRecipe( - c0 != null ? c0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1, 2)), - c1 != null ? c1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1, 2)), - 60, - c0 == null ? ItemBedrockOreNew.extract(type.primary1, 2) : new ItemStack(ModItems.dust), - c1 == null ? ItemBedrockOreNew.extract(type.primary2, 2) : new ItemStack(ModItems.dust))); + recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_SECOND, type)), makeBedrockOreProduct(productsS)); + + ArrayList> productsC = new ArrayList<>(); + productsC.add(new Pair<>(type.primary1,2)); + productsC.add(new Pair<>(type.primary2,2)); + + recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)), makeBedrockOreProduct(productsC)); } } + + public static ElectrolysisMetalRecipe makeBedrockOreProduct(ArrayList> products){ + ArrayList moltenProducts = new ArrayList<>(); + ArrayList solidProducts = new ArrayList<>(); + + for(Pair product : products){ + if(moltenProducts.size() < 2) { + MaterialStack melt = ItemBedrockOreNew.toFluid(product.getKey(), MaterialShapes.INGOT.q(product.getValue())); + if (melt != null) { + moltenProducts.add(melt); + continue; + } + } + solidProducts.add(ItemBedrockOreNew.extract(product.getKey(), product.getValue())); + } + if(moltenProducts.size() == 0) + moltenProducts.add(new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(2))); + + return new ElectrolysisMetalRecipe( + moltenProducts.get(0), + moltenProducts.size() > 1 ? moltenProducts.get(1) : null, + 20, + solidProducts.toArray(new ItemStack[0])); + } public static ElectrolysisMetalRecipe getRecipe(ItemStack stack) { if(stack == null || stack.getItem() == null) diff --git a/src/main/java/com/hbm/items/special/ItemBedrockOreNew.java b/src/main/java/com/hbm/items/special/ItemBedrockOreNew.java index 2739546f0..3e1d949de 100644 --- a/src/main/java/com/hbm/items/special/ItemBedrockOreNew.java +++ b/src/main/java/com/hbm/items/special/ItemBedrockOreNew.java @@ -169,6 +169,9 @@ public class ItemBedrockOreNew extends Item { List billets = OreDictionary.getOres(frame.billet(), false); if(!billets.isEmpty()) return fromList(billets, amount); List ingots = OreDictionary.getOres(frame.ingot(), false); if(!ingots.isEmpty()) return fromList(ingots, amount); } + if(o instanceof ItemStack){ + return (ItemStack) o; + } return new ItemStack(ModItems.nothing); } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java b/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java index fa9619d70..8b391a52c 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java @@ -349,18 +349,19 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn public void processMetal() { ElectrolysisMetalRecipe recipe = ElectrolyserMetalRecipes.getRecipe(slots[14]); + if(recipe.output1 != null) + if(leftStack == null) { + leftStack = new MaterialStack(recipe.output1.material, recipe.output1.amount); + } else { + leftStack.amount += recipe.output1.amount; + } - if(leftStack == null) { - leftStack = new MaterialStack(recipe.output1.material, recipe.output1.amount); - } else { - leftStack.amount += recipe.output1.amount; - } - - if(rightStack == null) { - rightStack = new MaterialStack(recipe.output2.material, recipe.output2.amount); - } else { - rightStack.amount += recipe.output2.amount; - } + if(recipe.output2 != null) + if(rightStack == null ) { + rightStack = new MaterialStack(recipe.output2.material, recipe.output2.amount); + } else { + rightStack.amount += recipe.output2.amount; + } if(recipe.byproduct != null) {