From 425332f22b3971f9a3c5b72786634121d538cc64 Mon Sep 17 00:00:00 2001 From: Technus Date: Sun, 13 Aug 2017 00:34:18 +0200 Subject: implemented research station --- .../github/technus/tectech/nei/NEI_TT_Config.java | 25 +++ .../tectech/nei/TT_NEI_ResearchHandler.java | 41 +++-- .../github/technus/tectech/nei/TT_NEI_config.java | 25 --- .../github/technus/tectech/recipe/TT_recipe.java | 2 +- .../technus/tectech/recipe/TT_recipeAdder.java | 4 +- .../GT_MetaTileEntity_Hatch_DataConnector.java | 3 +- .../hatch/GT_MetaTileEntity_Hatch_Holder.java | 7 - .../multi/GT_MetaTileEntity_EM_computer.java | 6 +- .../multi/GT_MetaTileEntity_EM_research.java | 185 +++++++++++++++++++-- .../multi/GT_MetaTileEntity_EM_transformer.java | 5 + .../multi/GT_MetaTileEntity_MultiblockBase_EM.java | 117 ++++++------- .../multi/GT_MetaTileEntity_TM_microwave.java | 3 +- 12 files changed, 292 insertions(+), 131 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java delete mode 100644 src/main/java/com/github/technus/tectech/nei/TT_NEI_config.java (limited to 'src/main') 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 new file mode 100644 index 0000000000..443a069d2e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java @@ -0,0 +1,25 @@ +package com.github.technus.tectech.nei; + +import codechicken.nei.api.IConfigureNEI; +import com.github.technus.tectech.recipe.TT_recipe; +import cpw.mods.fml.common.FMLCommonHandler; + +public class NEI_TT_Config implements IConfigureNEI {//must be NEI*Config + public static boolean sIsAdded = true; + public static TT_NEI_ResearchHandler TT_RH; + + public void loadConfig() { + sIsAdded = false; + if(FMLCommonHandler.instance().getEffectiveSide().isClient()) + TT_RH =new TT_NEI_ResearchHandler(TT_recipe.TT_Recipe_Map.sResearchableFakeRecipes); + sIsAdded = true; + } + + public String getName() { + return "TecTech NEI Plugin"; + } + + public String getVersion() { + return "(1.0)"; + } +} 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 c414220922..64dfb900da 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 @@ -9,11 +9,11 @@ import codechicken.nei.recipe.GuiCraftingRecipe; import codechicken.nei.recipe.GuiRecipe; import codechicken.nei.recipe.GuiUsageRecipe; import codechicken.nei.recipe.TemplateRecipeHandler; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.recipe.TT_recipe; import cpw.mods.fml.common.event.FMLInterModComms; import gregtech.GT_Mod; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.OrePrefixes; import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.objects.ItemData; @@ -22,7 +22,6 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.gui.GT_GUIContainer_FusionReactor; -import gregtech.nei.NEI_GT_Config; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.init.Blocks; @@ -50,9 +49,9 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { public TT_NEI_ResearchHandler(TT_recipe.TT_Recipe_Map aRecipeMap) { this.mRecipeMap = aRecipeMap; - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier(), new Object[0])); - if (!NEI_GT_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", Reference.MODID+"@" + getRecipeName() + "@" + getOverlayIdentifier()); + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); + if (!NEI_TT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(TecTech.instance, "NEIPlugins", "register-crafting-handler", Reference.MODID+"@" + getRecipeName() + "@" + getOverlayIdentifier()); GuiCraftingRecipe.craftinghandlers.add(this); GuiUsageRecipe.usagehandlers.add(this); } @@ -69,8 +68,8 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { } public TemplateRecipeHandler newInstance() { - TT_NEI_config.TT_RH=new TT_NEI_ResearchHandler(mRecipeMap); - return TT_NEI_config.TT_RH; + NEI_TT_Config.TT_RH=new TT_NEI_ResearchHandler(mRecipeMap); + return NEI_TT_Config.TT_RH; } public void loadCraftingRecipes(String outputId, Object... results) { @@ -101,7 +100,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + tResults.add(GT_Utility.copy(tData.filledContainer)); } } } @@ -135,7 +134,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + tInputs.add(GT_Utility.copy(tData.filledContainer)); } } } @@ -208,19 +207,19 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { int computation = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); if (recipeDesc == null) { - //if (tEUt != 0) { - // drawText(10, 73, trans("152","Total: ") + computation * tEUt + " EU", -16777216); - // drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); - // if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - // drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); - // drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); - // } else { - // drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); - // drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); - // } - //} + if (tEUt != 0) { + //drawText(10, 73, trans("152","Total: ") + computation * tEUt + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); + drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); + } + } if (computation > 0) { - drawText(10, 113, "Computation: "+String.format("%.2f ", 0.05F * computation), -16777216); + drawText(10, 113, "Computation: "+computation, -16777216); } int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; if (tSpecial == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_config.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_config.java deleted file mode 100644 index a6b729f407..0000000000 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_config.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.github.technus.tectech.nei; - -import codechicken.nei.api.IConfigureNEI; -import com.github.technus.tectech.recipe.TT_recipe; -import cpw.mods.fml.common.FMLCommonHandler; - -public class TT_NEI_config implements IConfigureNEI { - public static boolean sIsAdded = true; - public static TT_NEI_ResearchHandler TT_RH; - - public void loadConfig() { - sIsAdded = false; - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - TT_RH =new TT_NEI_ResearchHandler(TT_recipe.TT_Recipe_Map.sResearchableFakeRecipes); - sIsAdded = true; - } - - public String getName() { - return "GregTech NEI Plugin"; - } - - public String getVersion() { - return "(5.03a)"; - } -} 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 6f1196f0aa..96bdcf2703 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 @@ -7,7 +7,7 @@ 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/basicmachines/Scanner", 1, 1, 1, 0, 1, "", 1, "", false, true); + public static TT_Recipe_Map sResearchableFakeRecipes =new TT_Recipe_Map(new HashSet(30), "gt.recipe.researchStation", "Research station", (String)null, "gregtech:textures/gui/basicmachines/Scanner", 1, 1, 1, 0, 1, "", 1, "", true, false);//nei to false - using custom handler public TT_Recipe_Map (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); 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 d700514903..9389d73c3b 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 @@ -9,7 +9,9 @@ import net.minecraftforge.fluids.FluidStack; public class TT_recipeAdder extends GT_RecipeAdder { public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, int computationRequired, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) { - if ((aResearchItem==null)||(computationRequired<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15) { + if(aInputs==null)aInputs=new ItemStack[0]; + if(aFluidInputs==null)aFluidInputs=new FluidStack[0]; + if ((aResearchItem==null)||(computationRequired<=0)||(aOutput == null) || aInputs.length>15) { return false; } if ((aDuration = GregTech_API.sRecipeFile.get("assemblingline", aOutput, aDuration)) <= 0) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java index aeb7abb7e6..1d069cb77d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java @@ -90,8 +90,7 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE } } - public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { - } + public abstract void moveAround(IGregTechTileEntity aBaseMetaTileEntity); @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java index c2b3cd7f3f..4bd0c53a36 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java @@ -112,13 +112,6 @@ public class GT_MetaTileEntity_Hatch_Holder extends GT_MetaTileEntity_Hatch { return 1; } - //@Override - //public void onRemoval() { - // if(mInventory!=null && (heat>0 || (getBaseMetaTileEntity()!=null && getBaseMetaTileEntity().isActive()))) - // for(int i=0;i eHolders = new ArrayList<>(); + private GT_Recipe.GT_Recipe_AssemblyLine tRecipe; + private long computationRemaining,computationRequired; //region structure private static final String[][] shape = new String[][]{ @@ -44,9 +55,9 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{1, 3, 2}; private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addHolderToMachineList"}; - private static final short[] casingTextures = new short[]{textureOffset + 3, textureOffset + 3}; + private static final short[] casingTextures = new short[]{textureOffset + 1, textureOffset + 3}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, Blocks.air}; - private static final byte[] blockMetaFallback = new byte[]{3, 0}; + private static final byte[] blockMetaFallback = new byte[]{1, 0}; private static final String[] description = new String[]{ EnumChatFormatting.AQUA+"Hint Details:", "1 - Classic/Data Hatches or Computer casing", @@ -93,18 +104,124 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB } @Override - public boolean EM_checkRecipe(ItemStack itemStack) { - //for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { - // r.getBaseMetaTileEntity().setActive(true); - //}//Look in Computer code + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("eComputationRemaining",computationRemaining); + aNBT.setLong("eComputationRequired",computationRequired); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + computationRemaining=aNBT.getLong("eComputationRemaining"); + computationRequired=aNBT.getLong("eComputationRequired"); + } + + @Override + protected void EM_onFirstTick() { + if(computationRemaining>0) { + tRecipe = null; + if (!eHolders.isEmpty() && eHolders.get(0).mInventory[0] != null && + ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)) { + ItemStack researchItem = eHolders.get(0).mInventory[0]; + for (GT_Recipe.GT_Recipe_AssemblyLine tRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { + if (GT_Utility.areStacksEqual(tRecipe.mResearchItem, researchItem, true)) { + this.tRecipe = tRecipe; + } + } + } + if (tRecipe == null) { + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) + r.getBaseMetaTileEntity().setActive(false); + } + } + } - //check for item in controller and holder - //find research - //DO IT + @Override + public boolean EM_checkRecipe(ItemStack itemStack) { + if(!eHolders.isEmpty() && eHolders.get(0).mInventory[0]!=null && + ItemList.Tool_DataStick.isStackEqual(itemStack, false, true)){ + ItemStack researchItem=eHolders.get(0).mInventory[0]; + for(GT_Recipe.GT_Recipe_AssemblyLine tRecipe:GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes){ + if(GT_Utility.areStacksEqual(tRecipe.mResearchItem, researchItem, true)){ + this.tRecipe=tRecipe; + //if found + for(GT_Recipe ttRecipe: TT_recipe.TT_Recipe_Map.sResearchableFakeRecipes.mRecipeList){ + if(GT_Utility.areStacksEqual(ttRecipe.mInputs[0], researchItem, true)){ + computationRequired=computationRemaining=ttRecipe.mDuration*20L; + mMaxProgresstime=20; + mEfficiencyIncrease=10000; + eRequiredData=1;//require constant pc connection doesn't matter how fast is the computer + eAmpereFlow=1; + mEUt=(int)V[8]; + eHolders.get(0).getBaseMetaTileEntity().setActive(true); + return true; + } + } + } + } + } + computationRequired=computationRemaining=0; + mMaxProgresstime=0; + mEfficiencyIncrease = 0; + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) + r.getBaseMetaTileEntity().setActive(false); return false; } + @Override + public boolean onRunningTick(ItemStack aStack) { + if(computationRemaining<=0) { + computationRemaining=0; + mProgresstime=mMaxProgresstime; + return true; + }else{ + computationRemaining-=eAvailableData; + mProgresstime=1; + return super.onRunningTick(aStack); + } + } + + @Override + public void EM_outputFunction() { + if(tRecipe!=null && !eHolders.isEmpty() && ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)){ + eHolders.get(0).getBaseMetaTileEntity().setActive(false); + eHolders.get(0).mInventory[0]=null; + + mInventory[1].setStackDisplayName(GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName())+" Construction Data"); + NBTTagCompound tNBT = mInventory[1].getTagCompound();//code above makes it not null + + tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound())); + tNBT.setInteger("time", tRecipe.mDuration); + tNBT.setInteger("eu", tRecipe.mEUt); + for(int i = 0 ; i < tRecipe.mInputs.length ; i++){ + tNBT.setTag(""+i, tRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); + } + for(int i = 0 ; i < tRecipe.mFluidInputs.length ; i++){ + tNBT.setTag("f"+i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); + } + tNBT.setString("author", "EM Assembling Line Recipe Generator"); + NBTTagList tNBTList = new NBTTagList(); + tNBTList.appendTag(new NBTTagString("Construction plan for "+tRecipe.mOutput.stackSize+" "+GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName())+". Needed EU/t: "+tRecipe.mEUt+" Production time: "+(tRecipe.mDuration/20))); + for(int i=0;i 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { + if (dump.addOverflowMatter(mass)) explodeMultiblock(); + } + } + outputEM = null; + + hatchesStatusUpdate(); + }//On machine stop - now called when softhammered to offline state! - it does not cause a full stop like power failure //RATHER LEAVE ALONE Section @@ -383,10 +410,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (aBaseMetaTileEntity.isServerSide()) { if (mEfficiency < 0) mEfficiency = 0; - if(getBaseMetaTileEntity().hasWorkJustBeenEnabled()) EM_workJustGotEnabled(); - if(previousTickValueForWorkEnabled && !getBaseMetaTileEntity().isAllowedToWork()) + if (getBaseMetaTileEntity().hasWorkJustBeenEnabled()) EM_workJustGotEnabled(); + if (previousTickValueForWorkEnabled && !getBaseMetaTileEntity().isAllowedToWork()) EM_workJustGotDisabled(); - previousTickValueForWorkEnabled=getBaseMetaTileEntity().isAllowedToWork();//Assign new value + previousTickValueForWorkEnabled = getBaseMetaTileEntity().isAllowedToWork();//Assign new value if (--mUpdate == 0 || --mStartUpCheck == 0 || cyclicUpdate() || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { mInputHatches.clear(); @@ -510,7 +537,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mSolderingTool = true; mCrowbar = true; } else { - if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) tHatch.autoMaintainance(); + if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) + tHatch.autoMaintainance(); if (tHatch.mWrench) mWrench = true; if (tHatch.mScrewdriver) mScrewdriver = true; if (tHatch.mSoftHammer) mSoftHammer = true; @@ -536,7 +564,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt int qty = (int) Math.floor(remaining / instance.definition.getMass()); if (qty > 0) { qty = Math.min(qty, instance.amount); - if(voider.addOverflowMatter(instance.definition.getMass() * qty)) + if (voider.addOverflowMatter(instance.definition.getMass() * qty)) voider.setOverflowMatter(voider.overflowMax); in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); } @@ -547,7 +575,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt int qty = (int) Math.floor(remaining / instance.definition.getMass()); if (qty > 0) { qty = Math.min(qty, instance.amount); - if(voider.addOverflowMatter(instance.definition.getMass() * qty)) + if (voider.addOverflowMatter(instance.definition.getMass() * qty)) voider.setOverflowMatter(voider.overflowMax); out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); } @@ -562,8 +590,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) {//Start if (onRunningTick(mInventory[1])) {//Compute EU - if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) - stopMachine(); + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) stopMachine();//todo add em pollution if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime && recipeAt == Tick) {//progress increase and done hatchesStatusUpdate(); @@ -575,7 +602,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (tStack != null) addOutput(tStack); mOutputItems = null; - if(mOutputFluids!=null) { + if (mOutputFluids != null) { if (mOutputFluids.length == 1) { for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); @@ -592,18 +619,22 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); } updateSlots(); - } else stopMachine(); + }// else {//not allowed to work + // stopMachine(); + //} } - } - } else { - if (recipeAt == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { - if (aBaseMetaTileEntity.isAllowedToWork()) { - if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); - } - updateSlots(); - } else stopMachine(); - } + }// else {//failed to consume power/resources - inside on running tick + // stopMachine(); + //} + } else if (recipeAt == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe(mInventory[1])) { + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + } + updateSlots(); + }// else {//not allowed to work + // stopMachine(); + //} } {//DO ONCE @@ -689,12 +720,15 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public boolean onRunningTick(ItemStack aStack) { - if (eRequiredData > 0 && eRequiredData > eAvailableData) return false; + if (eRequiredData > 0 && eRequiredData > eAvailableData) { + stopMachine(); + return false; + } if (this.mEUt > 0) { this.EMaddEnergyOutput((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); return true; } else if (this.mEUt < 0 && !this.EMdrainEnergyInput((long) (-this.mEUt) * getMaxEfficiency(aStack) / (long) Math.max(1000, this.mEfficiency), eAmpereFlow)) { - this.stopMachine(); + stopMachine(); return false; } else return true; } @@ -845,39 +879,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return out.hasStacks()?out:null; } - @Override - public final void stopMachine() { - mOutputItems = null; - mOutputFluids = null; - //mEUt = 0; - mEfficiency = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - getBaseMetaTileEntity().disableWorking(); - - for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { - data.q = null; - } - - float mass = 0; - if (outputEM == null) return; - for (cElementalInstanceStackMap tree : outputEM) - mass += tree.getMass(); - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - if (dump.addOverflowMatter(mass)) explodeMultiblock(); - } - } - outputEM = null; - - hatchesStatusUpdate(); - - EM_stopMachine(); - } - @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { return null; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index da8290bed7..f9fbebf7f3 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -249,7 +249,8 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock } @Override - protected void EM_stopMachine() { + public void stopMachine() { + super.stopMachine(); timerValue=0; } -- cgit