diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java | 252 | ||||
-rw-r--r-- | src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java | 308 |
2 files changed, 294 insertions, 266 deletions
diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java index 5b24b1e6ee..e9f85b1700 100644 --- a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java @@ -43,6 +43,7 @@ import gregtech.api.enums.TierEU; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.recipe.RecipeCategories; import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTLog; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; @@ -61,153 +62,168 @@ public class CellLoader implements IWerkstoffRunnable { || werkstoff.getStats() .isCentrifuge()) && !werkstoff.hasItemType(dust)) { - List<FluidStack> flOutputs = new ArrayList<>(); - List<ItemStack> stOutputs = new ArrayList<>(); - HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>(); - int cells = 0; - for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents() + + if (werkstoff.getContents() .getValue() - .toArray(new Pair[0])) { - if (container.getKey() instanceof Materials) { - if ((((Materials) container.getKey()).hasCorrespondingGas() - || ((Materials) container.getKey()).hasCorrespondingFluid() - || ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID) - && ((Materials) container.getKey()).getDust(0) == null) { - FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000L * container.getValue()); - if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = ((Materials) container.getKey()).getFluid(1000L * container.getValue()); - } - flOutputs.add(tmpFl); - if (flOutputs.size() > 1) { + .size() > 0) { + + List<FluidStack> flOutputs = new ArrayList<>(); + List<ItemStack> stOutputs = new ArrayList<>(); + HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>(); + int cells = 0; + for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents() + .getValue() + .toArray(new Pair[0])) { + if (container.getKey() instanceof Materials) { + if ((((Materials) container.getKey()).hasCorrespondingGas() + || ((Materials) container.getKey()).hasCorrespondingFluid() + || ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID) + && ((Materials) container.getKey()).getDust(0) == null) { + FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000L * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Materials) container.getKey()).getFluid(1000L * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Materials) container.getKey()).getCells(container.getValue())); + tracker.put( + container.getKey(), + new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Materials) container.getKey()).getCells( + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + cells += container.getValue(); + } + } else { + if (((Materials) container.getKey()).getDust(container.getValue()) == null) continue; if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Materials) container.getKey()).getCells(container.getValue())); + stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); } else { stOutputs.add( - ((Materials) container.getKey()).getCells( + ((Materials) container.getKey()).getDust( tracker.get(container.getKey()) .getKey() + container.getValue())); stOutputs.remove( tracker.get(container.getKey()) .getValue() + 1); } - cells += container.getValue(); } - } else { - if (((Materials) container.getKey()).getDust(container.getValue()) == null) continue; - if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); - tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else if (container.getKey() instanceof Werkstoff) { + if (((Werkstoff) container.getKey()).getStats() + .isGas() || ((Werkstoff) container.getKey()).hasItemType(cell)) { + FluidStack tmpFl = ((Werkstoff) container.getKey()) + .getFluidOrGas(1000 * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue())); + tracker.put( + container.getKey(), + new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Werkstoff) container.getKey()).get( + cell, + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + cells += container.getValue(); + } } else { - stOutputs.add( - ((Materials) container.getKey()).getDust( - tracker.get(container.getKey()) - .getKey() + container.getValue())); - stOutputs.remove( - tracker.get(container.getKey()) - .getValue() + 1); - } - } - } else if (container.getKey() instanceof Werkstoff) { - if (((Werkstoff) container.getKey()).getStats() - .isGas() || ((Werkstoff) container.getKey()).hasItemType(cell)) { - FluidStack tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); - if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); - } - flOutputs.add(tmpFl); - if (flOutputs.size() > 1) { + if (!((Werkstoff) container.getKey()).hasItemType(dust)) continue; if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue())); + stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); } else { stOutputs.add( ((Werkstoff) container.getKey()).get( - cell, + dust, tracker.get(container.getKey()) .getKey() + container.getValue())); stOutputs.remove( tracker.get(container.getKey()) .getValue() + 1); } - cells += container.getValue(); - } - } else { - if (!((Werkstoff) container.getKey()).hasItemType(dust)) continue; - if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); - tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); - } else { - stOutputs.add( - ((Werkstoff) container.getKey()).get( - dust, - tracker.get(container.getKey()) - .getKey() + container.getValue())); - stOutputs.remove( - tracker.get(container.getKey()) - .getValue() + 1); } } } - } - ItemStack input = werkstoff.get(cell); - input.stackSize = 1; + ItemStack input = werkstoff.get(cell); + input.stackSize = 1; - int cellEmpty = cells - 1; + int cellEmpty = cells - 1; - stOutputs.add(Materials.Empty.getCells(-cellEmpty)); - if (werkstoff.getStats() - .isElektrolysis()) - RecipeMaps.electrolyzerRecipes.add( - new GTRecipe( - true, - new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, - stOutputs.toArray(new ItemStack[0]), - null, - null, - new FluidStack[] { null }, - new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, - (int) Math.max( - 1L, - Math.abs( - werkstoff.getStats() - .getProtons() - * werkstoff.getContents() - .getValue() - .size())), - Math.min( - 4, - werkstoff.getContents() - .getValue() - .size()) - * 30, - 0)); - if (werkstoff.getStats() - .isCentrifuge()) - RecipeMaps.centrifugeRecipes.add( - new GTRecipe( - true, - new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, - stOutputs.toArray(new ItemStack[0]), - null, - null, - new FluidStack[] { null }, - new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, - (int) Math.max( - 1L, - Math.abs( - werkstoff.getStats() - .getMass() - * werkstoff.getContents() - .getValue() - .size())), - Math.min( - 4, - werkstoff.getContents() - .getValue() - .size()) - * 5, - 0)); + stOutputs.add(Materials.Empty.getCells(-cellEmpty)); + if (werkstoff.getStats() + .isElektrolysis()) + RecipeMaps.electrolyzerRecipes.add( + new GTRecipe( + true, + new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + * werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0)); + if (werkstoff.getStats() + .isCentrifuge()) + RecipeMaps.centrifugeRecipes.add( + new GTRecipe( + true, + new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getMass() + * werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + } else { + GTLog.err.println( + "Autogenerated recipe(s) using Werkstoff material '" + werkstoff.getDefaultName() + + "' (fluid) removed due to no contents in material definition."); + } } // Tank "Recipe" diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java index 04db75e0d3..187ca174d7 100644 --- a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java @@ -47,6 +47,7 @@ import gregtech.api.enums.TextureSet; import gregtech.api.enums.TierEU; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTLog; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTRecipeConstants; @@ -71,50 +72,94 @@ public class DustLoader implements IWerkstoffRunnable { || werkstoffStats.isCentrifuge() || werkstoff.getGenerationFeatures() .hasChemicalRecipes()) { - for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents() + + if (werkstoff.getContents() .getValue() - .toArray(new Pair[0])) { - final ISubTagContainer key = container.getKey(); - final int value = container.getValue(); - if (key instanceof Materials materialKey) { - if ((materialKey.getGas(0) != null || materialKey.getFluid(0) != null - || materialKey.mIconSet == TextureSet.SET_FLUID) && materialKey.getDust(0) == null) { - FluidStack tmpFl = materialKey.getGas(1000L * value); - if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = materialKey.getFluid(1000L * value); - } - flOutputs.add(tmpFl); - if (flOutputs.size() > 1) { + .size() > 0) { + + for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents() + .getValue() + .toArray(new Pair[0])) { + final ISubTagContainer key = container.getKey(); + final int value = container.getValue(); + if (key instanceof Materials materialKey) { + if ((materialKey.getGas(0) != null || materialKey.getFluid(0) != null + || materialKey.mIconSet == TextureSet.SET_FLUID) && materialKey.getDust(0) == null) { + FluidStack tmpFl = materialKey.getGas(1000L * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = materialKey.getFluid(1000L * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getCells( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } else { + if (materialKey.getDust(value) == null) { + if (materialKey.getCells(value) == null + || materialKey.getMolten(0) == null && materialKey.getSolid(0) == null) + continue; + FluidStack tmpFl = materialKey.getMolten(1000L * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = materialKey.getSolid(1000L * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getCells( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } if (!tracker.containsKey(key)) { - stOutputs.add(materialKey.getCells(value)); + stOutputs.add(materialKey.getDust(value)); tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { stOutputs.add( - materialKey.getCells( + materialKey.getDust( tracker.get(key) .getKey() + value)); stOutputs.remove( tracker.get(key) .getValue() + 1); } - cells += value; } - } else { - if (materialKey.getDust(value) == null) { - if (materialKey.getCells(value) == null - || materialKey.getMolten(0) == null && materialKey.getSolid(0) == null) continue; - FluidStack tmpFl = materialKey.getMolten(1000L * value); + } else if (key instanceof Werkstoff werkstoffKey) { + if (werkstoffKey.getStats() + .isGas() || werkstoffKey.hasItemType(cell)) { + FluidStack tmpFl = werkstoffKey.getFluidOrGas(1000 * value); if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = materialKey.getSolid(1000L * value); + tmpFl = werkstoffKey.getFluidOrGas(1000 * value); } flOutputs.add(tmpFl); if (flOutputs.size() > 1) { if (!tracker.containsKey(key)) { - stOutputs.add(materialKey.getCells(value)); + stOutputs.add(werkstoffKey.get(cell, value)); tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { stOutputs.add( - materialKey.getCells( + werkstoffKey.get( + cell, tracker.get(key) .getKey() + value)); stOutputs.remove( @@ -123,92 +168,29 @@ public class DustLoader implements IWerkstoffRunnable { } cells += value; } - } - if (!tracker.containsKey(key)) { - stOutputs.add(materialKey.getDust(value)); - tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { - stOutputs.add( - materialKey.getDust( - tracker.get(key) - .getKey() + value)); - stOutputs.remove( - tracker.get(key) - .getValue() + 1); - } - } - } else if (key instanceof Werkstoff werkstoffKey) { - if (werkstoffKey.getStats() - .isGas() || werkstoffKey.hasItemType(cell)) { - FluidStack tmpFl = werkstoffKey.getFluidOrGas(1000 * value); - if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = werkstoffKey.getFluidOrGas(1000 * value); - } - flOutputs.add(tmpFl); - if (flOutputs.size() > 1) { + if (!werkstoffKey.hasItemType(dust)) continue; if (!tracker.containsKey(key)) { - stOutputs.add(werkstoffKey.get(cell, value)); + stOutputs.add(werkstoffKey.get(dust, value)); tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { stOutputs.add( werkstoffKey.get( - cell, + dust, tracker.get(key) .getKey() + value)); stOutputs.remove( tracker.get(key) .getValue() + 1); } - cells += value; - } - } else { - if (!werkstoffKey.hasItemType(dust)) continue; - if (!tracker.containsKey(key)) { - stOutputs.add(werkstoffKey.get(dust, value)); - tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); - } else { - stOutputs.add( - werkstoffKey.get( - dust, - tracker.get(key) - .getKey() + value)); - stOutputs.remove( - tracker.get(key) - .getValue() + 1); } } } - } - ItemStack input = werkstoff.get(dust); - input.stackSize = werkstoff.getContents() - .getKey(); - if (werkstoffStats.isElektrolysis()) { - GTRecipe tRecipe = new GTRecipe( - true, - new ItemStack[] { input, cells > 0 ? Materials.Empty.getCells(cells) : null }, - stOutputs.toArray(new ItemStack[0]), - null, - null, - new FluidStack[] { null }, - new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, - (int) Math.max( - 1L, - Math.abs( - werkstoffStats.getProtons() / werkstoff.getContents() - .getValue() - .size())), - Math.min( - 4, - werkstoff.getContents() - .getValue() - .size()) - * 30, - 0); - RecipeMaps.electrolyzerRecipes.add(tRecipe); - } - if (werkstoffStats.isCentrifuge()) { - RecipeMaps.centrifugeRecipes.add( - new GTRecipe( + ItemStack input = werkstoff.get(dust); + input.stackSize = werkstoff.getContents() + .getKey(); + if (werkstoffStats.isElektrolysis()) { + GTRecipe tRecipe = new GTRecipe( true, new ItemStack[] { input, cells > 0 ? Materials.Empty.getCells(cells) : null }, stOutputs.toArray(new ItemStack[0]), @@ -219,7 +201,7 @@ public class DustLoader implements IWerkstoffRunnable { (int) Math.max( 1L, Math.abs( - werkstoffStats.getMass() / werkstoff.getContents() + werkstoffStats.getProtons() / werkstoff.getContents() .getValue() .size())), Math.min( @@ -227,60 +209,90 @@ public class DustLoader implements IWerkstoffRunnable { werkstoff.getContents() .getValue() .size()) - * 5, - 0)); - } - if (werkstoff.getGenerationFeatures() - .hasChemicalRecipes()) { - if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); - GTValues.RA.stdBuilder() - .itemInputs(stOutputs.toArray(new ItemStack[0])) - .itemOutputs(input) - .fluidInputs(flOutputs.toArray(new FluidStack[0])) - .duration( - (int) Math.max( - 1L, - Math.abs( - werkstoffStats.getProtons() / werkstoff.getContents() + * 30, + 0); + RecipeMaps.electrolyzerRecipes.add(tRecipe); + } + if (werkstoffStats.isCentrifuge()) { + RecipeMaps.centrifugeRecipes.add( + new GTRecipe( + true, + new ItemStack[] { input, cells > 0 ? Materials.Empty.getCells(cells) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoffStats.getMass() / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() .getValue() - .size()))) - .eut( - Math.min( - 4, - werkstoff.getContents() - .getValue() - .size()) - * 30) - .addTo(GTRecipeConstants.UniversalChemical); - } - if (werkstoff.getGenerationFeatures() - .hasMixerRecipes()) { - if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); - short circuitID = werkstoff.getMixCircuit(); - ItemStack circuit = circuitID == -1 ? null : GTUtility.getIntegratedCircuit(circuitID); - if (circuit != null) stOutputs.add(circuit); - RecipeMaps.mixerRecipes.add( - new GTRecipe( - true, - stOutputs.toArray(new ItemStack[0]), - new ItemStack[] { input }, - null, - null, - new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, - null, - (int) Math.max( - 1L, - Math.abs( - werkstoffStats.getMass() / werkstoff.getContents() + .size()) + * 5, + 0)); + } + if (werkstoff.getGenerationFeatures() + .hasChemicalRecipes()) { + if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); + GTValues.RA.stdBuilder() + .itemInputs(stOutputs.toArray(new ItemStack[0])) + .itemOutputs(input) + .fluidInputs(flOutputs.toArray(new FluidStack[0])) + .duration( + (int) Math.max( + 1L, + Math.abs( + werkstoffStats.getProtons() / werkstoff.getContents() + .getValue() + .size()))) + .eut( + Math.min( + 4, + werkstoff.getContents() .getValue() - .size())), - Math.min( - 4, - werkstoff.getContents() - .getValue() - .size()) - * 5, - 0)); + .size()) + * 30) + .addTo(GTRecipeConstants.UniversalChemical); + } + if (werkstoff.getGenerationFeatures() + .hasMixerRecipes()) { + if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); + short circuitID = werkstoff.getMixCircuit(); + ItemStack circuit = circuitID == -1 ? null : GTUtility.getIntegratedCircuit(circuitID); + if (circuit != null) stOutputs.add(circuit); + RecipeMaps.mixerRecipes.add( + new GTRecipe( + true, + stOutputs.toArray(new ItemStack[0]), + new ItemStack[] { input }, + null, + null, + new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null }, + null, + (int) Math.max( + 1L, + Math.abs( + werkstoffStats.getMass() / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + } + } else { + GTLog.err.println( + "Autogenerated recipe(s) using Werkstoff material '" + werkstoff.getDefaultName() + + "' (dust) removed due to no contents in material definition."); } } |