diff options
| author | GlodBlock <1356392126@qq.com> | 2021-09-02 10:03:42 +0800 |
|---|---|---|
| committer | GlodBlock <1356392126@qq.com> | 2021-09-02 10:03:42 +0800 |
| commit | eb70ecfef30e18cafd6aca4dfad8b15f1cab6932 (patch) | |
| tree | f8280d2ceb6241dbc9bd68ce95e6ddb01bc606ad /src/main/java | |
| parent | 1e375fdfd71d1a57bcd82ec353798baa37ea02f4 (diff) | |
| download | GT5-Unofficial-eb70ecfef30e18cafd6aca4dfad8b15f1cab6932.tar.gz GT5-Unofficial-eb70ecfef30e18cafd6aca4dfad8b15f1cab6932.tar.bz2 GT5-Unofficial-eb70ecfef30e18cafd6aca4dfad8b15f1cab6932.zip | |
add an option to add integrated circuit to auto generated mix recipes. currently all auto generated mix recipes don't use the circuit, there is going be tons of recipe conflict when bw alloy become more.
Former-commit-id: 2b806369abc68220c6ee8c004829e450bbe2d954
Diffstat (limited to 'src/main/java')
3 files changed, 15 insertions, 203 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java deleted file mode 100644 index cd630ef2c3..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2018-2020 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.tileentities.multis.mega; - -import com.github.bartimaeusnek.bartworks.util.BW_Util; -import gregtech.GT_Mod; -import gregtech.api.enums.GT_Values; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ProcessingArray; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; - -import java.util.ArrayList; -import java.util.List; - -import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.isValidForLowGravity; -@SuppressWarnings("ALL") -public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_ProcessingArray { - private GT_Recipe mLastRecipe; - private int tTier; - private int mMult; - private String mMachine = ""; - private GT_MetaTileEntity_Hatch_InputBus machineBus; - public GT_TileEntity_MegaProcessingArray(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_TileEntity_MegaProcessingArray(String aName) { - super(aName); - } - - public boolean checkRecipe(ItemStack aStack) { - if (!this.isCorrectMachinePart(this.machineBus.mInventory[0])) { - return false; - } - - GT_Recipe.GT_Recipe_Map map = this.getRecipeMap(); - if (map == null) return false; - ArrayList<ItemStack> tInputList = this.getStoredInputs(); - - if (this.mInventory[1].getUnlocalizedName().endsWith("10")) { - this.tTier = 9; - this.mMult = 2;//u need 4x less machines and they will use 4x less power - } else if (this.mInventory[1].getUnlocalizedName().endsWith("11")) { - this.tTier = 9; - this.mMult = 4;//u need 16x less machines and they will use 16x less power - } else if (this.mInventory[1].getUnlocalizedName().endsWith("12") || - this.mInventory[1].getUnlocalizedName().endsWith("13") || - this.mInventory[1].getUnlocalizedName().endsWith("14") || - this.mInventory[1].getUnlocalizedName().endsWith("15")) { - this.tTier = 9; - this.mMult = 6;//u need 64x less machines and they will use 64x less power - } else if (this.mInventory[1].getUnlocalizedName().endsWith("1")) { - this.tTier = 1; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("2")) { - this.tTier = 2; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("3")) { - this.tTier = 3; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("4")) { - this.tTier = 4; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("5")) { - this.tTier = 5; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("6")) { - this.tTier = 6; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("7")) { - this.tTier = 7; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("8")) { - this.tTier = 8; - this.mMult = 0;//*1 - } else if (this.mInventory[1].getUnlocalizedName().endsWith("9")) { - this.tTier = 9; - this.mMult = 0;//*1 - } else { - this.tTier = 0; - this.mMult = 0;//*1 - } - - if (!this.mMachine.equals(this.mInventory[1].getUnlocalizedName())) this.mLastRecipe = null; - this.mMachine = this.mInventory[1].getUnlocalizedName(); - ItemStack[] tInputs = tInputList.toArray(new ItemStack[0]); - - ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); - if (tInputList.size() > 0 || tFluids.length > 0) { - GT_Recipe tRecipe = map.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, gregtech.api.enums.GT_Values.V[this.tTier], tFluids, tInputs); - if (tRecipe != null) { - if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 && - !isValidForLowGravity(tRecipe, this.getBaseMetaTileEntity().getWorld().provider.dimensionId)) - return false; - - this.mLastRecipe = tRecipe; - this.mEUt = 0; - this.mOutputItems = null; - this.mOutputFluids = null; - int machines = Math.min(64, this.mInventory[1].stackSize << this.mMult); //Upped max Cap to 64 - int i = 0; - for (; i < machines; i++) { - if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - if (i == 0) { - return false; - } - break; - } - } - this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - BW_Util.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, map.mAmperage, GT_Values.V[this.tTier], this); - //In case recipe is too OP for that machine - if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) - return false; - this.mEUt = GT_Utility.safeInt(((long) this.mEUt * i) >> this.mMult, 1); - if (this.mEUt == Integer.MAX_VALUE - 1) - return false; - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOut[h] = tRecipe.getOutput(h).copy(); - tOut[h].stackSize = 0; - } - } - FluidStack tFOut = null; - if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); - for (int f = 0; f < tOut.length; f++) { - if (tRecipe.mOutputs[f] != null && tOut[f] != null) { - for (int g = 0; g < i; g++) { - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) - tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - if (tFOut != null) { - int tSize = tFOut.amount; - tFOut.amount = tSize * i; - } - tOut = GT_MetaTileEntity_ProcessingArray.clean(tOut); - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - List<ItemStack> overStacks = new ArrayList<>(); - for (ItemStack itemStack : tOut) { - while (itemStack.getMaxStackSize() < itemStack.stackSize) { - ItemStack tmp = itemStack.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - itemStack.stackSize = itemStack.stackSize - itemStack.getMaxStackSize(); - overStacks.add(tmp); - } - } - if (overStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[overStacks.size()]; - tmp = overStacks.toArray(tmp); - tOut = ArrayUtils.addAll(tOut, tmp); - } - List<ItemStack> tSList = new ArrayList<>(); - for (ItemStack tS : tOut) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOut = tSList.toArray(new ItemStack[0]); - this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[]{tFOut}; - this.updateSlots(); - return true; - }/* else{ - ...remoteRecipeCheck() - }*/ - } - return false; - } - -} 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 16cbee2d2f..107dec62c6 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 @@ -386,6 +386,10 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { return this.mID; } + public short getMixCircuit() { + return this.getGenerationFeatures().mixCircuit; + } + public Werkstoff.GenerationFeatures getGenerationFeatures() { return this.generationFeatures; } @@ -609,6 +613,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { * Auto add MetalWorking(crafting components) Recipe 10000 */ public byte extraRecipes; + public short mixCircuit = -1; public Werkstoff.GenerationFeatures setBlacklist(OrePrefixes p) { this.blacklist |= getPrefixDataRaw(p); @@ -670,6 +675,13 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { return this; } + public Werkstoff.GenerationFeatures addMixerRecipes(short aCircuit) { + this.extraRecipes = (byte) (this.extraRecipes | 10); + if (aCircuit >= 1 && aCircuit <=24) + this.mixCircuit = aCircuit; + return this; + } + public boolean hasMixerRecipes() { return (this.extraRecipes & 10) != 0; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java index 8f79fc85bc..b8b1d7a75e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java @@ -148,6 +148,9 @@ public class DustLoader implements IWerkstoffRunnable { if (werkstoff.getGenerationFeatures().hasMixerRecipes()) { if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); + short circuitID = werkstoff.getMixCircuit(); + ItemStack circuit = circuitID == -1 ? null : GT_Utility.getIntegratedCircuit(circuitID); + if (circuit != null) stOutputs.add(circuit); GT_Recipe.GT_Recipe_Map.sMixerRecipes.add(new BWRecipes.DynamicGTRecipe(true, stOutputs.toArray(new ItemStack[0]), new ItemStack[]{input}, null, null, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, null, (int) Math.max(1L, Math.abs(werkstoff.getStats().getMass() / werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 5, 0)); } } |
