diff options
| author | MadMan310 <66886359+MadMan310@users.noreply.github.com> | 2022-11-29 01:50:58 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-29 10:50:58 +0100 |
| commit | f985e28ae553428945f3ce3841ac036c98266128 (patch) | |
| tree | 278c857c13493a8d0fdaebfb9a3d9cb90d07a774 /src/main/java/goodgenerator/util | |
| parent | 766af258761d0cc88d44169d06ae47198218078e (diff) | |
| download | GT5-Unofficial-f985e28ae553428945f3ce3841ac036c98266128.tar.gz GT5-Unofficial-f985e28ae553428945f3ce3841ac036c98266128.tar.bz2 GT5-Unofficial-f985e28ae553428945f3ce3841ac036c98266128.zip | |
Component Assembly Line (#102)
* Initial Commit
* Added recipe generator for components LV-IV
* Added recipe generator for components LuV and beyond
This one took a LONG time to make work...
* Added structure and recipe processing
* Added Recipes for Controller and Casings
* Cleanup
* Assline gives proper amount same as assembler
* tooltip fix
* add support for BW glass and warded glass
* Added proper NEI handler
* spotless
* Spotless apply for branch componentAssemblyLine for #102 (#103)
* Update build-and-test.yml
* fix missing hatch element (#92)
* fix missing hatch element
* spotlessApply (#93)
Co-authored-by: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix bunch of yottank issues (#94)
* yot tank/hatch fix
* dep
* Add better naq fuel recipes to combat fusion spam (#91)
* Add higher tier naq fuel recipes
* Fix Hypogen (hopefully)
* Spotless >:(
* Slightly change tooltip on the Precise Assembler (#95)
0.03 mm changed to 7nm
* fix 0 stack of nuclear rod (#98)
* naq fuel change (#96)
* naq fuel change
* Spotless apply for branch naqfuel for #96 (#97)
* Slightly change tooltip on the Precise Assembler (#95)
0.03 mm changed to 7nm
* spotlessApply
Co-authored-by: MadMan310 <66886359+MadMan310@users.noreply.github.com>
Co-authored-by: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: MadMan310 <66886359+MadMan310@users.noreply.github.com>
* Naq Fuel 1,2,3 Changes (#99)
* Naq Emulsion line changes
* Mk1 recipe change
* Fuel value changes
* Mk2 fuel recipe changes
* Radiation proof plate recipe changes
* Fix sludge dust centrifuge amounts
* Remove Hafnium recipe for now
* Spotless
* thorium balance change (#76)
* Add implementation for tank info getter (#101)
* Add void excess option to yotta fluid tank (#100)
* Add void excess option to yotta fluid tank
* derp
* Added own localization of void excess toggle messages
* Update build.gradle
* update bc
* spotlessApply
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: GDCloud <93287602+GDCloudstrike@users.noreply.github.com>
Co-authored-by: MadMan310 <66886359+MadMan310@users.noreply.github.com>
Co-authored-by: xSkewer <43712386+xSkewer@users.noreply.github.com>
Co-authored-by: Maxim <maxim235@gmx.de>
Co-authored-by: GitHub GTNH Actions <>
* cleanup handler
* Overhauled recipe generator, added circuit wraps, buffed output efficiency
* Structure re-tiering
* Gravi -> Nuclear for UHV components (due to overflowing)
* spotless
* added new casings
* removed some debug info and added dep
* Fixed magnetic samarium fluid and other autogenerations
* fixed recipe tiering
* Removed Nuclear Star, to be replaced by the GT5U version
* spotless
* fixed recipe handling
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com>
Co-authored-by: GDCloud <93287602+GDCloudstrike@users.noreply.github.com>
Co-authored-by: xSkewer <43712386+xSkewer@users.noreply.github.com>
Co-authored-by: Maxim <maxim235@gmx.de>
Diffstat (limited to 'src/main/java/goodgenerator/util')
| -rw-r--r-- | src/main/java/goodgenerator/util/ItemRefer.java | 16 | ||||
| -rw-r--r-- | src/main/java/goodgenerator/util/Log.java | 8 | ||||
| -rw-r--r-- | src/main/java/goodgenerator/util/MyRecipeAdder.java | 111 | ||||
| -rw-r--r-- | src/main/java/goodgenerator/util/StackUtils.java | 81 |
4 files changed, 216 insertions, 0 deletions
diff --git a/src/main/java/goodgenerator/util/ItemRefer.java b/src/main/java/goodgenerator/util/ItemRefer.java index 3cd1adf25a..86ac3db64d 100644 --- a/src/main/java/goodgenerator/util/ItemRefer.java +++ b/src/main/java/goodgenerator/util/ItemRefer.java @@ -151,6 +151,22 @@ public final class ItemRefer { public static ItemRefer Compact_Fusion_MK5 = getItemStack(LFC[4]); public static ItemRefer Large_Essentia_Smeltery = getItemStack(LES); public static ItemRefer Coolant_Tower = getItemStack(CT); + public static ItemRefer Component_Assembly_Line = getItemStack(CompAssline); + + public static ItemRefer Compassline_Casing_LV = getItemStack(componentAssemblylineCasing, 0); + public static ItemRefer Compassline_Casing_MV = getItemStack(componentAssemblylineCasing, 1); + public static ItemRefer Compassline_Casing_HV = getItemStack(componentAssemblylineCasing, 2); + public static ItemRefer Compassline_Casing_EV = getItemStack(componentAssemblylineCasing, 3); + public static ItemRefer Compassline_Casing_IV = getItemStack(componentAssemblylineCasing, 4); + public static ItemRefer Compassline_Casing_LuV = getItemStack(componentAssemblylineCasing, 5); + public static ItemRefer Compassline_Casing_ZPM = getItemStack(componentAssemblylineCasing, 6); + public static ItemRefer Compassline_Casing_UV = getItemStack(componentAssemblylineCasing, 7); + public static ItemRefer Compassline_Casing_UHV = getItemStack(componentAssemblylineCasing, 8); + public static ItemRefer Compassline_Casing_UEV = getItemStack(componentAssemblylineCasing, 9); + public static ItemRefer Compassline_Casing_UIV = getItemStack(componentAssemblylineCasing, 10); + public static ItemRefer Compassline_Casing_UMV = getItemStack(componentAssemblylineCasing, 11); + public static ItemRefer Compassline_Casing_UXV = getItemStack(componentAssemblylineCasing, 12); + public static ItemRefer Compassline_Casing_MAX = getItemStack(componentAssemblylineCasing, 13); private Item mItem = null; private Block mBlock = null; diff --git a/src/main/java/goodgenerator/util/Log.java b/src/main/java/goodgenerator/util/Log.java new file mode 100644 index 0000000000..8b88ddf5f1 --- /dev/null +++ b/src/main/java/goodgenerator/util/Log.java @@ -0,0 +1,8 @@ +package goodgenerator.util; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class Log { + public static final Logger LOGGER = LogManager.getLogger("GoodGenerator"); +} diff --git a/src/main/java/goodgenerator/util/MyRecipeAdder.java b/src/main/java/goodgenerator/util/MyRecipeAdder.java index 3e2c5371a3..58e0540340 100644 --- a/src/main/java/goodgenerator/util/MyRecipeAdder.java +++ b/src/main/java/goodgenerator/util/MyRecipeAdder.java @@ -1,8 +1,11 @@ package goodgenerator.util; +import static gregtech.api.enums.GT_Values.NI; + import codechicken.nei.PositionedStack; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.nei.GT_NEI_DefaultHandler; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -467,6 +470,7 @@ public class MyRecipeAdder { } } + @SuppressWarnings("deprecation") public static class PreciseAssemblerRecipe extends GT_Recipe { public PreciseAssemblerRecipe( ItemStack[] input1, FluidStack[] input2, ItemStack output, int EUt, int ticks, int tier) { @@ -511,4 +515,111 @@ public class MyRecipeAdder { PA.addRecipe( false, aItemInputs, new ItemStack[] {aOutput}, null, null, aFluidInputs, null, aDuration, aEUt, aTier); } + + public static class ComponentAssemblyLineMapper extends GT_Recipe.GT_Recipe_Map { + + public ComponentAssemblyLineMapper( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed, + true); + } + + @Override + public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { + ArrayList<PositionedStack> inputStacks = new ArrayList<>(); + + if (recipe.mInputs != null) { + for (int j = 0; j < recipe.mInputs.length; j++) { + if (recipe.mInputs[j] == NI) continue; + inputStacks.add(new GT_NEI_DefaultHandler.FixedPositionedStack( + recipe.mInputs[j].copy(), 12 + 18 * (j % 3), 5 + 18 * (j / 3))); + } + } + if (recipe.mFluidInputs != null) { + for (int j = 0; j < recipe.mFluidInputs.length; j++) { + + inputStacks.add(new GT_NEI_DefaultHandler.FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true), + 84 + 18 * (j % 4), + 27 + 18 * (j / 4))); + } + } + return inputStacks; + } + + @Override + public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { + ArrayList<PositionedStack> outputStacks = new ArrayList<>(); + if (recipe.mOutputs != null) { + outputStacks.add(new GT_NEI_DefaultHandler.FixedPositionedStack(recipe.mOutputs[0].copy(), 138, 5)); + } + return outputStacks; + } + } + + public final ComponentAssemblyLineMapper COMPASSLINE_RECIPES = new ComponentAssemblyLineMapper( + new HashSet<>(110), + "gg.recipe.componentassemblyline", + "Component Assembly Line", + null, + "goodgenerator:textures/gui/ComponentAssline", + 9, + 1, + 0, + 0, + 1, + "Casing Tier: ", + 1, + "", + false, + false); + + public GT_Recipe addComponentAssemblyLineRecipe( + ItemStack[] ItemInputArray, + FluidStack[] FluidInputArray, + ItemStack OutputItem, + int aDuration, + int aEUt, + int casingLevel) { + return COMPASSLINE_RECIPES.addRecipe( + false, + ItemInputArray, + new ItemStack[] {OutputItem}, + null, + FluidInputArray, + null, + aDuration, + aEUt, + casingLevel); + } } diff --git a/src/main/java/goodgenerator/util/StackUtils.java b/src/main/java/goodgenerator/util/StackUtils.java new file mode 100644 index 0000000000..1d7dcc3ac8 --- /dev/null +++ b/src/main/java/goodgenerator/util/StackUtils.java @@ -0,0 +1,81 @@ +package goodgenerator.util; + +import gregtech.api.util.GT_Utility; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import net.minecraft.item.ItemStack; + +public class StackUtils { + + /** + * Multiplies one ItemStack by a multiplier, and splits it into as many full stacks as it needs to. + * @param stack The ItemStack you want to multiply + * @param multiplier The number the stack is multiplied by + * @return A List of stacks that, in total, are the same as the input ItemStack after it has been multiplied. + */ + public static List<ItemStack> multiplyAndSplitIntoStacks(ItemStack stack, int multiplier) { + int totalItems = stack.stackSize * multiplier; + ArrayList<ItemStack> stacks = new ArrayList<>(); + if (totalItems >= 64) { + for (int i = 0; i < totalItems / 64; i++) { + stacks.add(GT_Utility.copyAmount(64, stack)); + } + } + if (totalItems % 64 > 0) { + stacks.add(GT_Utility.copyAmount(totalItems % 64, stack)); + } + return stacks; + } + + /** + * Merges the ItemStacks in the array into full stacks. + * */ + public static ArrayList<ItemStack> mergeStacks(List<ItemStack> stacks) { + ArrayList<ItemStack> output = new ArrayList<>(); + for (int index = 0; index < stacks.size(); index++) { + ItemStack i = stacks.get(index); + boolean hasDupe = false; + int newSize = i.stackSize; + for (int j = index + 1; j < stacks.size(); j++) { + ItemStack is2 = stacks.get(j); + if (GT_Utility.areStacksEqual(i, is2)) { + hasDupe = true; + newSize += is2.stackSize; + stacks.remove(j); + j--; + } + } + if (hasDupe) { + if (newSize >= 64) { + for (int k = 0; k < newSize / 64; k++) { + output.add(GT_Utility.copyAmount(64, i)); + } + } + if (newSize % 64 > 0) { + output.add(GT_Utility.copyAmount(newSize > 64 ? newSize % 64 : newSize, i)); + } + } else output.add(i); + } + return output; + } + + public static HashMap<ItemStack, Integer> getTotalItems(List<ItemStack> items) { + HashMap<ItemStack, Integer> totals = new HashMap<>(); + itemLoop: + for (ItemStack item : items) { + int t = items.stream() + .filter(i2 -> GT_Utility.areStacksEqual(item, i2)) + .mapToInt(i -> i.stackSize) + .sum(); + for (ItemStack i2 : totals.keySet()) if (GT_Utility.areStacksEqual(item, i2)) continue itemLoop; + totals.put(GT_Utility.copyAmount(1, item), t); + } + return totals; + } + + public static HashMap<ItemStack, Integer> getTotalItems(ItemStack[] items) { + return getTotalItems(Arrays.asList(items)); + } +} |
