From 1bf9655308ffca6ad00edcce03e37cc47dc31d69 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 30 Jul 2019 02:34:08 +0200 Subject: 0.5pre Circuits Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: aeccff4e60af64a4f1a140019ca3989bd3de87c6 --- .../github/bartimaeusnek/bartworks/MainMod.java | 4 + .../bartworks/common/items/SimpleIconItem.java | 1 + .../common/loaders/CircuitImprintLoader.java | 43 ------- .../CircuitGeneration/BW_CircuitsLoader.java | 48 +++++++ .../material/CircuitGeneration/BW_Meta_Items.java | 109 ++++++++++++++++ .../material/CircuitGeneration/CircuitData.java | 79 ++++++++++++ .../CircuitGeneration/CircuitImprintLoader.java | 118 +++++++++++++++++ .../CircuitGeneration/CircuitPartLoader.java | 30 +++++ .../bartworks/system/material/Werkstoff.java | 24 +++- .../bartworks/system/material/WerkstoffLoader.java | 51 +++++++- .../processingLoaders/AdditionalRecipes.java | 12 +- .../bartimaeusnek/bartworks/util/BWRecipes.java | 142 +++++++++++---------- .../bartimaeusnek/bartworks/util/BW_Util.java | 18 +++ 13 files changed, 557 insertions(+), 122 deletions(-) delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/CircuitImprintLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java (limited to 'src') diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 297abb2ca2..aa5d3f63f4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -34,6 +34,8 @@ import com.github.bartimaeusnek.bartworks.common.loaders.*; import com.github.bartimaeusnek.bartworks.common.net.BW_Network; import com.github.bartimaeusnek.bartworks.server.EventHandler.ServerEventHandler; import com.github.bartimaeusnek.bartworks.system.log.DebugLog; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitPartLoader; import com.github.bartimaeusnek.bartworks.system.material.ThreadedLoader; import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; @@ -48,6 +50,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartedEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; +import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.SubTag; @@ -120,6 +123,7 @@ public final class MainMod { if (ConfigHandler.newStuff) { WerkstoffLoader.INSTANCE.init(); Werkstoff.init(); + GregTech_API.sAfterGTPostload.add(new CircuitPartLoader()); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java index 1ca3c8fe2f..ab19b5d967 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java @@ -38,5 +38,6 @@ public class SimpleIconItem extends Item { @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon("bartworks:" + this.tex); + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/CircuitImprintLoader.java deleted file mode 100644 index 1027e8b344..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/CircuitImprintLoader.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2019 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.common.loaders; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.oredict.OreDictionary; - -import java.util.HashSet; - -public class CircuitImprintLoader implements Runnable { - - private static final HashSet circuitTypes = new HashSet<>(); - - @Override - public void run() { - for(String names : OreDictionary.getOreNames()){ - if (names.contains("circuit") || names.contains("Circuit")) - for (ItemStack itemStack : OreDictionary.getOres(names)) - CircuitImprintLoader.circuitTypes.add(itemStack.copy().splitStack(1).writeToNBT(new NBTTagCompound())); - } - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java new file mode 100644 index 0000000000..5bd182c6c0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import gregtech.api.GregTech_API; + +public class BW_CircuitsLoader { + private static final BW_Meta_Items NEW_CIRCUITS; + + public static BW_Meta_Items getNewCircuits() { + return BW_CircuitsLoader.NEW_CIRCUITS; + } + + static { + NEW_CIRCUITS = new BW_Meta_Items(); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(0,1, "Primitive Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(1,2, "Basic Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(2,3, "Good Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(3,4, "Advanced Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(4,5, "Data Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(5,6, "Elite Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(6,7, "Master Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(7,8, "Ultimate Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(8,9, "Superconductor Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(9,10, "Infinite Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(10,11, "Bio Magneto Resonatic Circuit"); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java new file mode 100644 index 0000000000..c8e1ba1335 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictAdder; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.Pair; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.items.GT_MetaGenerated_Item; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + + +public class BW_Meta_Items { + + public static BW_Meta_Items.BW_GT_MetaGenCircuits getNEWCIRCUITS() { + return BW_Meta_Items.NEWCIRCUITS; + } + + private static final BW_Meta_Items.BW_GT_MetaGenCircuits NEWCIRCUITS = new BW_Meta_Items.BW_GT_MetaGenCircuits(); + + + public void addNewCircuit(int aTier, int aID, String aName){ + + String additionalOreDictData = ""; + String tooltip = ""; + String aOreDictPrefix = OrePrefixes.circuit.toString(); + switch (aTier){ + case 0: additionalOreDictData = Materials.Primitive.toString(); tooltip = Materials.Primitive.getToolTip(); break; + case 1: additionalOreDictData = Materials.Basic.toString(); tooltip = Materials.Basic.getToolTip(); break; + case 2: additionalOreDictData = Materials.Good.toString(); tooltip = Materials.Good.getToolTip(); break; + case 3: additionalOreDictData = Materials.Advanced.toString(); tooltip = Materials.Advanced.getToolTip(); break; + case 4: additionalOreDictData = Materials.Data.toString(); tooltip = Materials.Data.getToolTip(); break; + case 5: additionalOreDictData = Materials.Elite.toString(); tooltip = Materials.Elite.getToolTip(); break; + case 6: additionalOreDictData = Materials.Master.toString(); tooltip = Materials.Master.getToolTip(); break; + case 7: additionalOreDictData = Materials.Ultimate.toString(); tooltip = Materials.Ultimate.getToolTip(); break; + case 8: additionalOreDictData = Materials.Superconductor.toString(); tooltip = Materials.Superconductor.getToolTip(); break; + case 9: additionalOreDictData = "Infinite"; tooltip = "An Infinite Circuit"; break; + case 10: additionalOreDictData = "Bio"; tooltip = "A Bio Circuit"; break; + } + + ItemStack tStack = BW_Meta_Items.NEWCIRCUITS.addCircuit(aID,aName,tooltip,aTier); + + if (ConfigHandler.experimentalThreadedLoader) + OreDictAdder.addToMap(new Pair<>((aOreDictPrefix + additionalOreDictData).replaceAll(" ",""), tStack)); + else + GT_OreDictUnificator.registerOre((aOreDictPrefix + additionalOreDictData).replaceAll(" ",""), tStack); + } + + public static class BW_GT_MetaGenCircuits extends BW_Meta_Items.BW_GT_MetaGen_Item_Hook{ + + + public BW_GT_MetaGenCircuits() { + super("bwMetaGeneratedItem0", (short) 0, (short) 32766); + } + + public final ItemStack addCircuit(int aID, String aEnglish, String aToolTip, int tier){ + CircuitImprintLoader.bwCircuitTagMap.put(new CircuitData(BW_Util.getMachineVoltageFromTier(tier-2),0,(byte)tier), CircuitImprintLoader.getTagFromStack(new ItemStack(BW_Meta_Items.NEWCIRCUITS,1,aID))); + return this.addItem(aID, aEnglish, aToolTip,SubTag.NO_UNIFICATION); + } + + public final void modifyIIconIndex(int aID, IIcon icon){ + this.mIconList[aID][0] = icon; + } + + public final ItemStack getStack(int... meta_amount){ + ItemStack ret = new ItemStack(this); + if (meta_amount.length <= 0 || meta_amount.length > 2) + return ret; + if (meta_amount.length == 1) { + ret.setItemDamage(meta_amount[0]); + return ret; + } + ret.setItemDamage(meta_amount[0]); + ret.stackSize=meta_amount[1]; + return ret; + } + } + + private static class BW_GT_MetaGen_Item_Hook extends GT_MetaGenerated_Item{ + private BW_GT_MetaGen_Item_Hook(String aUnlocalized, short aOffset, short aItemAmount) { + super(aUnlocalized, aOffset, aItemAmount); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java new file mode 100644 index 0000000000..2dfb4ad7c0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; + +import java.nio.ByteBuffer; + +public class CircuitData { + + private long aVoltage; + private int aSpecial; + private byte aTier; + + public CircuitData(long aVoltage, int aSpecial, byte aTier) { + this.aVoltage = aVoltage; + this.aSpecial = aSpecial; + this.aTier = aTier; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CircuitData)) return false; + CircuitData that = (CircuitData) o; + if (this.getaVoltage() != that.getaVoltage()) return false; + if (this.getaSpecial() != that.getaSpecial()) return false; + return this.getaTier() == that.getaTier(); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(13).put(this.aTier).putInt(this.aSpecial).putLong(this.aVoltage).array(),0,13,31); + } + + public long getaVoltage() { + return this.aVoltage; + } + + public void setaVoltage(long aVoltage) { + this.aVoltage = aVoltage; + } + + public int getaSpecial() { + return this.aSpecial; + } + + public void setaSpecial(int aSpecial) { + this.aSpecial = aSpecial; + } + + public byte getaTier() { + return this.aTier; + } + + public void setaTier(byte aTier) { + this.aTier = aTier; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java new file mode 100644 index 0000000000..d3af29e6b7 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.HashBiMap; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.items.GT_MetaGenerated_Item; +import gregtech.api.items.GT_MetaGenerated_Item_X32; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.*; + +public class CircuitImprintLoader implements Runnable { + + static final ArrayListMultimap recipeTagMap = ArrayListMultimap.create(); + static final HashBiMap bwCircuitTagMap = HashBiMap.create(20); + static final HashSet refs = new HashSet<>(); + private static short reverseIDs = 32766; + + public static NBTTagCompound getTagFromStack(ItemStack stack){ + if (GT_Utility.isStackValid(stack)) + return stack.copy().splitStack(1).writeToNBT(new NBTTagCompound()); + return new NBTTagCompound(); + } + + public static ItemStack getStackFromTag(NBTTagCompound tagCompound){ + return ItemStack.loadItemStackFromNBT(tagCompound); + } + + public static void makeCircuitParts() { + ItemList[] itemLists = ItemList.values(); + for (ItemList single : itemLists) { + if (!single.hasBeenSet()) + continue; + ItemStack itemStack = single.get(1); + if (!GT_Utility.isStackValid(itemStack)) + continue; + int[] oreIDS = OreDictionary.getOreIDs(itemStack); + if (oreIDS.length > 1) + continue; + String name = null; + if (oreIDS.length == 1) + name = OreDictionary.getOreName(oreIDS[0]); + if ((name == null || name.isEmpty()) && (single.toString().contains("Circuit") || single.toString().contains("circuit")) && single.getBlock() == Blocks.air) { + ArrayList toolTip = new ArrayList<>(); + single.getItem().addInformation(single.get(1).copy(), null, toolTip, true); + String localised = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack)); + BW_Meta_Items.getNEWCIRCUITS().addItem(CircuitImprintLoader.reverseIDs, "Wrap of " + localised, toolTip.size() > 0 ? toolTip.get(0) : ""); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{single.get(16).copy()},Materials.Plastic.getMolten(576),BW_Meta_Items.getNEWCIRCUITS().getStack(CircuitImprintLoader.reverseIDs),600,30); + CircuitImprintLoader.reverseIDs--; + } + } + } + + @Override + public void run() { + Iterator it = GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.iterator(); + GT_Recipe circuitRecipe; + HashSet torem = new HashSet<>(); + while (it.hasNext()) { + circuitRecipe = it.next(); + ItemStack[] outputs = circuitRecipe.mOutputs; + if (outputs.length < 1) + continue; + int[] oreIDS = OreDictionary.getOreIDs(outputs[0]); + if (oreIDS.length < 1) + continue; + String name = OreDictionary.getOreName(oreIDS[0]); + if (name.contains("Circuit") || name.contains("circuit")) { + CircuitImprintLoader.recipeTagMap.put(CircuitImprintLoader.getTagFromStack(outputs[0]),circuitRecipe.copy()); + for (ItemStack s : circuitRecipe.mInputs){ + if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0))) + CircuitImprintLoader.refs.add(CircuitImprintLoader.getTagFromStack(s.copy().splitStack(1))); + } +// if (circuitRecipe.mEUt > BW_Util.getTierVoltage(5)) + if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0))) { + torem.add(circuitRecipe); + BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).addRecipe(circuitRecipe); + } + } + } + GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.removeAll(torem); + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java new file mode 100644 index 0000000000..24f581d208 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +public class CircuitPartLoader implements Runnable { + @Override + public void run() { + CircuitImprintLoader.makeCircuitParts(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index ccc1335e6c..24af0547a7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -108,11 +108,27 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.toolTip = ""; if (toolTip.isEmpty()) { for (Pair p : contents) { - if (p.getKey() instanceof Materials) { - this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + if (contents.length > 1) { + if (p.getKey() instanceof Materials) { + if (((Materials) p.getKey()).mMaterialList.size() > 1 && p.getValue() > 1) +// if (((Materials) p.getKey()).mChemicalFormula != null && Character.isDigit(((Materials) p.getKey()).mChemicalFormula.toCharArray()[((Materials) p.getKey()).mChemicalFormula.length()-1])) + this.toolTip += "(" + ((Materials) p.getKey()).mChemicalFormula + ")" + (BW_Util.subscriptNumber(p.getValue())); + else + this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } + if (p.getKey() instanceof Werkstoff) { + if (((Werkstoff) p.getKey()).contents.size() > 1 && p.getValue() > 1) +// if (((Werkstoff) p.getKey()).toolTip != null && Character.isDigit(((Werkstoff) p.getKey()).toolTip.toCharArray()[((Werkstoff) p.getKey()).toolTip.length()-1])) + this.toolTip += "(" + ((Werkstoff) p.getKey()).toolTip + ")" + (BW_Util.subscriptNumber(p.getValue())); + else + this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } + } else { + if (p.getKey() instanceof Materials) { + this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } else if (p.getKey() instanceof Werkstoff) + this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } - if (p.getKey() instanceof Werkstoff) - this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } } else this.toolTip = toolTip; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java index 99dce114b2..8c9164538a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -28,6 +28,7 @@ import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.system.log.DebugLog; import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.AdditionalRecipes; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_CircuitsLoader; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictAdder; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; @@ -103,10 +104,10 @@ public class WerkstoffLoader implements Runnable { Werkstoff.Types.ELEMENT, new Werkstoff.GenerationFeatures().onlyDust(), 3, - TextureSet.SET_METALLIC, - Arrays.asList() + TextureSet.SET_METALLIC + //No Byproducts ); - public static final Werkstoff Zirconia = new Werkstoff( + public static final Werkstoff CubicZirconia = new Werkstoff( new short[]{255, 255, 255, 0}, "Cubic Zirconia", Werkstoff.Types.COMPOUND, @@ -462,6 +463,7 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().disable().onlyDust(), 30, TextureSet.SET_METALLIC + //No Byproducts ); public static final Werkstoff BismuthTellurite = new Werkstoff( new short[]{32,72,32,0}, @@ -471,6 +473,7 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().disable().onlyDust().addChemicalRecipes(), 31, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.Bismuth, 2), new Pair<>(Materials.Tellurium, 3) ); @@ -479,9 +482,10 @@ public class WerkstoffLoader implements Runnable { "Tellurium", new Werkstoff.Stats(), Werkstoff.Types.ELEMENT, - new Werkstoff.GenerationFeatures().disable().addMetalItems(), + new Werkstoff.GenerationFeatures().addMetalItems().removeOres(), 32, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.Tellurium, 1) ); public static final Werkstoff BismuthHydroBorat = new Werkstoff( @@ -492,23 +496,54 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().disable().onlyDust().addChemicalRecipes(), 33, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.Bismuth, 2), new Pair<>(Materials.Boron, 1), new Pair<>(Materials.Hydrogen, 1) ); public static final Werkstoff ArInGaPhoBiBoTe = new Werkstoff( new short[]{36,36,36,0}, - "Circuit Compound MK1", + "Circuit Compound MK3", new Werkstoff.Stats().setCentrifuge(true), Werkstoff.Types.COMPOUND, new Werkstoff.GenerationFeatures().disable().onlyDust().addMixerRecipes(), 34, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.IndiumGalliumPhosphide, 1), new Pair<>(WerkstoffLoader.BismuthHydroBorat, 3), new Pair<>(WerkstoffLoader.BismuthTellurite, 2) ); + public static final Werkstoff Prasiolite = new Werkstoff( + new short[]{0xD0,0xDD,0x95,0}, + "Prasiolite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 35, + TextureSet.SET_QUARTZ, + //No Byproducts + new Pair<>(Materials.Silicon,5), + new Pair<>(Materials.Oxygen,10), + new Pair<>(Materials.Iron,1) + ); + + public static final Werkstoff MagnetoResonaticDust = new Werkstoff( + new short[]{0xDD,0x77,0xDD,0}, + "Magneto Resonatic Dust", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust().addMixerRecipes(), + 36, + TextureSet.SET_MAGNETIC, + //No Byproducts + new Pair<>(WerkstoffLoader.Prasiolite,3), + new Pair<>(WerkstoffLoader.BismuthTellurite,4), + new Pair<>(WerkstoffLoader.CubicZirconia,1), + new Pair<>(Materials.SteelMagnetic,1) + ); + public static HashMap items = new HashMap<>(); public static Block BWOres; public boolean registered; @@ -571,6 +606,8 @@ public class WerkstoffLoader implements Runnable { DebugLog.log("Loading Aspects"+" " +(System.nanoTime()-timepreone)); ThaumcraftHandler.AspectAdder.addAspectToAll(werkstoff); } + DebugLog.log("Loading New Circuits"+" " +(System.nanoTime()-timepreone)); + new BW_CircuitsLoader(); DebugLog.log("Done"+" " +(System.nanoTime()-timepreone)); progressBar.step(werkstoff.getDefaultName()); } @@ -690,7 +727,7 @@ public class WerkstoffLoader implements Runnable { OreDictAdder.addToMap(new Pair<>("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), werkstoff.get(lens))); } - OreDictAdder.addToMap(new Pair<>("craftingIndustrialDiamond", WerkstoffLoader.Zirconia.get(gemExquisite))); + OreDictAdder.addToMap(new Pair<>("craftingIndustrialDiamond", WerkstoffLoader.CubicZirconia.get(gemExquisite))); } else { for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { if (werkstoff.getGenerationFeatures().hasOres()) @@ -699,7 +736,7 @@ public class WerkstoffLoader implements Runnable { OreDictionary.registerOre("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), werkstoff.get(lens)); } - GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.Zirconia.get(gemExquisite)); + GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.CubicZirconia.get(gemExquisite)); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java index 0c8327ad69..155283bfb0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java @@ -28,6 +28,7 @@ import com.github.bartimaeusnek.bartworks.util.BW_Util; 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_Recipe; import gregtech.api.util.GT_Utility; @@ -40,9 +41,6 @@ public class AdditionalRecipes implements Runnable { @Override public void run() { - //Cubic Circonia - GT_Values.RA.addChemicalRecipe(Materials.Yttrium.getDust(2), GT_Utility.getIntegratedCircuit(11),Materials.Oxygen.getGas(3000),null, WerkstoffLoader.YttriumOxide.get(dust,5),64, BW_Util.getMachineVoltageFromTier(4)); - GT_Recipe.GT_Recipe_Map.sBlastRecipes.addRecipe(false, new ItemStack[]{WerkstoffLoader.Zirconium.get(dust,10), WerkstoffLoader.YttriumOxide.get(dust)}, new ItemStack[]{WerkstoffLoader.YttriumOxide.get(dust), WerkstoffLoader.Zirconia.get(gemFlawed, 40)}, null, null, new FluidStack[]{Materials.Oxygen.getGas(20000)}, null, 14400, BW_Util.getMachineVoltageFromTier(4), 2953); //Thorium/Yttrium Glas GT_Values.RA.addBlastRecipe(WerkstoffLoader.YttriumOxide.get(dustSmall,2),WerkstoffLoader.Thorianit.get(dustSmall,2),Materials.Glass.getMolten(144),null,new ItemStack(ItemRegistry.bw_glasses[0],1,12),null,800,BW_Util.getMachineVoltageFromTier(5),3663); //Thorianit recipes @@ -61,6 +59,14 @@ public class AdditionalRecipes implements Runnable { GT_Values.RA.addChemicalRecipe(WerkstoffLoader.Thorianit.get(dust),Materials.Aluminium.getDust(1),Materials.Thorium.getDust(1),1000); GT_Values.RA.addChemicalRecipe(WerkstoffLoader.Thorianit.get(dust),Materials.Magnesium.getDust(1),Materials.Thorium.getDust(1),1000); GT_Values.RA.addChemicalRecipe(WerkstoffLoader.Thorianit.get(crushed), ItemList.Crop_Drop_Thorium.get(9),Materials.Water.getFluid(1000),Materials.Thorium.getMolten(144),WerkstoffLoader.Thorianit.get(crushedPurified,4),96,24); + + //TODO: Gem & Circuit Stuff + //Prasiolite + GT_Values.RA.addBlastRecipe(GT_OreDictUnificator.get(dust,Materials.Quartzite,40L),Materials.Amethyst.getDust(10),GT_Values.NF,GT_Values.NF,WerkstoffLoader.Prasiolite.get(OrePrefixes.gemFlawed,20),GT_Values.NI,800, BW_Util.getMachineVoltageFromTier(2),500); + GT_Values.RA.addPrimitiveBlastRecipe(GT_OreDictUnificator.get(dust,Materials.Quartzite,40L),Materials.Amethyst.getDust(10),6,WerkstoffLoader.Prasiolite.get(OrePrefixes.gemFlawed,20),GT_Values.NI,800); + //Cubic Circonia + GT_Values.RA.addChemicalRecipe(Materials.Yttrium.getDust(2), GT_Utility.getIntegratedCircuit(11),Materials.Oxygen.getGas(3000),null, WerkstoffLoader.YttriumOxide.get(dust,5),64, BW_Util.getMachineVoltageFromTier(4)); + GT_Recipe.GT_Recipe_Map.sBlastRecipes.addRecipe(false, new ItemStack[]{WerkstoffLoader.Zirconium.get(dust,10), WerkstoffLoader.YttriumOxide.get(dust)}, new ItemStack[]{WerkstoffLoader.YttriumOxide.get(dust), WerkstoffLoader.CubicZirconia.get(gemFlawed, 40)}, null, null, new FluidStack[]{Materials.Oxygen.getGas(20000)}, null, 14400, BW_Util.getMachineVoltageFromTier(4), 2953); //Tellurium GT_Values.RA.addBlastRecipe(GT_OreDictUnificator.get(crushed,Materials.Lead,10L),GT_Utility.getIntegratedCircuit(17),GT_Values.NF,GT_Values.NF,Materials.Lead.getIngots(10),Materials.Tellurium.getNuggets(20),800,BW_Util.getMachineVoltageFromTier(2),722); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index c380f3399b..e6c83a7f76 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -60,6 +60,8 @@ public class BWRecipes { public static final byte BIOLABBYTE = 0; public static final byte BACTERIALVATBYTE = 1; public static final byte ACIDGENMAPBYTE = 2; + public static final byte CIRCUITASSEMBLYLINE = 3; + private final GT_Recipe.GT_Recipe_Map sBiolab = new GT_Recipe.GT_Recipe_Map( new HashSet(150), "bw.recipe.biolab", @@ -87,6 +89,15 @@ public class BWRecipes { 1, 1, 1, 1, 1, "EU generated: ", 1000, "", false, true ); + private final BWRecipes.SpecialObjectSensitiveMap sCircuitAssemblyLineMap = new SpecialObjectSensitiveMap( + new HashSet(60), + "bw.recipe.cal", + "Circuit Assembly Line", + null, + "gregtech:textures/gui/basicmachines/Default", + 6, 6, 1, 1, 1, + "", 1, "", true, true //special handler + ); public BWRecipes() { @@ -261,7 +272,7 @@ public class BWRecipes { ); //aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue sBiolab.addRecipe( - new BioLabRecipe( + new DynamicGTRecipe( false, new ItemStack[]{ BioItemList.getPetriDish(null), @@ -304,8 +315,7 @@ public class BWRecipes { /** - * @param machine 0 = biolab; 1 = BacterialVat; 2 = sAcidGenFuels - * @return + * @param machine 0 = biolab; 1 = BacterialVat; 2 = sAcidGenFuels; 3 = circuitAssemblyLine */ public GT_Recipe.GT_Recipe_Map getMappingsFor(byte machine) { switch (machine) { @@ -315,6 +325,8 @@ public class BWRecipes { return sBacteriaVat; case 2: return sAcidGenFuels; + case 3: + return sCircuitAssemblyLineMap; default: return null; } @@ -322,54 +334,54 @@ public class BWRecipes { } public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, aInputs, new ItemStack[]{aOutput}, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, new ItemStack[]{BioItemList.getPetriDish(null), aInput}, new ItemStack[]{BioItemList.getPetriDish(aOutput)}, null, aChances, aFluidInputs, new FluidStack[]{GT_Values.NF}, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, new ItemStack[]{BioItemList.getPetriDish(null), aInput}, new ItemStack[]{BioItemList.getPetriDish(aOutput)}, null, aChances, aFluidInputs, new FluidStack[]{GT_Values.NF}, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, new ItemStack[]{BioItemList.getPetriDish(null), aInput}, new ItemStack[]{BioItemList.getPetriDish(aOutput)}, null, aChances, new FluidStack[]{aFluidInputs}, new FluidStack[]{GT_Values.NF}, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, new ItemStack[]{BioItemList.getPetriDish(null), aInput}, new ItemStack[]{BioItemList.getPetriDish(aOutput)}, null, aChances, new FluidStack[]{aFluidInputs}, new FluidStack[]{GT_Values.NF}, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } @Deprecated public boolean addBioLabRecipeDNAExtraction(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[0], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[0], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } @Deprecated public boolean addBioLabRecipePCRThermoclycling(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[1], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[1], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } @Deprecated public boolean addBioLabRecipePlasmidSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[2], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[2], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } @Deprecated public boolean addBioLabRecipeTransformation(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[3], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[3], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } @Deprecated public boolean addBioLabRecipeClonalCellularSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[4], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[4], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } @@ -515,14 +527,65 @@ public class BWRecipes { } } - public static class BacteriaVatRecipeMap extends GT_Recipe.GT_Recipe_Map { + public static class BacteriaVatRecipeMap extends BWRecipes.SpecialObjectSensitiveMap { public BacteriaVatRecipeMap(Collection 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); } + protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { + aRecipe.mHidden = aHidden; + aRecipe.mFakeRecipe = aFakeRecipe; + GT_Recipe isthere = this.findRecipe((IHasWorldObjectAndCoords) null, false, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs); + + if (aRecipe.mFluidInputs.length < this.mMinimalInputFluids && aRecipe.mInputs.length < this.mMinimalInputItems) { + return null; + } else { + return aCheckForCollisions && isthere != null && BW_Util.areStacksEqualOrNull((ItemStack) isthere.mSpecialItems, (ItemStack) aRecipe.mSpecialItems) ? null : this.add(aRecipe); + } + } + + public GT_Recipe addRecipe(GT_Recipe aRecipe, boolean VanillaGT) { + if (VanillaGT) + return addRecipe(aRecipe, true, false, false); + else + return addRecipe(aRecipe); + } + + public GT_Recipe addRecipe(GT_Recipe aRecipe) { + if (aRecipe.mInputs.length > 0 && GT_Utility.areStacksEqual(aRecipe.mInputs[aRecipe.mInputs.length - 1], GT_Utility.getIntegratedCircuit(32767))) + return aRecipe; + else { + ItemStack[] nu1 = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); + nu1[nu1.length - 1] = GT_Utility.getIntegratedCircuit(9 + nu1.length); + aRecipe.mInputs = nu1; + } + if (this.findRecipe((IHasWorldObjectAndCoords) null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null) { + ItemStack[] nu = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); + int i = 9 + nu.length; + do { + nu[nu.length - 1] = GT_Utility.getIntegratedCircuit(i); + i++; + aRecipe.mInputs = nu; + if (i > 24) + i = 1; + if (i == 9 + nu.length) + return null; + } + while (this.findRecipe((IHasWorldObjectAndCoords) null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null); + } + return this.addRecipe(aRecipe, false, false, false); + } + } + + private static class SpecialObjectSensitiveMap extends GT_Recipe.GT_Recipe_Map{ + + private SpecialObjectSensitiveMap(Collection 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); + } + /** - * finds a Recipe matching the aFluid and ItemStack Inputs. + * finds a Recipe matching the aFluid, aSpecial and ItemStack Inputs. * * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup. * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up. @@ -530,7 +593,7 @@ public class BWRecipes { * @param aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with the provided input * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage * @param aFluids the Fluid Inputs - * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. + * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. Like this one. * @param aInputs the Item Inputs * @return the Recipe it has found or null for no matching Recipe */ @@ -592,56 +655,5 @@ public class BWRecipes { // And nothing has been found. return null; } - - protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { - aRecipe.mHidden = aHidden; - aRecipe.mFakeRecipe = aFakeRecipe; - GT_Recipe isthere = this.findRecipe((IHasWorldObjectAndCoords) null, false, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs); - - if (aRecipe.mFluidInputs.length < this.mMinimalInputFluids && aRecipe.mInputs.length < this.mMinimalInputItems) { - return null; - } else { - return aCheckForCollisions && isthere != null && BW_Util.areStacksEqualOrNull((ItemStack) isthere.mSpecialItems, (ItemStack) aRecipe.mSpecialItems) ? null : this.add(aRecipe); - } - } - - public GT_Recipe addRecipe(GT_Recipe aRecipe, boolean VanillaGT) { - if (VanillaGT) - return addRecipe(aRecipe, true, false, false); - else - return addRecipe(aRecipe); - } - - public GT_Recipe addRecipe(GT_Recipe aRecipe) { - if (aRecipe.mInputs.length > 0 && GT_Utility.areStacksEqual(aRecipe.mInputs[aRecipe.mInputs.length - 1], GT_Utility.getIntegratedCircuit(32767))) - return aRecipe; - else { - ItemStack[] nu1 = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); - nu1[nu1.length - 1] = GT_Utility.getIntegratedCircuit(9 + nu1.length); - aRecipe.mInputs = nu1; - } - if (this.findRecipe((IHasWorldObjectAndCoords) null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null) { - ItemStack[] nu = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); - int i = 9 + nu.length; - do { - nu[nu.length - 1] = GT_Utility.getIntegratedCircuit(i); - i++; - aRecipe.mInputs = nu; - if (i > 24) - i = 1; - if (i == 9 + nu.length) - return null; - } - while (this.findRecipe((IHasWorldObjectAndCoords) null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null); - } - return this.addRecipe(aRecipe, false, false, false); - } - } - - class BioLabRecipe extends GT_Recipe { - protected BioLabRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); - } - } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index f774989d6a..5802387794 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.util; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; @@ -417,4 +418,21 @@ public class BW_Util { } return ret; } + + public static byte getCircuitTierFromOreDictName(String name) { + switch (name){ + case "circuitPrimitive": return 0; + case "circuitBasic": return 1; + case "circuitGood": return 2; + case "circuitAdvanced": return 3; + case "circuitData": return 4; + case "circuitElite": return 5; + case "circuitMaster": return 6; + case "circuitUltimate": return 7; + case "circuitSuperconductor": return 8; + case "circuitInfinite": return 9; + case "circuitBio": return 10; + default: return -1; + } + } } -- cgit