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/loader | |
| 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/loader')
3 files changed, 861 insertions, 2 deletions
diff --git a/src/main/java/goodgenerator/loader/ComponentAssemblyLineMiscRecipes.java b/src/main/java/goodgenerator/loader/ComponentAssemblyLineMiscRecipes.java new file mode 100644 index 0000000000..41181d858c --- /dev/null +++ b/src/main/java/goodgenerator/loader/ComponentAssemblyLineMiscRecipes.java @@ -0,0 +1,459 @@ +package goodgenerator.loader; + +import static goodgenerator.util.ItemRefer.*; +import static goodgenerator.util.Log.LOGGER; + +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.technus.tectech.recipe.TT_recipeAdder; +import com.google.common.collect.HashBiMap; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.recipe.common.CI; +import java.util.HashMap; +import javax.annotation.Nullable; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import org.apache.logging.log4j.Level; + +public class ComponentAssemblyLineMiscRecipes { + + @SuppressWarnings("deprecation") + public static final Materials[] circuitTierMaterials = { + Materials.Primitive, + Materials.Basic, + Materials.Good, + Materials.Advanced, + Materials.Data, + Materials.Elite, + Materials.Master, + Materials.Ultimate, + Materials.Superconductor, + Materials.Infinite, + Materials.Bio, + Materials.Nano, + Materials.Piko, + Materials.Quantum + }; + + static final HashBiMap<Materials, Integer> MatToTier = HashBiMap.create(); + + static final HashMap<ItemStack, Integer> CircuitToTier = new HashMap<>(); + + static void run() { + for (int i = 0; i < circuitTierMaterials.length; i++) MatToTier.put(circuitTierMaterials[i], i); + + MatToTier.forEach((mat, tier) -> { + for (ItemStack item : mat.mMaterialItems) CircuitToTier.put(item, tier); + }); + + generateCasingRecipes(); + generateWrapRecipes(); + // Try and find the ZPM Fluid solidifier + ItemStack solidifier; + try { + Class<?> c = Class.forName("com.dreammaster.gthandler.CustomItemList"); + Object maybeSolidifier = c.getMethod("valueOf", String.class).invoke(null, "FluidSolidifierZPM"); + solidifier = + (ItemStack) (c.getMethod("get", long.class, Object[].class).invoke(maybeSolidifier, 16L, null)); + if (GT_Utility.isStackValid(solidifier)) LOGGER.log(Level.INFO, "ZPM Fluid Solidifier found."); + else throw new NullPointerException(); + } catch (Exception e) { + LOGGER.log(Level.ERROR, "ZPM Fluid Solidifier not found, falling back to IV.", e); + solidifier = ItemList.Machine_IV_FluidSolidifier.get(16); + } + + // The controller itself + GT_Values.RA.addAssemblylineRecipe( + ItemList.Machine_Multi_Assemblyline.get(1), + 3600 * 20, + new Object[] { + ItemList.Machine_Multi_Assemblyline.get(16L), + ItemList.Casing_Assembler.get(16L), + ItemList.Casing_Gearbox_TungstenSteel.get(32L), + ComponentType.Robot_Arm.getComponent(8).get(16), + ComponentType.Conveyor_Module.getComponent(8).get(32), + ComponentType.Electric_Motor.getComponent(7).get(32), + GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Polybenzimidazole, 16), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Iridium, 32), + solidifier, + getALCircuit(8, 16), + getALCircuit(7, 20), + getALCircuit(6, 24) + }, + new FluidStack[] { + new FluidStack(FluidRegistry.getFluid("molten.indalloy140"), 144 * 12), + Materials.Naquadria.getMolten(144 * 16), + Materials.Lubricant.getFluid(5000) + }, + Component_Assembly_Line.get(1), + 30 * 20, + getV(8) * 2); + } + + /** Recipes for the Component Assembly Line Casings */ + private static void generateCasingRecipes() { + int t = 1; + // lv 1 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Steel, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Steel, 4), + ComponentType.Robot_Arm.getComponent(t).get(4), + ComponentType.Electric_Piston.getComponent(t).get(8), + ComponentType.Electric_Motor.getComponent(t).get(10), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Steel, 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Tin, 6), + getCircuit(t, 16), + }, + Materials.SolderingAlloy.getMolten(144 * (t + 3)), + Compassline_Casing_LV.get(1), + 16 * 20, + getV(t)); + // mv 2 + t++; + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Aluminium, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Aluminium, 4), + ComponentType.Robot_Arm.getComponent(t).get(4), + ComponentType.Electric_Piston.getComponent(t).get(8), + ComponentType.Electric_Motor.getComponent(t).get(10), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Aluminium, 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.AnyCopper, 6), + getCircuit(t, 8), + getCircuit(t - 1, 16) + }, + Materials.SolderingAlloy.getMolten(144 * (t + 1)), + Compassline_Casing_MV.get(1), + 16 * 20, + getV(t)); + // hv 3 + t++; + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.StainlessSteel, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.StainlessSteel, 4), + ComponentType.Robot_Arm.getComponent(t).get(4), + ComponentType.Electric_Piston.getComponent(t).get(8), + ComponentType.Electric_Motor.getComponent(t).get(10), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.StainlessSteel, 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Gold, 6), + getCircuit(t, 8), + getCircuit(t - 1, 16) + }, + Materials.SolderingAlloy.getMolten(144 * (t + 1)), + Compassline_Casing_HV.get(1), + 16 * 20, + getV(t)); + // ev 4 + t++; + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Titanium, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Titanium, 4), + ComponentType.Robot_Arm.getComponent(t).get(4), + ComponentType.Electric_Piston.getComponent(t).get(8), + ComponentType.Electric_Motor.getComponent(t).get(10), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Titanium, 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Aluminium, 6), + getCircuit(t, 8), + getCircuit(t - 1, 16) + }, + Materials.SolderingAlloy.getMolten(144 * (t + 1)), + Compassline_Casing_EV.get(1), + 16 * 20, + getV(t)); + // iv 5 + t++; + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.TungstenSteel, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.TungstenSteel, 4), + ComponentType.Robot_Arm.getComponent(t).get(4), + ComponentType.Electric_Piston.getComponent(t).get(8), + ComponentType.Electric_Motor.getComponent(t).get(10), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.TungstenSteel, 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Tungsten, 6), + getCircuit(t, 8), + getCircuit(t - 1, 16) + }, + Materials.SolderingAlloy.getMolten(144 * (t + 1)), + Compassline_Casing_IV.get(1), + 16 * 20, + getV(t)); + + Fluid sold = FluidRegistry.getFluid("molten.indalloy140"); + // Assline Recipes! + // luv 6 + t++; + GT_Values.RA.addAssemblylineRecipe( + Compassline_Casing_IV.get(1), + 2250 << t, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Europium, 1), + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.plateDense, 6), + ComponentType.Robot_Arm.getComponent(t).get(8), + ComponentType.Electric_Piston.getComponent(t).get(10), + ComponentType.Electric_Motor.getComponent(t).get(16), + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.gearGt, 4), + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.gearGtSmall, 16), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.VanadiumGallium, 8), + getALCircuit(t, 8), + getALCircuit(t - 1, 16) + }, + new FluidStack[] { + new FluidStack(sold, 144 * t * 4), + CI.getTieredFluid(t, 144 * t * 2), + CI.getAlternativeTieredFluid(t, 144 * t), + Materials.Lubricant.getFluid(1000 * (t - 2)) + }, + Compassline_Casing_LuV.get(1), + 30 * 20, + 6000); + // zpm 7 + t++; + GT_Values.RA.addAssemblylineRecipe( + Compassline_Casing_LuV.get(1), + 2250 << t, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Iridium, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Iridium, 6), + ComponentType.Robot_Arm.getComponent(t).get(8), + ComponentType.Electric_Piston.getComponent(t).get(10), + ComponentType.Electric_Motor.getComponent(t).get(16), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iridium, 4), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Iridium, 16), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Naquadah, 8), + getALCircuit(t, 8), + getALCircuit(t - 1, 16) + }, + new FluidStack[] { + new FluidStack(sold, 144 * t * 4), + CI.getTieredFluid(t, 144 * t * 2), + CI.getAlternativeTieredFluid(t, 144 * t), + Materials.Lubricant.getFluid(1000 * (t - 2)) + }, + Compassline_Casing_ZPM.get(1), + 30 * 20, + 24000); + // uv 8 + t++; + GT_Values.RA.addAssemblylineRecipe( + Compassline_Casing_ZPM.get(1), + 2250 << t, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Osmium, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Osmium, 6), + ComponentType.Robot_Arm.getComponent(t).get(8), + ComponentType.Electric_Piston.getComponent(t).get(10), + ComponentType.Electric_Motor.getComponent(t).get(16), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Osmium, 4), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Osmium, 16), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NaquadahAlloy, 8), + getALCircuit(t, 8), + getALCircuit(t - 1, 16) + }, + new FluidStack[] { + new FluidStack(sold, 144 * t * 4), + CI.getTieredFluid(t, 144 * t * 2), + CI.getAlternativeTieredFluid(t, 144 * t), + Materials.Lubricant.getFluid(1000 * (t - 2)) + }, + Compassline_Casing_UV.get(1), + 30 * 20, + 100000); + // uhv 9 + t++; + TT_recipeAdder.addResearchableAssemblylineRecipe( + Compassline_Casing_UV.get(1), + 375 << (t - 2), + 1 << (t - 3), + 500000, + 1, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.CosmicNeutronium, 6), + ComponentType.Robot_Arm.getComponent(t).get(8), + ComponentType.Electric_Piston.getComponent(t).get(10), + ComponentType.Electric_Motor.getComponent(t).get(16), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.CosmicNeutronium, 4), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.CosmicNeutronium, 16), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 8), + getALCircuit(t, 8), + getALCircuit(t - 1, 16) + }, + new FluidStack[] { + new FluidStack(sold, 144 * t * 4), + Materials.Naquadria.getMolten(144 * t * 4), + CI.getTieredFluid(t, 144 * t * 2), + Materials.Lubricant.getFluid(1000 * (t - 2)) + }, + Compassline_Casing_UHV.get(1), + 50 * 20, + 500000); + sold = FluidRegistry.getFluid("molten.mutatedlivingsolder"); + // uev 10 + t++; + TT_recipeAdder.addResearchableAssemblylineRecipe( + Compassline_Casing_UHV.get(1), + 375 << (t - 2), + 1 << (t - 3), + 2000000, + 1, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Infinity, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Infinity, 6), + ComponentType.Robot_Arm.getComponent(t).get(8), + ComponentType.Electric_Piston.getComponent(t).get(10), + ComponentType.Electric_Motor.getComponent(t).get(16), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Infinity, 4), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Infinity, 16), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 8), + getALCircuit(t, 8), + getALCircuit(t - 1, 16) + }, + new FluidStack[] { + new FluidStack(sold, 144 * t * 4), + Materials.Quantium.getMolten(144 * t * 4), + CI.getTieredFluid(t, 144 * t * 2), + Materials.Lubricant.getFluid(1000 * (t - 2)) + }, + Compassline_Casing_UEV.get(1), + 50 * 20, + 2000000); + // uiv 11 + t++; + TT_recipeAdder.addResearchableAssemblylineRecipe( + Compassline_Casing_UEV.get(1), + 375 << (t - 2), + 1 << (t - 3), + 8000000, + 1, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.TranscendentMetal, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.TranscendentMetal, 6), + ComponentType.Robot_Arm.getComponent(t).get(8), + ComponentType.Electric_Piston.getComponent(t).get(10), + ComponentType.Electric_Motor.getComponent(t).get(16), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.TranscendentMetal, 4), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.TranscendentMetal, 16), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 8), + getALCircuit(t, 8), + getALCircuit(t - 1, 16) + }, + new FluidStack[] { + new FluidStack(sold, 144 * t * 4), + CI.getTieredFluid(t, 144 * t * 2), + CI.getAlternativeTieredFluid(t - 1, 144 * t * 2), + Materials.Lubricant.getFluid(1000 * (t - 2)) + }, + Compassline_Casing_UIV.get(1), + 50 * 20, + 8000000); + // umv 12 + t++; + TT_recipeAdder.addResearchableAssemblylineRecipe( + Compassline_Casing_UIV.get(1), + 375 << (t - 2), + 1 << (t - 3), + 32000000, + 1, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.SpaceTime, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.SpaceTime, 6), + ComponentType.Robot_Arm.getComponent(t).get(8), + ComponentType.Electric_Piston.getComponent(t).get(10), + ComponentType.Electric_Motor.getComponent(t).get(16), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.SpaceTime, 4), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.SpaceTime, 16), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 8), + getALCircuit(t, 8), + getALCircuit(t - 1, 16) + }, + new FluidStack[] { + new FluidStack(sold, 144 * t * 4), + CI.getTieredFluid(t - 1, 144 * t * 2), + CI.getAlternativeTieredFluid(t - 2, 144 * t * 2), + Materials.Lubricant.getFluid(1000 * (t - 2)) + }, + Compassline_Casing_UMV.get(1), + 50 * 20, + 32000000); + } + + private static int getV(int tier) { + return (int) (GT_Values.V[tier] - (GT_Values.V[tier] >> 4)); + } + + private static void generateWrapRecipes() { + for (int i = 0; i <= 10; i++) { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] {getCircuit(i, 16)}, + Materials.SolderingAlloy.getMolten(72L), + new ItemStack(Loaders.circuitWrap, 1, i), + 30 * 20, + 30); + } + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] {GameRegistry.findItemStack("dreamcraft", "item.NanoCircuit", 16)}, + Materials.SolderingAlloy.getMolten(72L), + new ItemStack(Loaders.circuitWrap, 1, 11), + 30 * 20, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] {GameRegistry.findItemStack("dreamcraft", "item.PikoCircuit", 16)}, + Materials.SolderingAlloy.getMolten(72L), + new ItemStack(Loaders.circuitWrap, 1, 12), + 30 * 20, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] {GameRegistry.findItemStack("dreamcraft", "item.QuantumCircuit", 16)}, + Materials.SolderingAlloy.getMolten(72L), + new ItemStack(Loaders.circuitWrap, 1, 13), + 30 * 20, + 30); + } + + @SuppressWarnings("unused") + private enum ComponentType { + Electric_Motor, + Electric_Piston, + Robot_Arm, + Electric_Pump, + Field_Generator, + Conveyor_Module, + Emitter, + Sensor; + + public ItemList getComponent(int tier) { + if (tier < 0 || tier > GT_Values.VN.length) throw new IllegalArgumentException("Tier is out of range!"); + return ItemList.valueOf(this.name() + "_" + GT_Values.VN[tier]); + } + } + + private static ItemStack getCircuit(int tier, long amount) { + return GT_OreDictUnificator.get(OrePrefixes.circuit, getCircuitMaterial(tier), amount); + } + + private static Object[] getALCircuit(int tier, int amount) { + return new Object[] {OrePrefixes.circuit.get(getCircuitMaterial(tier)), amount}; + } + + @Nullable + public static Materials getCircuitMaterial(int tier) { + Materials circuitMaterial; + try { + circuitMaterial = circuitTierMaterials[tier]; + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + return circuitMaterial; + } +} diff --git a/src/main/java/goodgenerator/loader/ComponentAssemblyLineRecipeLoader.java b/src/main/java/goodgenerator/loader/ComponentAssemblyLineRecipeLoader.java new file mode 100644 index 0000000000..dba7cda79e --- /dev/null +++ b/src/main/java/goodgenerator/loader/ComponentAssemblyLineRecipeLoader.java @@ -0,0 +1,360 @@ +package goodgenerator.loader; + +import static goodgenerator.util.StackUtils.*; + +import goodgenerator.util.MyRecipeAdder; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_IntegratedCircuit_Item; +import java.util.*; +import java.util.stream.Collectors; +import javax.annotation.Nullable; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.tuple.Pair; + +public class ComponentAssemblyLineRecipeLoader { + private static final String[] compPrefixes = { + "Electric_Motor_", + "Electric_Piston_", + "Electric_Pump_", + "Robot_Arm_", + "Conveyor_Module_", + "Emitter_", + "Sensor_", + "Field_Generator_", + }; + private static final String[] blacklistedDictPrefixes = {"circuit"}; + private static final String[] softBlacklistedDictPrefixes = {"Any", "crafting"}; + + private static LinkedHashMap<List<GT_Recipe>, Pair<ItemList, Integer>> allAssemblerRecipes; + private static LinkedHashMap<List<GT_Recipe.GT_Recipe_AssemblyLine>, Pair<ItemList, Integer>> allAsslineRecipes; + + private static final HashMap<OrePrefixes, OrePrefixes> conversion = new HashMap<>(); + + private static final int INPUT_MULTIPLIER = 48; + private static final int OUTPUT_MULTIPLIER = 64; + + public static void run() { + ComponentAssemblyLineMiscRecipes.run(); + conversion.put(OrePrefixes.cableGt01, OrePrefixes.cableGt16); + conversion.put(OrePrefixes.wireGt01, OrePrefixes.wireGt16); + conversion.put(OrePrefixes.cableGt02, OrePrefixes.cableGt16); + conversion.put(OrePrefixes.wireGt02, OrePrefixes.wireGt16); + conversion.put(OrePrefixes.cableGt04, OrePrefixes.cableGt16); + conversion.put(OrePrefixes.wireGt04, OrePrefixes.wireGt16); + conversion.put(OrePrefixes.cableGt08, OrePrefixes.cableGt16); + conversion.put(OrePrefixes.wireGt08, OrePrefixes.wireGt16); + conversion.put(OrePrefixes.plate, OrePrefixes.plateDense); + conversion.put(OrePrefixes.foil, OrePrefixes.plate); + conversion.put(OrePrefixes.stick, OrePrefixes.stickLong); + conversion.put(OrePrefixes.gearGtSmall, OrePrefixes.gearGt); + findAllRecipes(); + generateAssemblerRecipes(); + generateAsslineRecipes(); + } + + /** Normal assembler recipes (LV-IV) */ + private static void generateAssemblerRecipes() { + allAssemblerRecipes.forEach((recipeList, info) -> { + for (GT_Recipe recipe : recipeList) { + if (recipe != null) { + ArrayList<ItemStack> fixedInputs = new ArrayList<>(); + ArrayList<FluidStack> fixedFluids = new ArrayList<>(); + + // This is done in order to differentiate between emitter and sensor recipes. Without the circuit, + // both components have virtually the same recipe after the inputs are melted. + if (info.getLeft().name().contains("Sensor")) { + fixedInputs.add(GT_Utility.getIntegratedCircuit(1)); + } + for (int j = 0; j < recipe.mInputs.length; j++) { + ItemStack input = recipe.mInputs[j]; + if (GT_Utility.isStackValid(input) && !(input.getItem() instanceof GT_IntegratedCircuit_Item)) + fixedInputs.addAll(multiplyAndSplitIntoStacks(input, INPUT_MULTIPLIER)); + } + for (int j = 0; j < recipe.mFluidInputs.length; j++) { + FluidStack currFluid = recipe.mFluidInputs[j].copy(); + currFluid.amount = currFluid.amount * INPUT_MULTIPLIER; + fixedFluids.add(currFluid); + } + + int tier = info.getRight(); + int energy = (int) Math.min(Integer.MAX_VALUE - 7, (GT_Values.V[tier] - (GT_Values.V[tier] >> 4))); + + MyRecipeAdder.instance.addComponentAssemblyLineRecipe( + compactItems(fixedInputs, info.getRight()).toArray(new ItemStack[0]), + fixedFluids.toArray(new FluidStack[0]), + info.getLeft().get(OUTPUT_MULTIPLIER), + recipe.mDuration * INPUT_MULTIPLIER, + energy, + info.getRight()); + } + } + }); + } + /** Assembly Line Recipes (LuV+) **/ + private static void generateAsslineRecipes() { + allAsslineRecipes.forEach((recipeList, info) -> { + for (GT_Recipe.GT_Recipe_AssemblyLine recipe : recipeList) { + if (recipe != null) { + // Arrays of the item and fluid inputs, that are updated to be multiplied and/or condensed in the + // following code + ArrayList<ItemStack> fixedInputs = new ArrayList<>(); + ArrayList<FluidStack> fixedFluids = new ArrayList<>(); + + // This is done in order to differentiate between emitter and sensor recipes. Without the circuit, + // both components have virtually the same recipe after the inputs are melted. + if (info.getLeft().name().contains("Sensor")) { + fixedInputs.add(GT_Utility.getIntegratedCircuit(1)); + } + + // Multiplies the original fluid inputs + for (int j = 0; j < recipe.mFluidInputs.length; j++) { + FluidStack currFluid = recipe.mFluidInputs[j].copy(); + currFluid.amount *= INPUT_MULTIPLIER; + fixedFluids.add(currFluid); + } + + // First pass. + for (ItemStack input : recipe.mInputs) { + if (GT_Utility.isStackValid(input)) { + int count = input.stackSize; + // Mulitplies the input by its multiplier, and adjusts the stacks accordingly + if (!(input.getItem() instanceof GT_IntegratedCircuit_Item)) { + + ItemData data = GT_OreDictUnificator.getAssociation(input); + // trying to fix some circuit oredicting issues + + if (data != null && data.mPrefix == OrePrefixes.circuit) + fixedInputs.addAll(multiplyAndSplitIntoStacks( + GT_OreDictUnificator.get(data.mPrefix, data.mMaterial.mMaterial, count), + INPUT_MULTIPLIER)); + else fixedInputs.addAll(multiplyAndSplitIntoStacks(input, INPUT_MULTIPLIER)); + } + } + } + + fixedInputs = compactItems(fixedInputs, info.getRight()); + replaceIntoFluids(fixedInputs, fixedFluids, 128); + // If it overflows then it tries REALLY HARD to cram as much stuff into there. + if (fixedInputs.size() > 9) replaceIntoFluids(fixedInputs, fixedFluids, 32); + MyRecipeAdder.instance.addComponentAssemblyLineRecipe( + fixedInputs.toArray(new ItemStack[0]), + fixedFluids.toArray(new FluidStack[0]), + info.getLeft().get(OUTPUT_MULTIPLIER), + recipe.mDuration, + recipe.mEUt, + info.getRight()); + } + } + }); + } + /** + * Returns {@code true} if the {@code ItemStack} is able to be compacted + * into its respective gear/wire/etc. + * */ + private static boolean isCompactable(ItemStack toCompact) { + ItemData data = GT_OreDictUnificator.getAssociation(toCompact); + return data != null + && conversion.containsKey(data.mPrefix) + && conversion.get(data.mPrefix) != null + && GT_OreDictUnificator.get(conversion.get(data.mPrefix), data.mMaterial.mMaterial, 1) != null; + } + + private static void replaceIntoFluids(List<ItemStack> inputs, List<FluidStack> fluidOutputs, int threshold) { + HashMap<ItemStack, Integer> totals = getTotalItems(inputs.toArray(new ItemStack[0])); + ArrayList<ItemStack> newInputs = new ArrayList<>(); + for (ItemStack input : totals.keySet()) { + int count = totals.get(input); + boolean isConverted = false; + if (OreDictionary.getOreIDs(input).length > 0 && count > threshold) { + FluidStack foundFluidStack = tryConvertItemStackToFluidMaterial(input); + // Looks for a matching fluid stack and merges the amount of the converted fluid with + // the one it found. Otherwise it will add the converted to the fluid inputs. + + // Prevents the uncraftable molten magnetic samarium from being converted into fluid during auto + // generation + + ItemData data = GT_OreDictUnificator.getAssociation(input); + if (data != null && data.mMaterial.mMaterial == Materials.SamariumMagnetic) { + input = GT_OreDictUnificator.get(data.mPrefix, Materials.Samarium, 1); + foundFluidStack = tryConvertItemStackToFluidMaterial(input); + } + + if (foundFluidStack != null) { + foundFluidStack.amount *= count; + boolean alreadyHasFluid = false; + for (FluidStack fluidstack : fluidOutputs) { + if (foundFluidStack.getFluid().equals(fluidstack.getFluid())) { + fluidstack.amount += foundFluidStack.amount; + alreadyHasFluid = true; + break; + } + } + if (!alreadyHasFluid) { + fluidOutputs.add(foundFluidStack); + } + isConverted = true; + } + } + if (!isConverted) { + newInputs.addAll(multiplyAndSplitIntoStacks(input, count)); + } + } + inputs.clear(); + inputs.addAll(newInputs); + } + + /** Tries to convert {@code input} into its molten form. + * Because the internal names for material fluids in GT5u, GT++, and BartWorks follow the same naming scheme, + * this method should work for any {@code ItemStack} from any of the 3 material systems. + * */ + @Nullable + private static FluidStack tryConvertItemStackToFluidMaterial(ItemStack input) { + ArrayList<String> oreDicts = new ArrayList<>(); + for (int id : OreDictionary.getOreIDs(input)) { + oreDicts.add(OreDictionary.getOreName(id)); + } + oreDictLoop: + for (String dict : oreDicts) { + for (String blacklistedPrefix : blacklistedDictPrefixes) { + if (dict.startsWith(blacklistedPrefix)) { + return null; + } + } + for (String blacklistedPrefix : softBlacklistedDictPrefixes) { + if (dict.startsWith(blacklistedPrefix)) { + continue oreDictLoop; + } + } + OrePrefixes orePrefix; + try { + orePrefix = OrePrefixes.valueOf(findBestPrefix(dict)); + } catch (Exception e) { + continue; + } + + String strippedOreDict = dict.substring(orePrefix.toString().length()); + + // Prevents things like AnyCopper or AnyIron from messing the search up. + if (strippedOreDict.contains("Any")) continue; + return FluidRegistry.getFluidStack( + "molten." + strippedOreDict.toLowerCase(), + (int) (orePrefix.mMaterialAmount / (GT_Values.M / 144)) * input.stackSize); + } + return null; + } + /** + * Gives the longest Ore Prefix that the OreDictionary string starts with. This makes it the most accurate prefix. + * For example: If your OreDictionary is something like {@code gearGtSmallSpaceTime}, a conventional search would + * return something like {@code gearGt} instead of {@code gearGtSmall}. This makes the longer String the most accurate. + * @param oreDict The Ore Dictionary entry + * @return The longest ore prefix that the OreDict string starts with. This makes it the most accurate prefix. + */ + private static String findBestPrefix(String oreDict) { + int longestPrefixLength = 0; + String matchingPrefix = null; + for (OrePrefixes prefix : OrePrefixes.values()) { + String name = prefix.toString(); + if (oreDict.startsWith(name)) { |
