diff options
| author | Technus <daniel112092@gmail.com> | 2017-08-21 08:44:13 +0200 |
|---|---|---|
| committer | Technus <daniel112092@gmail.com> | 2017-08-21 08:44:13 +0200 |
| commit | 712d76561585ab35e787d2db2593ed84650a356e (patch) | |
| tree | 088accfe712f0488ae46cb132fde039751b45b6b /src/main/java/com | |
| parent | cc4055e984cdfd685738acf003ac02916070559f (diff) | |
| parent | f255a93d8141e51c0406dc497b9e5f68e4b8bcdc (diff) | |
| download | GT5-Unofficial-712d76561585ab35e787d2db2593ed84650a356e.tar.gz GT5-Unofficial-712d76561585ab35e787d2db2593ed84650a356e.tar.bz2 GT5-Unofficial-712d76561585ab35e787d2db2593ed84650a356e.zip | |
Merge branch 'master' into bassAdditions
Diffstat (limited to 'src/main/java/com')
26 files changed, 1112 insertions, 126 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 34426b0075..9be7c008d7 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -70,7 +70,9 @@ public class TecTech { proxy.addTexturePage(tectechTexturePage1); GTCustomLoader = new MainLoader(); + dAtomDefinition.overrides.add(new AtomOverrider()); + TecTech.Logger.info("Added Atom Overrider"); } @EventHandler diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java index 2ae8ddbede..57effa005e 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java @@ -36,6 +36,10 @@ public class rElementalRecipeMap {//TODO FIX return recipes.remove(map);//suspicious but ok, equals and hashcode methods are adjusted for that } + public HashMap<Short, rElementalRecipe> findExact(cElementalInstanceStackMap in) { + return recipes.get(in.toDefinitionMapForComparison());//suspicious but ok, equals and hashcode methods are adjusted for that + } + //Recipe founding should not check amounts - this checks if the types of matter in map are equal to any recipe! //Return a recipeShortMap when the content of input is equal (ignoring amounts and instance data) @Deprecated @@ -43,10 +47,6 @@ public class rElementalRecipeMap {//TODO FIX return recipes.get(in);//suspicious but ok, equals and hashcode methods are adjusted for that } - public HashMap<Short, rElementalRecipe> findExact(cElementalInstanceStackMap in) { - return recipes.get(in.toDefinitionMapForComparison());//suspicious but ok, equals and hashcode methods are adjusted for that - } - //this does check if the map contains all the requirements for any recipe, and the required amounts //Return a recipeShortMap when the content of input matches the recipe input - does not ignore amounts but ignores instance data! @Deprecated diff --git a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java index 344fa44ff9..a92a5a663d 100644 --- a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java @@ -2,11 +2,13 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.block.QuantumGlassBlock; +import com.github.technus.tectech.thing.block.QuantumStuffBlock; import com.github.technus.tectech.thing.casing.GT_Block_CasingsTT; import com.github.technus.tectech.thing.casing.GT_Block_HintTT; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.item.ConstructibleTriggerItem; import com.github.technus.tectech.thing.item.DebugContainer_EM; +import com.github.technus.tectech.thing.item.DefinitionContainer_EM; import com.github.technus.tectech.thing.item.ParametrizerMemoryCard; import cpw.mods.fml.common.Loader; import openmodularturrets.blocks.turretbases.TurretBaseEM; @@ -25,6 +27,9 @@ public class ThingsLoader implements Runnable { QuantumGlassBlock.run(); TecTech.Logger.info("Quantum Glass registered"); + QuantumStuffBlock.run(); + TecTech.Logger.info("Quantum Stuff registered"); + if(Loader.isModLoaded("openmodularturrets")) { TurretHeadEM.run(); TecTech.Logger.info("TurretHeadEM registered"); @@ -32,9 +37,12 @@ public class ThingsLoader implements Runnable { TecTech.Logger.info("TurretBaseEM registered"); } - DebugContainer_EM.run(); ConstructibleTriggerItem.run(); ParametrizerMemoryCard.run(); + TecTech.Logger.info("Useful item registered"); + + DefinitionContainer_EM.run(); + DebugContainer_EM.run(); TecTech.Logger.info("Debug Items registered"); } } diff --git a/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java b/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java index 4b92fd0509..96a84b6603 100644 --- a/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java +++ b/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java @@ -41,7 +41,7 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ {"202","0!0","202",}, }; private static final Block[] blockType = new Block[]{QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{0,0,4,10}; + private static final byte[] blockMeta = new byte[]{0,0,4,8}; private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalInputToMachineList", "addElementalMufflerToMachineList"}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; diff --git a/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java b/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java index 2d484c8815..96d8056992 100644 --- a/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java +++ b/src/main/java/com/github/technus/tectech/magicAddon/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java @@ -41,7 +41,7 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu {"010","1!1","010",}, }; private static final Block[] blockType = new Block[]{QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{0,4,0,10}; + private static final byte[] blockMeta = new byte[]{0,4,0,8}; private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalOutputToMachineList", "addElementalMufflerToMachineList"}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset+4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; diff --git a/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java b/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java index 443a069d2e..b488e29ee7 100644 --- a/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java +++ b/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java @@ -11,7 +11,7 @@ public class NEI_TT_Config implements IConfigureNEI {//must be NEI*Config public void loadConfig() { sIsAdded = false; if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - TT_RH =new TT_NEI_ResearchHandler(TT_recipe.TT_Recipe_Map.sResearchableFakeRecipes); + TT_RH =new TT_NEI_ResearchHandler(TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes); sIsAdded = true; } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java index 54035707ca..f4a8ca8e7e 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java @@ -44,9 +44,9 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { GuiContainerManager.addTooltipHandler(new GT_RectHandler()); } - protected final TT_recipe.TT_Recipe_Map mRecipeMap; + protected final TT_recipe.GT_Recipe_MapTT mRecipeMap; - public TT_NEI_ResearchHandler(TT_recipe.TT_Recipe_Map aRecipeMap) { + public TT_NEI_ResearchHandler(TT_recipe.GT_Recipe_MapTT aRecipeMap) { this.mRecipeMap = aRecipeMap; this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); if (!NEI_TT_Config.sIsAdded) { diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java index ab1307cb3e..89eae43bcd 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.proxy; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.entity.fx.BlockHint; import com.github.technus.tectech.thing.block.QuantumGlassRender; +import com.github.technus.tectech.thing.block.QuantumStuffRender; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -42,6 +43,9 @@ public class ClientProxy extends CommonProxy { QuantumGlassRender.renderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(QuantumGlassRender.renderID, new QuantumGlassRender()); + QuantumStuffRender.renderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(QuantumStuffRender.renderID, new QuantumStuffRender()); + if(Loader.isModLoaded("openmodularturrets")) { TurretHeadRenderEM turretHeadRenderEM=new TurretHeadRenderEM(); ClientRegistry.bindTileEntitySpecialRenderer(TileTurretHeadEM.class, turretHeadRenderEM); diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java index f131dde200..2b9f917418 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java @@ -1,16 +1,235 @@ package com.github.technus.tectech.recipe; +import com.github.technus.tectech.auxiliary.TecTechConfig; +import com.github.technus.tectech.elementalMatter.classes.cElementalDefinition; +import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStackMap; +import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackMap; +import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; +import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_Recipe; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; -public class TT_recipe /*extends GT_Recipe*/ { - public static class TT_Recipe_Map extends GT_Recipe.GT_Recipe_Map { - public static TT_Recipe_Map sResearchableFakeRecipes =new TT_Recipe_Map(new HashSet(30), "gt.recipe.researchStation", "Research station", (String)null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1, 1, 0, 1, "", 1, "", true, false);//nei to false - using custom handler +public class TT_recipe extends GT_Recipe { + public static final String E_RECIPE_ID = "eRecipeID"; + public final cElementalDefinitionStackMap input[],output[], eCatalyst[]; + public final AdditionalCheck additionalCheck; - public TT_Recipe_Map (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) { + public TT_recipe(boolean aOptimize, + ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, + FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check){ + super(aOptimize,aInputs,aOutputs,aSpecialItems,aChances,aFluidInputs,aFluidOutputs,aDuration,aEUt,aSpecialValue); + input=in; + output=out; + eCatalyst=catalyst; + additionalCheck=check; + } + + public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks){ + return EMisRecipeInputEqual(consume,doNotCheckStackSizes,itemStacks,fluidStacks,null,null); + } + + public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in){ + return EMisRecipeInputEqual(consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,null); + } + + public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in, cElementalInstanceStackMap[] catalyst) { + if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) return false; + if (this.eCatalyst != null) { + if (catalyst != null && catalyst.length >= this.eCatalyst.length) { + for (int i = 0; i < this.eCatalyst.length; i++) { + if (this.eCatalyst[i] != null && this.eCatalyst[i].hasStacks()) { + if (catalyst[i] != null && catalyst[i].hasStacks()) { + if (!catalyst[i].removeAllAmounts(true, this.eCatalyst[i])) return false; + } else { + return false; + } + } + } + } else { + return false; + } + } + if (input != null) { + if (in != null && in.length >= input.length) { + for (int i = 0; i < input.length; i++) { + if (input[i] != null && input[i].hasStacks()) { + if (in[i] != null && in[i].hasStacks()) { + if (!in[i].removeAllAmounts(consume, input[i])) return false; + } else { + return false; + } + } + } + } else { + return false; + } + } + return super.isRecipeInputEqual(consume, doNotCheckStackSizes, fluidStacks, itemStacks); + } + + public boolean EMisRecipeInputEqualConsumeFromOne(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in){ + return EMisRecipeInputEqualConsumeFromOne(consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,null); + } + + public boolean EMisRecipeInputEqualConsumeFromOne(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in, cElementalInstanceStackMap[] catalyst) { + if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) return false; + if (this.eCatalyst != null) { + if (catalyst != null && catalyst.length >= this.eCatalyst.length) { + for (int i = 0; i < this.eCatalyst.length; i++) { + if (this.eCatalyst[i] != null && this.eCatalyst[i].hasStacks()) { + if (catalyst[i] != null && catalyst[i].hasStacks()) { + if (!catalyst[i].removeAllAmounts(true, this.eCatalyst[i])) return false; + } else { + return false; + } + } + } + } else { + return false; + } + } + if (input != null) { + if (in != null) { + for (int i = 0; i < input.length; i++) { + if (input[i] != null && input[i].hasStacks()) { + if (in.hasStacks()) { + if (!in.removeAllAmounts(consume, input[i])) return false; + } else { + return false; + } + } + } + } else { + return false; + } + } + return super.isRecipeInputEqual(consume, doNotCheckStackSizes, fluidStacks, itemStacks); + } + + public interface AdditionalCheck { + boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in, cElementalInstanceStackMap[] e); + boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in, cElementalInstanceStackMap[] e); + } + + public static class TT_Recipe_Map<T extends TT_recipe> { + public static TT_Recipe_Map<TT_assLineRecipe> sCrafterRecipes = new TT_Recipe_Map<>(); + public static TT_Recipe_Map<TT_assLineRecipe> sMachineRecipes = new TT_Recipe_Map<>(); + + private final HashMap<String,T> mRecipeMap; + + + public TT_Recipe_Map(){ + mRecipeMap =new HashMap<>(16); + } + + public T findRecipe(String identifier){ + return mRecipeMap.get(identifier); + } + + public T findRecipe(ItemStack dataHandler){ + if(dataHandler==null || dataHandler.stackTagCompound==null) return null; + return mRecipeMap.get(dataHandler.stackTagCompound.getString(E_RECIPE_ID)); + } + + public void add(T recipe){ + GameRegistry.UniqueIdentifier uid=GameRegistry.findUniqueIdentifierFor(recipe.mOutputs[0].getItem()); + mRecipeMap.put(uid+":"+recipe.mOutputs[0].getItemDamage(),recipe); + } + + public Collection<T> recipeList(){ + return mRecipeMap.values(); + } + } + + public static class GT_Recipe_MapTT extends GT_Recipe.GT_Recipe_Map { + public static GT_Recipe_MapTT sResearchableFakeRecipes =new GT_Recipe_MapTT(new HashSet<GT_Recipe>(32), "gt.recipe.researchStation", "Research station", (String)null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1,1,0,1,"", 1, "", true, false);//nei to false - using custom handler + public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT(new HashSet<GT_Recipe>(32),"gt.recipe.em_scanner","EM Scanner Research",(String)null,"gregtech:textures/gui/multimachines/ResearchFake",1,1,1,0,1,"",1,"",true,false); + + public GT_Recipe_MapTT(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); } } + + public static class TT_assLineRecipe extends TT_recipe{ + public final ItemStack mResearchItem; + + public TT_assLineRecipe(boolean aOptimize, ItemStack researchItem, + ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check) { + super(aOptimize, aInputs, aOutputs, aSpecialItems, null, aFluidInputs, null, aDuration, aEUt, aSpecialValue, in, out, catalyst, check); + mResearchItem=researchItem; + } + + public TT_assLineRecipe(boolean aOptimize, ItemStack researchItem, + ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, + cElementalDefinitionStackMap[] in) { + this(aOptimize, researchItem, aInputs, aOutputs, aSpecialItems, aFluidInputs, aDuration, aEUt, aSpecialValue, in, null, null,null); + } + } + + public static class TT_EMRecipe extends TT_recipe{ + public final iElementalDefinition mResearchEM; + public final GT_Recipe scannerRecipe; + + public TT_EMRecipe(boolean aOptimize, GT_Recipe scannerRecipe, iElementalDefinition researchEM, + ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check) { + super(aOptimize, aInputs, aOutputs, aSpecialItems, null, aFluidInputs, null, aDuration, aEUt, aSpecialValue, in, out, catalyst, check); + mResearchEM=researchEM; + this.scannerRecipe=scannerRecipe; + } + + public TT_EMRecipe(boolean aOptimize, GT_Recipe scannerRecipe, iElementalDefinition researchEM, + ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, + cElementalDefinitionStackMap[] in) { + this(aOptimize, scannerRecipe, researchEM, aInputs, aOutputs, aSpecialItems, aFluidInputs, aDuration, aEUt, aSpecialValue, in, null, null,null); + } + } + + public static class TT_Recipe_Map_EM<T extends TT_EMRecipe> { + public static TT_Recipe_Map_EM<TT_EMRecipe> sCrafterRecipesEM = new TT_Recipe_Map_EM<>("EM Crafter Recipes","gt.recipe.em_crafter",null); + public static TT_Recipe_Map_EM<TT_EMRecipe> sMachineRecipesEM = new TT_Recipe_Map_EM<>("EM Machinert Recipe","gt.recipe.em_machinery",null); + + private final HashMap<iElementalDefinition,T> mRecipeMap; + public final String mNEIName,mUnlocalizedName,mNEIGUIPath; + + public TT_Recipe_Map_EM(String mNEIName,String mUnlocalizedName,String mNEIGUIPath){ + mRecipeMap =new HashMap<>(16); + this.mNEIName=mNEIName; + this.mUnlocalizedName=mUnlocalizedName; + this.mNEIGUIPath=mNEIGUIPath; + } + + public T findRecipe(iElementalDefinition stack){ + return mRecipeMap.get(stack); + } + + public T findRecipe(ItemStack dataHandler){ + if(dataHandler==null || dataHandler.stackTagCompound==null) return null; + try { + return mRecipeMap.get(cElementalDefinition.fromNBT(dataHandler.stackTagCompound.getCompoundTag(E_RECIPE_ID))); + }catch (Exception e){ + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); + return null; + } + } + + public void add(T recipe){ + mRecipeMap.put(recipe.mResearchEM,recipe); + } + + public Collection<T> recipeList(){ + return mRecipeMap.values(); + } + } } diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java index 460a9aa056..6d7060b4fb 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -1,6 +1,12 @@ package com.github.technus.tectech.recipe; -import gregtech.api.GregTech_API; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStack; +import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStackMap; +import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; +import com.github.technus.tectech.thing.item.DefinitionContainer_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafter; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_machine; import gregtech.api.enums.ItemList; import gregtech.api.util.GT_Recipe; import gregtech.common.GT_RecipeAdder; @@ -8,38 +14,120 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public class TT_recipeAdder extends GT_RecipeAdder { + public static final ItemStack[] nullItem=new ItemStack[0]; + public static final FluidStack[] nullFluid=new FluidStack[0]; + public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { - if(aInputs==null)aInputs=new ItemStack[0]; - if(aFluidInputs==null)aFluidInputs=new FluidStack[0]; + if(aInputs==null)aInputs=nullItem; + if(aFluidInputs==null)aFluidInputs=nullFluid; if ((aResearchItem==null)||(totalComputationRequired<=0)||(aOutput == null) || aInputs.length>15) { return false; } - if ((assDuration = GregTech_API.sRecipeFile.get("assemblingline", aOutput, assDuration)) <= 0) { - return false; - } for(ItemStack tItem : aInputs){ if(tItem==null){ - System.out.println("addAssemblingLineRecipe "+aResearchItem.getDisplayName()+" --> "+aOutput.getUnlocalizedName()+" there is some null item in that recipe"); + TecTech.Logger.error("addAssemblingLineRecipe "+aResearchItem.getDisplayName()+" --> "+aOutput.getUnlocalizedName()+" there is some null item in that recipe"); } } if(researchAmperage<=0) researchAmperage=1; else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; if(computationRequiredPerSec<=0) computationRequiredPerSec=1; else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; - TT_recipe.TT_Recipe_Map.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result")}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); + TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result")}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result")}, aFluidInputs, null, assDuration, assEUt, 0,true); GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe.GT_Recipe_AssemblyLine( aResearchItem, 0/*ignored*/, aInputs, aFluidInputs, aOutput, assDuration, assEUt)); return true; } - //public boolean addResearchableEMAssemblyRecipe(ItemStack aResearchItem, int computationRequired, rElementalRecipe emREcipe, int aDuration, int aEUt) { - // if ((aResearchItem==null)||(computationRequired<=0)||(emREcipe == null)) { - // return false; - // } - // todo write recipe maps - // GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result", new Object[0])}, null, null, computationRequired, 30, 0); - // GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result", new Object[0])}, aFluidInputs, null, aDuration, aEUt, 0,true); - // GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe.GT_Recipe_AssemblyLine( aResearchItem, computationRequired, aInputs, aFluidInputs, aOutput, aDuration, aEUt)); - // return true; - //} + /* + (boolean aOptimize, + ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, + FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check) + */ + + public static boolean addResearchableEMmachineRecipe( + ItemStack aResearchItem, i |
