diff options
Diffstat (limited to 'src')
42 files changed, 1900 insertions, 3 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/ComponentAssemblyLine.java b/src/main/java/goodgenerator/blocks/tileEntity/ComponentAssemblyLine.java new file mode 100644 index 0000000000..1a9d1b245f --- /dev/null +++ b/src/main/java/goodgenerator/blocks/tileEntity/ComponentAssemblyLine.java @@ -0,0 +1,744 @@ +package goodgenerator.blocks.tileEntity; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.Textures.BlockIcons.*; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import goodgenerator.loader.Loaders; +import goodgenerator.util.MyRecipeAdder; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.tuple.Pair; + +public class ComponentAssemblyLine extends GT_MetaTileEntity_EnhancedMultiBlockBase<ComponentAssemblyLine> + implements ISurvivalConstructable { + + private int casingTier; + private final double log4 = Math.log(4); + private long EU_per_tick = 0; + protected static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<ComponentAssemblyLine> STRUCTURE_DEFINITION = + StructureDefinition.<ComponentAssemblyLine>builder() + .addShape(STRUCTURE_PIECE_MAIN, new String[][] { + { + " ", + " III ", + " HHI~IHH ", + "HH III HH", + "H H", + "H H", + "H JJJ H", + "H N N H", + "H N N H", + "HHHHHHHHH" + }, + { + " ", + " EHHHHHE ", + "E E", + "H H", + "A A", + "A A", + "A HHH A", + "A A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " BBB ", + " EL LE ", + "E GGDGG E", + "HGG D GGH", + "AG C GA", + "AG GA", + "AG GA", + "AG HHH GA", + "AG GA", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " BBB ", + " EL LE ", + "E GGDGG E", + "HGG D GGH", + "HG C GH", + "HG GH", + "HG GH", + "HG HHH GH", + "HG GH", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " BBB ", + " EL LE ", + "E GGDGG E", + "HGG D GGH", + "AG C GA", + "AG GA", + "AG GA", + "AG HHH GA", + "AG GA", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " BBB ", + " EL LE ", + "E GGDGG E", + "HGG D GGH", + "HG C GH", + "HG GH", + "HG GH", + "HG HHH GH", + "HG GH", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " BBB ", + " EL LE ", + "E GGDGG E", + "HGG D GGH", + "AG C GA", + "AG GA", + "AG GA", + "AG HHH GA", + "AG GA", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " BBB ", + " EL LE ", + "E GGDGG E", + "HGG D GGH", + "HG C GH", + "HG GH", + "HG GH", + "HG HHH GH", + "HG GH", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " BBB ", + " EL LE ", + "E GGDGG E", + "HGG D GGH", + "AG C GA", + "AG GA", + "AG GA", + "AG HHH GA", + "AG GA", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A N N A", + "MHHHHHHHM" + }, + { + " HBH ", + " EL LE ", + "E E", + "HC CH", + "AC CA", + "AC CA", + "A D D A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " ", + " EHHHHHE ", + "E E", + "H H", + "A A", + "A A", + "A A", + "A HHH A", + "A A", + "MHHHHHHHM" + }, + { + " ", + " ", + " HHHHHHH ", + "HH HH", + "H H", + "H H", + "H H", + "H H", + "H KKK H", + "HHHHHHHHH" + } + }) + .addElement( + 'A', + ofChain( + ofBlockUnlocalizedName("bartworks", "BW_GlasBlocks", 5), + ofBlockUnlocalizedName("bartworks", "BW_GlasBlocks", 13), + ofBlockUnlocalizedName("bartworks", "BW_GlasBlocks", 14), + ofBlockUnlocalizedName("bartworks", "BW_GlasBlocks", 15), + ofBlockUnlocalizedName("bartworks", "BW_GlasBlocks2", 0))) + .addElement('H', ofBlock(GregTech_API.sBlockCasings8, 7)) + .addElement('C', ofBlock(GregTech_API.sBlockCasings2, 5)) + .addElement('D', ofBlock(GregTech_API.sBlockCasings2, 9)) + .addElement('G', ofBlock(GregTech_API.sBlockCasings9, 0)) + .addElement('E', ofBlock(GregTech_API.sBlockCasings9, 1)) + .addElement('F', ofBlock(GregTech_API.sBlockCasings4, 1)) + .addElement( + 'B', + ofBlocksTiered( + (block, meta) -> block == Loaders.componentAssemblylineCasing ? meta : -1, + IntStream.range(0, 14) + .mapToObj(i -> Pair.of(Loaders.componentAssemblylineCasing, i)) + .collect(Collectors.toList()), + -1, + (t, meta) -> t.casingTier = meta, + t -> t.casingTier)) + .addElement( + 'J', + GT_StructureUtility.buildHatchAdder(ComponentAssemblyLine.class) + .atLeast(InputBus) + .dot(1) + .casingIndex(183) + .buildAndChain(GregTech_API.sBlockCasings8, 7)) + .addElement( + 'K', + GT_StructureUtility.buildHatchAdder(ComponentAssemblyLine.class) + .atLeast(OutputBus) + .dot(2) + .casingIndex(183) + .buildAndChain(GregTech_API.sBlockCasings8, 7)) + .addElement( + 'L', + GT_StructureUtility.buildHatchAdder(ComponentAssemblyLine.class) + .atLeast(Energy, ExoticEnergy) + .dot(3) + .casingIndex(183) + .buildAndChain(GregTech_API.sBlockCasings8, 7)) + .addElement( + 'I', + GT_StructureUtility.buildHatchAdder(ComponentAssemblyLine.class) + .atLeast(Maintenance) + .dot(4) + .casingIndex(183) + .buildAndChain(GregTech_API.sBlockCasings8, 7)) + .addElement( + 'M', + GT_StructureUtility.buildHatchAdder(ComponentAssemblyLine.class) + .atLeast(InputHatch) + .dot(5) + .casingIndex(183) + .buildAndChain(GregTech_API.sBlockCasings8, 7)) + .addElement('N', GT_StructureUtility.ofFrame(Materials.TungstenSteel)) + .build(); + + public ComponentAssemblyLine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public ComponentAssemblyLine(String aName) { + super(aName); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 4, 2, 0); + } + + @Override + public IStructureDefinition<ComponentAssemblyLine> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("High-Capacity Component Assembler") + .addInfo("Controller block for the Component Assembly Line.") + .addInfo("Assembles basic components (motors, pumps, etc.) in large batches.") + .addInfo("The " + EnumChatFormatting.BOLD + EnumChatFormatting.YELLOW + + "Special Component Assembly Line Casing" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY) + .addInfo("limits the recipes the machine can perform. See the NEI pages for details.") + .addInfo("Supports " + EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + + EnumChatFormatting.GRAY + " laser and multi-amp hatches!") + .addInfo("Supports overclocking beyond MAX!") + .addInfo(EnumChatFormatting.ITALIC + "Much more efficient than other competing brands!") + .beginStructureBlock(9, 10, 33, false) + .addStructureInfo("This structure is too complex! See schematic for details.") + .addOtherStructurePart("Borosilicate Glass", "Can be UV tier or higher") + .addInputBus("Start of conveyor belt", 1) + .addOutputBus("End of conveyor belt", 2) + .addEnergyHatch("Second-top layer", 3) + .addMaintenanceHatch("Around the controller", 4) + .addInputHatch("Bottom left and right corners", 5) + .toolTipFinisher(EnumChatFormatting.AQUA + "MadMan310" + EnumChatFormatting.GRAY + " via " + + EnumChatFormatting.GREEN + "Good Generator"); + + return tt; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new ComponentAssemblyLine(mName); + } + + /** + * Changes and adds new information to the default info data for the scanner. + * */ + @Override + public String[] getInfoData() { + long storedEnergy = 0; + long maxEnergy = 0; + + for (GT_MetaTileEntity_Hatch tHatch : mExoticEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + return new String[] { + "------------ Critical Information ------------", + StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(mProgresstime) + EnumChatFormatting.RESET + "t / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime) + EnumChatFormatting.RESET + "t", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + EnumChatFormatting.RED + + GT_Utility.formatNumbers(-EU_per_tick) + EnumChatFormatting.RESET + " EU/t", + StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers( + GT_ExoticEnergyInputHelper.getMaxInputVoltageMulti(getExoticAndNormalEnergyHatchList())) + + EnumChatFormatting.RESET + " EU/t(*" + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers( + GT_ExoticEnergyInputHelper.getMaxInputAmpsMulti(getExoticAndNormalEnergyHatchList())) + + EnumChatFormatting.RESET + "A) " + StatCollector.translateToLocal("GT5U.machines.tier") + + ": " + EnumChatFormatting.YELLOW + + VN[ + GT_Utility.getTier(GT_ExoticEnergyInputHelper.getMaxInputVoltageMulti( + getExoticAndNormalEnergyHatchList()))] + + EnumChatFormatting.RESET, + StatCollector.translateToLocal("scanner.info.CASS.tier") + + (casingTier >= 0 ? GT_Values.VN[casingTier + 1] : "None!") + }; + } + + @Override + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + if (aSide == aFacing) { + if (aActive) + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(183), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE_GLOW) + .extFacing() + .glow() + .build() + }; + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(183), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_PROCESSING_ARRAY) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_GLOW) + .extFacing() + .glow() + .build() + }; + } + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(183)}; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + long tVoltage = GT_ExoticEnergyInputHelper.getMaxInputVoltageMulti(getExoticAndNormalEnergyHatchList()); + long tAmps = GT_ExoticEnergyInputHelper.getMaxInputAmpsMulti(getExoticAndNormalEnergyHatchList()); + long totalEU = tVoltage * tAmps; + ItemStack[] tItems = getStoredInputs().toArray(new ItemStack[0]); + FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); + GT_Recipe foundRecipe = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, totalEU, tFluids, tItems); + if (foundRecipe == null) return false; + if (foundRecipe.mSpecialValue > casingTier + 1) return false; + if (!foundRecipe.isRecipeInputEqual(true, tFluids, tItems)) return false; + + // Logic for overclocking calculations. + double EU_input_tier = Math.log(totalEU) / log4; + double EU_recipe_tier = Math.log(foundRecipe.mEUt) / log4; + long overclock_count = (long) Math.floor(EU_input_tier - EU_recipe_tier); + + // Vital recipe info. Calculate overclocks here if necessary. + EU_per_tick = (long) -(foundRecipe.mEUt * Math.pow(4, overclock_count)); + + mMaxProgresstime = (int) (foundRecipe.mDuration / Math.pow(2, overclock_count)); + mMaxProgresstime = Math.max(1, mMaxProgresstime); + + mOutputItems = foundRecipe.mOutputs; + updateSlots(); + return true; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (EU_per_tick < 0) { + if (!drainEnergyInput(-EU_per_tick)) { + EU_per_tick = 0; + criticalStopMachine(); + return false; + } + } + return true; + } + + @Override + public boolean drainEnergyInput(long aEU) { + return GT_ExoticEnergyInputHelper.drainEnergy(aEU, getExoticAndNormalEnergyHatchList()); + } + + public List<GT_MetaTileEntity_Hatch> getExoticAndNormalEnergyHatchList() { + List<GT_MetaTileEntity_Hatch> tHatches = new ArrayList<>(); + tHatches.addAll(mExoticEnergyHatches); + tHatches.addAll(mEnergyHatches); + return tHatches; + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 4, 2, 0, realBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + casingTier = -1; + return checkPiece(STRUCTURE_PIECE_MAIN, 4, 2, 0); + } + + @Override + public void clearHatches() { + super.clearHatches(); + mExoticEnergyHatches.clear(); + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return MyRecipeAdder.instance.COMPASSLINE_RECIPES; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("casingTier", casingTier); + aNBT.setLong("euPerTick", EU_per_tick); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + casingTier = aNBT.getInteger("casingTier"); + EU_per_tick = aNBT.getLong("euPerTick"); + super.loadNBTData(aNBT); + } +} diff --git a/src/main/java/goodgenerator/crossmod/nei/ComponentAssemblyLineHandler.java b/src/main/java/goodgenerator/crossmod/nei/ComponentAssemblyLineHandler.java new file mode 100644 index 0000000000..d365434c3f --- /dev/null +++ b/src/main/java/goodgenerator/crossmod/nei/ComponentAssemblyLineHandler.java @@ -0,0 +1,38 @@ +package goodgenerator.crossmod.nei; + +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Recipe; +import gregtech.nei.GT_NEI_DefaultHandler; +import java.awt.*; + +public class ComponentAssemblyLineHandler extends GT_NEI_DefaultHandler { + public ComponentAssemblyLineHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) { + + super(aRecipeMap); + this.transferRects.remove(new RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); + this.transferRects.add(new RecipeTransferRect(new Rectangle(69, 18, 9, 34), getOverlayIdentifier())); + if (!NEI_Config.isAdded) { + FMLInterModComms.sendRuntimeMessage( + GT_Values.GT, + "NEIPlugins", + "register-crafting-handler", + "gregtech@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + @Override + public TemplateRecipeHandler newInstance() { + return new ComponentAssemblyLineHandler(this.mRecipeMap); + } + + @Override + protected String getSpecialInfo(int specialValue) { + return this.mRecipeMap.mNEISpecialValuePre + GT_Values.VN[specialValue]; + } +} diff --git a/src/main/java/goodgenerator/crossmod/nei/IMCForNEI.java b/src/main/java/goodgenerator/crossmod/nei/IMCForNEI.java index bcae911545..a4879e9ff6 100644 --- a/src/main/java/goodgenerator/crossmod/nei/IMCForNEI.java +++ b/src/main/java/goodgenerator/crossmod/nei/IMCForNEI.java @@ -33,9 +33,16 @@ public class IMCForNEI { } // sendCatalyst("gt.recipe.complexfusionreactor", "gregtech:gt.blockmachines:32023", -10); // Compact // Fusion MK-V + + sendHandler("goodgenerator.crossmod.nei.ComponentAssemblyLineHandler", "gregtech:gt.blockmachines:32026", 2); + sendCatalyst("gg.recipe.componentassemblyline", "gregtech:gt.blockmachines:32026"); } private static void sendHandler(String aName, String aBlock) { + sendHandler(aName, aBlock, 1); + } + + private static void sendHandler(String aName, String aBlock, int maxRecipesPerPage) { NBTTagCompound aNBT = new NBTTagCompound(); aNBT.setString("handler", aName); aNBT.setString("modName", "Good Generator"); @@ -44,7 +51,7 @@ public class IMCForNEI { aNBT.setString("itemName", aBlock); aNBT.setInteger("handlerHeight", 135); aNBT.setInteger("handlerWidth", 166); - aNBT.setInteger("maxRecipesPerPage", 1); + aNBT.setInteger("maxRecipesPerPage", maxRecipesPerPage); aNBT.setInteger("yShift", 6); FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT); } diff --git a/src/main/java/goodgenerator/crossmod/nei/NEI_Config.java b/src/main/java/goodgenerator/crossmod/nei/NEI_Config.java index b9a8d5cb52..70b31e51ad 100644 --- a/src/main/java/goodgenerator/crossmod/nei/NEI_Config.java +++ b/src/main/java/goodgenerator/crossmod/nei/NEI_Config.java @@ -17,6 +17,7 @@ public class NEI_Config implements IConfigureNEI { new NeutronActivatorHandler(MyRecipeAdder.instance.NA); new ExtremeHeatExchangerHandler(MyRecipeAdder.instance.XHE); new PreciseAssemblerHandler(MyRecipeAdder.instance.PA); + new ComponentAssemblyLineHandler(MyRecipeAdder.instance.COMPASSLINE_RECIPES); NEI_Config.isAdded = true; } 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)) { + if (name.length() > longestPrefixLength) { + longestPrefixLength = name.length(); + matchingPrefix = name; + } + } + } + return matchingPrefix; + } + /** + * Transforms each {@code ItemStack}, if possible, into a more compact form. + * For example, a stack of 16 1x cables, when passed into the {@code items} array, + * will be converted into a single 16x cable. Also handles GraviStar conversion. + * */ + private static ArrayList<ItemStack> compactItems(List<ItemStack> items, int tier) { + ArrayList<ItemStack> stacks = new ArrayList<>(); + HashMap<ItemStack, Integer> totals = getTotalItems(items); + for (ItemStack itemstack : totals.keySet()) { + int totalItems = totals.get(itemstack); + ItemData data = GT_OreDictUnificator.getAssociation(itemstack); + boolean isCompacted = false; + if (data != null) { + if (data.mPrefix == OrePrefixes.circuit) { + stacks.addAll(getWrappedCircuits(itemstack, totalItems)); + isCompacted = true; + } else { + OrePrefixes goInto = conversion.get(data.mPrefix); + if (goInto != null && GT_OreDictUnificator.get(goInto, data.mMaterial.mMaterial, 1) != null) { + compactorHelper(data, goInto, stacks, totalItems); + isCompacted = true; + } + } + } + if (GT_Utility.areStacksEqual(itemstack, ItemList.Gravistar.get(1)) && tier >= 9) { + stacks.addAll(multiplyAndSplitIntoStacks(ItemList.NuclearStar.get(1), totalItems / 16)); + isCompacted = true; + } + if (!isCompacted) stacks.addAll(multiplyAndSplitIntoStacks(itemstack, totalItems)); + } + stacks = mergeStacks(stacks); + return stacks; + } + /** A helper method for compacting items */ + private static void compactorHelper( + ItemData data, OrePrefixes compactInto, ArrayList<ItemStack> output, int total) { + int materialRatio = (int) ((double) compactInto.mMaterialAmount / data.mPrefix.mMaterialAmount); + output.addAll(multiplyAndSplitIntoStacks( + GT_OreDictUnificator.get(compactInto, data.mMaterial.mMaterial, 1), total / materialRatio)); + } + + /** + * Searches the Assembler and Assembly line registry for all the base component recipes. + */ + private static void findAllRecipes() { + allAssemblerRecipes = new LinkedHashMap<>(); + allAsslineRecipes = new LinkedHashMap<>(); + for (String compPrefix : compPrefixes) { + + for (int t = 1; t <= 12; t++) { + String vName = GT_Values.VN[t]; + ItemList currentComponent = ItemList.valueOf(compPrefix + vName); + if (currentComponent.hasBeenSet()) { + if (t < 6) { + allAssemblerRecipes.put( + GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.mRecipeList.stream() + .filter(rec -> rec.mOutputs[0].isItemEqual(currentComponent.get(1))) + .collect(Collectors.toList()), + Pair.of(currentComponent, t)); + } else { + allAsslineRecipes.put( + GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.stream() + .filter(rec -> rec.mOutput.isItemEqual(currentComponent.get(1))) + .collect(Collectors.toList()), + Pair.of(currentComponent, t)); + } + } + } + } + } + + private static List<ItemStack> getWrappedCircuits(ItemStack item, int total) { + ArrayList<ItemStack> stacks = new ArrayList<>(); + for (ItemStack i2 : ComponentAssemblyLineMiscRecipes.CircuitToTier.keySet()) { + int tier = ComponentAssemblyLineMiscRecipes.CircuitToTier.get(i2); + if (GT_Utility.areStacksEqual(item, i2)) { + if (total >= 16) + stacks.addAll(multiplyAndSplitIntoStacks(new ItemStack(Loaders.circuitWrap, 1, tier), total / 16)); + else stacks.addAll(multiplyAndSplitIntoStacks(item, total)); + break; + } + } + return stacks; + } +} diff --git a/src/main/java/goodgenerator/loader/Loaders.java b/src/main/java/goodgenerator/loader/Loaders.java index e2c6a92dbf..0251c6753b 100644 --- a/src/main/java/goodgenerator/loader/Loaders.java +++ b/src/main/java/goodgenerator/loader/Loaders.java @@ -109,9 +109,27 @@ public class Loaders { GoodGenerator.MOD_ID + ":ciruits/2", GoodGenerator.MOD_ID + ":ciruits/3", GoodGenerator.MOD_ID + ":ciruits/4", - GoodGenerator.MOD_ID + ":ciruits/5" + GoodGenerator.MOD_ID + ":ciruits/5", }); + public static final Item circuitWrap = new MyItems("circuitWrap", GoodGenerator.GG, new String[] { + GoodGenerator.MOD_ID + ":wraps/0", + GoodGenerator.MOD_ID + ":wraps/1", + GoodGenerator.MOD_ID + ":wraps/2", + GoodGenerator.MOD_ID + ":wraps/3", + GoodGenerator.MOD_ID + ":wraps/4", + GoodGenerator.MOD_ID + ":wraps/5", + GoodGenerator.MOD_ID + ":wraps/6", + GoodGenerator.MOD_ID + ":wraps/7", + GoodGenerator.MOD_ID + ":wraps/8", + GoodGenerator.MOD_ID + ":wraps/9", + GoodGenerator.MOD_ID + ":wraps/10", + GoodGenerator.MOD_ID + ":wraps/11", + GoodGenerator.MOD_ID + ":wraps/12", + GoodGenerator.MOD_ID + ":wraps/13", + GoodGenerator.MOD_ID + ":wraps/14" + }); + public static final Block MAR_Casing = new Casing("MAR_Casing", new String[] {GoodGenerator.MOD_ID + ":MAR_Casing"}); public static final Block FRF_Casings = @@ -179,7 +197,22 @@ public class Loaders { public static Block essentiaHatch; public static Block essentiaOutputHatch; public static Block essentiaOutputHatch_ME; - + public static final Block componentAssemblylineCasing = new Casing("componentAssemblyLineCasing", new String[] { + GoodGenerator.MOD_ID + ":compAsslineCasing/0", // LV + GoodGenerator.MOD_ID + ":compAsslineCasing/1", // MV + GoodGenerator.MOD_ID + ":compAsslineCasing/2", // HV + GoodGenerator.MOD_ID + ":compAsslineCasing/3", // EV + GoodGenerator.MOD_ID + ":compAsslineCasing/4", // IV + GoodGenerator.MOD_ID + ":compAsslineCasing/5", // LuV + GoodGenerator.MOD_ID + ":compAsslineCasing/6", // ZPM + GoodGenerator.MOD_ID + ":compAsslineCasing/7", // UV + GoodGenerator.MOD_ID + ":compAsslineCasing/8", // UHV + GoodGenerator.MOD_ID + ":compAsslineCasing/9", // UEV + GoodGenerator.MOD_ID + ":compAsslineCasing/10", // UIV + GoodGenerator.MOD_ID + ":compAsslineCasing/11", // UMV + GoodGenerator.MOD_ID + ":compAsslineCasing/12", // UXV + GoodGenerator.MOD_ID + ":compAsslineCasing/13" // MAX + }); public static ItemStack MAR; public static ItemStack FRF; public static ItemStack UCFE; @@ -198,6 +231,7 @@ public class Loaders { public static ItemStack[] NeutronAccelerators = new ItemStack[9]; public static ItemStack[] Generator_Diesel = new ItemStack[2]; + public static ItemStack CompAssline; // public static Item Isotope = new NuclearMetaItemGenerator(); public static void GTMetaTileRegister() { @@ -249,6 +283,9 @@ public class Loaders { 1114, "basicgenerator.diesel.tier.05", "Ultimate Chemical Energy Releaser", 5) .getStackForm(1L); Loaders.CT = new CoolantTower(IDOffset + 24, "CoolantTower", "Coolant Tower").getStackForm(1L); + Loaders.CompAssline = new ComponentAssemblyLine( + IDOffset + 25, "ComponentAssemblyLine", "Component Assembly Line") + .getStackForm(1L); CrackRecipeAdder.registerPipe(30995, MyMaterial.incoloy903, 15000, 8000, true); CrackRecipeAdder.registerWire(32749, MyMaterial.signalium, 12, 131072, 16, true); CrackRecipeAdder.registerWire(32737, MyMaterial.lumiium, 8, 524288, 64, true); @@ -273,6 +310,7 @@ public class Loaders { GameRegistry.registerBlock(yottaFluidTankCasing, MyItemBlocks.class, "yottaFluidTankCasing"); GameRegistry.registerBlock( supercriticalFluidTurbineCasing, MyItemBlocks.class, "supercriticalFluidTurbineCasing"); + GameRegistry.registerBlock(componentAssemblylineCasing, MyItemBlocks.class, "componentAssemblylineCasing"); GameRegistry.registerBlock(pressureResistantWalls, MyItemBlocks.class, "pressureResistantWalls"); GameRegistry.registerBlock(preciseUnitCasing, MyItemBlocks.class, "preciseUnitCasing"); GameRegistry.registerBlock(compactFusionCoil, MyItemBlocks.class, "compactFusionCoil"); @@ -307,6 +345,7 @@ public class Loaders { GameRegistry.registerItem(highEnergyMixture, "highEnergyMixture", GoodGenerator.MOD_ID); GameRegistry.registerItem(saltyRoot, "saltyRoot", GoodGenerator.MOD_ID); GameRegistry.registerItem(huiCircuit, "huiCircuit", GoodGenerator.MOD_ID); + GameRegistry.registerItem(circuitWrap, "circuitWrap", GoodGenerator.MOD_ID); } public static void compactMod() { @@ -385,6 +424,7 @@ public class Loaders { public static void completeLoad() { RecipeLoader_02.FinishLoadRecipe(); MaterialFix.addRecipeForMultiItems(); + ComponentAssemblyLineRecipeLoader.run(); } public static void initLoadRecipes() { 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)); + } +} diff --git a/src/main/resources/assets/goodgenerator/lang/en_US.lang b/src/main/resources/assets/goodgenerator/lang/en_US.lang index 7817a09428..be8210803d 100644 --- a/src/main/resources/assets/goodgenerator/lang/en_US.lang +++ b/src/main/resources/assets/goodgenerator/lang/en_US.lang @@ -41,6 +41,21 @@ compactFusionCoil.4.name=Compact Fusion Coil MK-II Finaltype essentiaFilterCasing.0.name=Essentia Filter Casing essentiaOutputHatch.0.name=Essentia Output Hatch essentiaOutputHatch_ME.0.name=Essentia Output Hatch (ME) +componentAssemblyLineCasing.0.name=Component Assembly Line Casing (LV) +componentAssemblyLineCasing.1.name=Component Assembly Line Casing (MV) +componentAssemblyLineCasing.2.name=Component Assembly Line Casing (HV) +componentAssemblyLineCasing.3.name=Component Assembly Line Casing (EV) +componentAssemblyLineCasing.4.name=Component Assembly Line Casing (IV) +componentAssemblyLineCasing.5.name=Component Assembly Line Casing (LuV) +componentAssemblyLineCasing.6.name=Component Assembly Line Casing (ZPM) +componentAssemblyLineCasing.7.name=Component Assembly Line Casing (UV) +componentAssemblyLineCasing.8.name=Component Assembly Line Casing (UHV) +componentAssemblyLineCasing.9.name=Component Assembly Line Casing (UEV) +componentAssemblyLineCasing.10.name=Component Assembly Line Casing (UIV) +componentAssemblyLineCasing.11.name=Component Assembly Line Casing (UMV) +componentAssemblyLineCasing.12.name=Component Assembly Line Casing (UXV) +componentAssemblyLineCasing.13.name=Component Assembly Line Casing (MAX) + #Items item.radiationProtectionPlate.name=Radiation Proof Plate @@ -121,6 +136,22 @@ item.huiCircuit.1.name=Hi-Computation Station MK-II item.huiCircuit.2.name=Hi-Computation Station MK-III item.huiCircuit.3.name=Hi-Computation Station MK-IV Prototype item.huiCircuit.4.name=Hi-Computation Station MK-V Finaltype +item.nuclearStar.name=Nuclear Star +item.circuitWrap.0.name=Wrap of ULV Circuits +item.circuitWrap.1.name=Wrap of LV Circuits +item.circuitWrap.2.name=Wrap of MV Circuits +item.circuitWrap.3.name=Wrap of HV Circuits +item.circuitWrap.4.name=Wrap of EV Circuits +item.circuitWrap.5.name=Wrap of IV Circuits +item.circuitWrap.6.name=Wrap of LuV Circuits +item.circuitWrap.7.name=Wrap of ZPM Circuits +item.circuitWrap.8.name=Wrap of UV Circuits +item.circuitWrap.9.name=Wrap of UHV Circuits +item.circuitWrap.10.name=Wrap of UEV Circuits +item.circuitWrap.11.name=Wrap of UIV Circuits +item.circuitWrap.12.name=Wrap of UMV Circuits +item.circuitWrap.13.name=Wrap of UXV Circuits +item.circuitWrap.14.name=Wrap of MAX Circuits #Crops crops.saltroot=Salty Root @@ -255,6 +286,7 @@ scanner.info.YOTTank.2=Current Used: scanner.info.XHE.0=Steam Output is equal to scanner.info.XHE.1=Overheated Threshold: scanner.info.UX.0=Running Parallel +scanner.info.CASS.tier=Casing Tier: #GUI Info gui.NeutronSensor.0=Input the value of Neutron Kinetic Energy. diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/0.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/0.png Binary files differnew file mode 100644 index 0000000000..24ca2d49cd --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/0.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/1.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/1.png Binary files differnew file mode 100644 index 0000000000..a7422006a5 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/1.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/10.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/10.png Binary files differnew file mode 100644 index 0000000000..f87e748701 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/10.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/11.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/11.png Binary files differnew file mode 100644 index 0000000000..a1f0aab3e4 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/11.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/12.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/12.png Binary files differnew file mode 100644 index 0000000000..94a3241f19 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/12.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/13.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/13.png Binary files differnew file mode 100644 index 0000000000..74a9f9b0d9 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/13.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/2.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/2.png Binary files differnew file mode 100644 index 0000000000..d7ba583b6d --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/2.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/3.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/3.png Binary files differnew file mode 100644 index 0000000000..cd2f9870df --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/3.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/4.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/4.png Binary files differnew file mode 100644 index 0000000000..ec6c14210f --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/4.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/5.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/5.png Binary files differnew file mode 100644 index 0000000000..6f26a6ad1b --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/5.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/6.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/6.png Binary files differnew file mode 100644 index 0000000000..a1d7057330 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/6.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/7.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/7.png Binary files differnew file mode 100644 index 0000000000..913bcc4e83 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/7.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/8.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/8.png Binary files differnew file mode 100644 index 0000000000..3154df6ade --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/8.png diff --git a/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/9.png b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/9.png Binary files differnew file mode 100644 index 0000000000..6f933cc98e --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/blocks/compAsslineCasing/9.png diff --git a/src/main/resources/assets/goodgenerator/textures/gui/ComponentAssline.png b/src/main/resources/assets/goodgenerator/textures/gui/ComponentAssline.png Binary files differnew file mode 100644 index 0000000000..27bc15e8ee --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/gui/ComponentAssline.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/0.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/0.png Binary files differnew file mode 100644 index 0000000000..3e9501abc1 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/0.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/1.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/1.png Binary files differnew file mode 100644 index 0000000000..fe258942ae --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/1.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/10.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/10.png Binary files differnew file mode 100644 index 0000000000..a10d3af767 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/10.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/11.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/11.png Binary files differnew file mode 100644 index 0000000000..9757a1047e --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/11.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/12.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/12.png Binary files differnew file mode 100644 index 0000000000..aac60e58fd --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/12.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/13.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/13.png Binary files differnew file mode 100644 index 0000000000..893e7f3017 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/13.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/14.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/14.png Binary files differnew file mode 100644 index 0000000000..1be71e3d71 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/14.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/2.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/2.png Binary files differnew file mode 100644 index 0000000000..c328d738a1 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/2.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/3.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/3.png Binary files differnew file mode 100644 index 0000000000..32411af565 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/3.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/4.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/4.png Binary files differnew file mode 100644 index 0000000000..840b2c8b27 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/4.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/5.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/5.png Binary files differnew file mode 100644 index 0000000000..052e61d09e --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/5.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/6.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/6.png Binary files differnew file mode 100644 index 0000000000..8a37a18715 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/6.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/7.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/7.png Binary files differnew file mode 100644 index 0000000000..8aeba93ef9 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/7.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/8.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/8.png Binary files differnew file mode 100644 index 0000000000..b3850aae70 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/8.png diff --git a/src/main/resources/assets/goodgenerator/textures/items/wraps/9.png b/src/main/resources/assets/goodgenerator/textures/items/wraps/9.png Binary files differnew file mode 100644 index 0000000000..bd18dcbeda --- /dev/null +++ b/src/main/resources/assets/goodgenerator/textures/items/wraps/9.png |