diff options
author | Maxim <maxim235@gmx.de> | 2023-07-22 16:12:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-22 16:12:12 +0200 |
commit | 2b424e8295b7071b85a2960a87da91bf0dd3df02 (patch) | |
tree | 8ac7f89be7193dd0fe8e9b7b2919924fae34e860 /src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations | |
parent | dd025431efe8122bc316bc2f1b99a939c0ca149a (diff) | |
download | GT5-Unofficial-2b424e8295b7071b85a2960a87da91bf0dd3df02.tar.gz GT5-Unofficial-2b424e8295b7071b85a2960a87da91bf0dd3df02.tar.bz2 GT5-Unofficial-2b424e8295b7071b85a2960a87da91bf0dd3df02.zip |
Implement generic processing logic (#697)
* Migrated extruder
* Migrated alloy smelter
* Migrated arc furnace
* Migrated centrifuge
* Migrated ICO
* Migrated cutter
* Migrated dehydrator
* Migrated electrolyzer
* Migrated fluid heater
* Migrated forge hammer
* Forgot gtpp machines are cursed
* Migrated mac
* Migrated mixer
* Migrated molecular transformer
* Migrated bender
* Migrated sifter
* Migrated thermal centrifuge
* Migrated VF
* Migrated washer
* Migrated wiremill
* Migrated Volcanus
* Migrated adv implo compressor
* Migrated XL turbines
* Migrated chemplant
* Migrated MABS
* Migrated ABS
* Migrated cyclotron
* Migrated Zhuhai
* Migrated rock breaker
* Migrated rocketdyne
* Migrated semifluid generator
* Migrated QFT
* Minor optimization
* Migrate refinery
* Migrated solar tower
* Migrated TGS
* Migrated duplicator
* Migrated PSS
* Migrated algae pond
* Migrated froth flotation cell
* Migrated LTFR
* Migrated LPF
* Migrated sparge tower
* Migrated salt
* Migrated isamill
* Migrate DT
* Migrated HE
* Migrated mass fab
* Migrated chisel
* Migrated boiler
* Migrated steam machines
* Migrated amazon
* Disable batch mode button on XL turbines
* Update dependencies.gradle
* Updated dep
* Addressed first batch of reviews
* Migrated assembler
* Removed unused checkRecipe methods
* Forgot these
* Fix and cleanup chemplant
* Removed getAmounfOfOutputs
* Removed special multi behavior
* Migrated sound mostly
* Addressed new reviews
* Fix build fail and chisel sound
* Derp
* More reviews addressed
* Oversight on chemplant batchmode
* Fix DT speed bonus
* Removed iron blast furnace
* Removed generator array
* Removed
* Simplify rocket engine logic
* Removed left over artifacts
* Minor fixes
* Removed nerf chips
* Removed tesla tower
* Revert and fix chemplant recipe map
* Fix chemplant catalyst damaging
* Addressed reviews
* Derp
---------
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations')
2 files changed, 11 insertions, 654 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 9a2d6e7d81..f9af7d29a1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -7,7 +7,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; @@ -27,7 +26,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -59,6 +57,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; @@ -73,8 +72,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -82,13 +79,8 @@ import gregtech.api.util.IGT_HatchAdder; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; -import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; -import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -112,7 +104,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; public GT_Recipe mLastRecipe; - private boolean mInternalCircuit = false; protected long mTotalRunTime = 0; public ArrayList<GT_MetaTileEntity_Hatch_ControlCore> mControlCoreBus = new ArrayList<>(); @@ -126,9 +117,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex public ArrayList<GT_MetaTileEntity_Hatch> mAllEnergyHatches = new ArrayList<>(); public ArrayList<GT_MetaTileEntity_Hatch> mAllDynamoHatches = new ArrayList<>(); - // Custom Behaviour Map - private static final HashMap<String, SpecialMultiBehaviour> mCustomBehviours = new HashMap<>(); - public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -153,9 +141,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return this.mTotalRunTime; } - protected float batchMultiplier = 1.0f; - protected static final int MAX_BATCH_SIZE = 128; - public abstract String getMachineType(); public String getMachineTooltip() { @@ -301,13 +286,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex } mInfo.add( - StatCollector.translateToLocal("GTPP.CC.discount") + ": " - + EnumChatFormatting.GREEN - + (getEuDiscountForParallelism()) - + EnumChatFormatting.RESET - + "%"); - - mInfo.add( StatCollector.translateToLocal("GTPP.CC.parallel") + ": " + EnumChatFormatting.GREEN + (getMaxParallelRecipes()) @@ -407,14 +385,8 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex public static final String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; public static final String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; - public int getAmountOfOutputs() { - return 1; - } - public abstract int getMaxParallelRecipes(); - public abstract int getEuDiscountForParallelism(); - @Override public boolean isCorrectMachinePart(final ItemStack paramItemStack) { return true; @@ -430,22 +402,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return false; } - @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient(new ResourceLocation(getSound()), 10, 1.0F, aX, aY, aZ); - } - } - - public void startProcess() { - if (GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); - } - - public String getSound() { - return ""; - } - /** * A Static {@link Method} object which holds the current status of logging. */ @@ -461,58 +417,10 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex } } - public boolean checkRecipeGeneric() { - return checkRecipeGeneric(1, 100, 0); - } - - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent) { - return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); - } - - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, - int aOutputChanceRoll) { - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric( - tItemInputs, - tFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll); - } - - public boolean checkRecipeGeneric(GT_Recipe aRecipe, int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - if (aRecipe == null) { - return false; - } - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric( - tItemInputs, - tFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll, - aRecipe); - } - - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - return checkRecipeGeneric( - aItemInputs, - aFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll, - null); + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(GT_Utility.roundDownVoltage(this.getMaxInputVoltage())); + logic.setAvailableAmperage(1L); } public long getMaxInputEnergy() { @@ -526,319 +434,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return rEnergy; } - public boolean hasPerfectOverclock() { - return false; - } - - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - /* - * Check for Special Behaviours - */ - - // First populate the map if we need to. - if (mCustomBehviours.isEmpty()) { - mCustomBehviours.putAll(Multiblock_API.getSpecialBehaviourItemMap()); - } - - // We have a special slot object in the recipe - if (tRecipe.mSpecialItems != null) { - // The special slot is an item - if (tRecipe.mSpecialItems instanceof ItemStack) { - // Make an Itemstack instance of this. - ItemStack aSpecialStack = (ItemStack) tRecipe.mSpecialItems; - // Check if this item is in an input bus. - boolean aDidFindMatch = false; - for (ItemStack aInputItemsToCheck : aItemInputs) { - // If we find a matching stack, continue. - if (GT_Utility.areStacksEqual(aSpecialStack, aInputItemsToCheck, false)) { - // Iterate all special behaviour items, to see if we need to utilise one. - aDidFindMatch = true; - break; - } - } - // Try to prevent needless iteration loops if we don't have the required inputs at all. - if (aDidFindMatch) { - // Iterate all special behaviour items, to see if we need to utilise one. - for (SpecialMultiBehaviour aBehaviours : mCustomBehviours.values()) { - // Found a match, let's adjust this recipe now. - if (aBehaviours.isTriggerItem(aSpecialStack)) { - // Adjust this recipe to suit special item - aMaxParallelRecipes = aBehaviours.getMaxParallelRecipes(); - aEUPercent = aBehaviours.getEUPercent(); - aSpeedBonusPercent = aBehaviours.getSpeedBonusPercent(); - aOutputChanceRoll = aBehaviours.getOutputChanceRoll(); - break; - } - } - } - } - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; - } - - /* - * Here we handle recipe boosting, which grants additional output %'s to recipes that do not have 100%. - */ - - private boolean mHasBoostedCurrentRecipe = false; - private GT_Recipe mBoostedRecipe = null; - private ItemStack[] mInputVerificationForBoosting = null; - - /** - * Does this machine boost it's output? - * - * @return - if true, gives additional % to output chances. - */ - protected boolean doesMachineBoostOutput() { - return false; - } - - private int boostOutput(int aAmount) { - if (aAmount <= 0) { - return 10000; - } - if (aAmount <= 250) { - aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); - } else if (aAmount <= 500) { - aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); - } else if (aAmount <= 750) { - aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); - } else if (aAmount <= 1000) { - aAmount = (aAmount * 2); - } else if (aAmount <= 1500) { - aAmount = (aAmount * 2); - } else if (aAmount <= 2000) { - aAmount = (int) (aAmount * 1.5); - } else if (aAmount <= 3000) { - aAmount = (int) (aAmount * 1.5); - } else if (aAmount <= 4000) { - aAmount = (int) (aAmount * 1.2); - } else if (aAmount <= 5000) { - aAmount = (int) (aAmount * 1.2); - } else if (aAmount <= 7000) { - aAmount = (int) (aAmount * 1.2); - } else if (aAmount <= 9000) { - aAmount = (int) (aAmount * 1.1); - } - return Math.min(10000, aAmount); - } - - public GT_Recipe generateAdditionalOutputForRecipe(GT_Recipe aRecipe) { - AutoMap<Integer> aNewChances = new AutoMap<>(); - for (int chance : aRecipe.mChances) { - aNewChances.put(boostOutput(chance)); - } - GT_Recipe aClone = aRecipe.copy(); - int[] aTemp = new int[aNewChances.size()]; - int slot = 0; - for (int g : aNewChances) { - aTemp[slot] = g; - slot++; - } - aClone.mChances = aTemp; - return aClone; - } - - /** - * Processes recipes but provides a bonus to the output % of items if they are < 100%. - * - * @param aItemInputs - * @param aFluidInputs - * @param aMaxParallelRecipes - * @param aEUPercent - * @param aSpeedBonusPercent - * @param aOutputChanceRoll - * @param aRecipe - * @return - */ - public boolean checkRecipeBoostedOutputs(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, - GT_Recipe aRecipe) { - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = aRecipe != null ? aRecipe - : findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - log("Running checkRecipeGeneric(1)"); - - // First we check whether or not we have an input cached for boosting. - // If not, we set it to the current recipe. - // If we do, we compare it against the current recipe, if thy are the same, we try return a boosted recipe, if - // not, we boost a new recipe. - boolean isRecipeInputTheSame = false; - - // No cached recipe inputs, assume first run. - if (mInputVerificationForBoosting == null) { - mInputVerificationForBoosting = tRecipe.mInputs; - isRecipeInputTheSame = true; - } - // If the inputs match, we are good. - else { - if (tRecipe.mInputs == mInputVerificationForBoosting) { - isRecipeInputTheSame = true; - } else { - isRecipeInputTheSame = false; - } - } - - // Inputs are the same, let's see if there's a boosted version. - if (isRecipeInputTheSame) { - // Yes, let's just set that as the recipe - if (mHasBoostedCurrentRecipe && mBoostedRecipe != null) { - tRecipe = mBoostedRecipe; - } - // We have yet to generate a new boosted recipe - else { - GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); - if (aBoostedRecipe != null) { - mBoostedRecipe = aBoostedRecipe; - mHasBoostedCurrentRecipe = true; - tRecipe = mBoostedRecipe; - } - // Bad boost - else { - mBoostedRecipe = null; - mHasBoostedCurrentRecipe = false; - } - } - } - // We have changed inputs, so we should generate a new boosted recipe - else { - GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); - if (aBoostedRecipe != null) { - mBoostedRecipe = aBoostedRecipe; - mHasBoostedCurrentRecipe = true; - tRecipe = mBoostedRecipe; - } - // Bad boost - else { - mBoostedRecipe = null; - mHasBoostedCurrentRecipe = false; - } - } - - // Bad modify, let's just use the original recipe. - if (!mHasBoostedCurrentRecipe || mBoostedRecipe == null) { - tRecipe = aRecipe != null ? aRecipe - : findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - } - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - Logger.MACHINE_INFO("BAD RETURN - 2"); - return false; - } - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(mMaxProgresstime * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - return true; - } - public boolean isMachineRunning() { boolean aRunning = this.getBaseMetaTileEntity().isActive(); // log("Queried Multiblock is currently running: "+aRunning); @@ -899,33 +494,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex super.explodeMultiblock(); } - protected int getGUICircuit(ItemStack[] t) { - Item g = CI.getNumberedCircuit(0).getItem(); - ItemStack guiSlot = this.mInventory[1]; - int mMode = -1; - if (guiSlot != null && guiSlot.getItem() == g) { - this.mInternalCircuit = true; - return guiSlot.getItemDamage(); - } else { - this.mInternalCircuit = false; - } - - if (!this.mInternalCircuit) { - for (ItemStack j : t) { - if (j.getItem() == g) { - mMode = j.getItemDamage(); - break; - } - } - } - return mMode; - } - - protected ItemStack getGUIItemStack() { - ItemStack guiSlot = this.mInventory[1]; - return guiSlot; - } - protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { boolean result = false; if (this.mInventory[1] == null) { @@ -937,10 +505,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return result; } - protected boolean clearGUIItemSlot() { - return setGUIItemStack(null); - } - public ItemStack findItemInInventory(Item aSearchStack) { return findItemInInventory(aSearchStack, 0); } @@ -1882,74 +1446,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return false; } - public boolean isValidBlockForStructure(IGregTechTileEntity aBaseMetaTileEntity, int aCasingID, boolean canBeHatch, - Block aFoundBlock, int aFoundMeta, Block aExpectedBlock, int aExpectedMeta) { - boolean isHatch = false; - if (aBaseMetaTileEntity != null) { - - // Unsure why this check exists? - /* - * if (aCasingID < 64) { aCasingID = TAE.GTPP_INDEX(aCasingID); } - */ - - isHatch = this.addToMachineList(aBaseMetaTileEntity, aCasingID); - if (isHatch) { - return true; - } else { - int aMetaTileID = aBaseMetaTileEntity.getMetaTileID(); - // Found a controller - if (aMetaTileID >= 750 && aMetaTileID < 1000 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Vanilla Hatches/Busses - else if (aMetaTileID >= 10 && aMetaTileID <= 99 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Adv Mufflers - else if (aMetaTileID >= 30001 && aMetaTileID <= 30009 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Control Core, Super IO - else if (aMetaTileID >= 30020 && aMetaTileID <= 30040 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Auto maint - else if (aMetaTileID == 111 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Data Ports - else if ((aMetaTileID == 131 || aMetaTileID == 132) && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } else { - log("Found meta Tile: " + aMetaTileID); - } - } - } - if (!isHatch) { - if (aFoundBlock == aExpectedBlock && aFoundMeta == aExpectedMeta) { - return true; - } else if (aFoundBlock != aExpectedBlock) { - if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { - log( - "A1 - Found: " + aFoundBlock.getLocalizedName() - + ":" - + aFoundMeta - + ", Expected: " - + aExpectedBlock.getLocalizedName() - + ":" - + aExpectedMeta); - // log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); - } - return false; - } else if (aFoundMeta != aExpectedMeta) { - log("A2"); - return false; - } - } - log("A3"); - return false; - } - @Override public void onServerStart() { super.onServerStart(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java index 2c2412d245..85a3fd4edc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java @@ -2,7 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.util.ArrayList; import java.util.Collections; @@ -14,18 +13,16 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_HatchElementBuilder; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.api.util.IGT_HatchAdder; import gtPlusPlus.api.objects.data.AutoMap; @@ -75,150 +72,14 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu } @Override - public int getEuDiscountForParallelism() { - return 0; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public boolean checkRecipe(ItemStack arg0) { - - log("Running checkRecipeGeneric(0)"); - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - GT_Recipe_Map tMap = this.getRecipeMap(); - if (tMap == null) { - return false; - } - ItemStack[] aItemInputs = tItems.toArray(new ItemStack[0]); - FluidStack[] aFluidInputs = tFluids.toArray(new FluidStack[0]); - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[1], null, null, aItemInputs); - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - int aEUPercent = 100; - int aSpeedBonusPercent = 0; - int aOutputChanceRoll = 10000; - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - int aMaxParallelRecipes = canBufferOutputs( - tRecipe.mOutputs, - tRecipe.mFluidOutputs, - this.getMaxParallelRecipes()); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: " + parallelRecipes); - log("aMaxParallelRecipes: " + aMaxParallelRecipes); - log("tTotalEUt: " + tTotalEUt); - log("tRecipeEUt: " + tRecipeEUt); - - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (32 - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at " + parallelRecipes + "."); - break; - } - log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor * 1.5f); - - this.lEUt = (long) Math.ceil(tTotalEUt * 1.33f); - - // this.mEUt = (3 * tRecipe.mEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = getOutputFluids(tRecipe, parallelRecipes); - - // Collect output item types - ItemStack[] tOutputItems = getOutputItems(tRecipe); - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List<ItemStack> splitStacks = new ArrayList<ItemStack>(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[0]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(V[1]); + logic.setAvailableAmperage(1); } public ArrayList<FluidStack> getAllSteamStacks() { |