diff options
| author | Alkalus <draknyte1@hotmail.com> | 2018-01-29 19:14:43 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-29 19:14:43 +1000 |
| commit | 0d44c0b8810bda7a6d16b7a3aa27affa28f648f2 (patch) | |
| tree | db3ece2aded1ee760c2b91a8b1d6a6300a15abf6 /src/Java/gtPlusPlus/xmod/gregtech | |
| parent | e56eccacee3e865638b0e6f0652d2ff1009c184f (diff) | |
| parent | f0b2da3cc57441dc5ef468c33a68788b47f073b2 (diff) | |
| download | GT5-Unofficial-0d44c0b8810bda7a6d16b7a3aa27affa28f648f2.tar.gz GT5-Unofficial-0d44c0b8810bda7a6d16b7a3aa27affa28f648f2.tar.bz2 GT5-Unofficial-0d44c0b8810bda7a6d16b7a3aa27affa28f648f2.zip | |
Merge pull request #196 from codewarrior0/refactor-check-recipe
$ Rewrite and refactor checkRecipe() for several multiblocks, restore machine sounds
$ Fixes #182.
$ Fixes #183.
$ Fixes #184.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech')
13 files changed, 306 insertions, 980 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 3a79b2a446..0447cbcd20 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -3,8 +3,12 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; import java.lang.reflect.*; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; -import org.apache.commons.lang3.reflect.FieldUtils; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_Utility; +import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -14,7 +18,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.*; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.PollutionUtils; import gtPlusPlus.core.util.math.MathUtils; @@ -27,11 +30,14 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import static gtPlusPlus.core.util.array.ArrayUtils.removeNulls; + public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_MultiBlockBase { - public static boolean disableMaintenance; + public GT_Recipe mLastRecipe; + public ArrayList<GT_MetaTileEntity_Hatch_InputBattery> mChargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_InputBattery>(); public ArrayList<GT_MetaTileEntity_Hatch_OutputBattery> mDischargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_OutputBattery>(); @@ -97,45 +103,215 @@ GT_MetaTileEntity_MultiBlockBase { @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(getSound(), 10, 1.0F, aX, aY, aZ); + } } public void startProcess() { + if(GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); } - public int getValidOutputSlots(final IGregTechTileEntity machineCalling, - final GT_Recipe sRecipes, final ItemStack[] sInputs) { - Logger.WARNING("Finding valid output slots for " - + machineCalling.getInventoryName()); - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - final GT_Recipe tRecipe = sRecipes; - final int outputItemCount = tRecipe.mOutputs.length; - int tValidOutputHatches = 0; + public String getSound() { return ""; } - for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { - if (!isValidMetaTileEntity(tHatch)) { + public boolean canBufferOutputs(final GT_Recipe aRecipe) { + // Count slots available in hatches + int tEmptySlots = 0; + for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { + if (!isValidMetaTileEntity(tBus)) { continue; } + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + tEmptySlots++; + } + } + } - int tEmptySlots = 0; - boolean foundRoom = false; - final IInventory tHatchInv = tHatch.getBaseMetaTileEntity(); - for (int i = 0; (i < tHatchInv.getSizeInventory()) - && !foundRoom; ++i) { - if (tHatchInv.getStackInSlot(i) != null) { - continue; + // TODO: Check if any of the output stacks can stack with the stacks in the hatches? + // Enough open slots? + if (tEmptySlots < aRecipe.mOutputs.length) return false; + + // For each output fluid, make sure an output hatch can accept it. + for (FluidStack tRecipeFluid: aRecipe.mFluidOutputs) { + boolean tCanBufferFluid = false; + int tRecipeAmount = tRecipeFluid.amount; + for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { + FluidStack tHatchFluid = tHatch.getFluid(); + if (tHatchFluid == null) { + if(tHatch.getCapacity() > tRecipeAmount) { + tCanBufferFluid = true; + break; + } } + else if (tHatchFluid.isFluidEqual(tRecipeFluid) && tHatch.getCapacity() - tHatchFluid.amount > tRecipeAmount) { + tCanBufferFluid = true; + break; + } + } + if (!tCanBufferFluid) return false; + } + return true; + } + + public boolean checkRecipeGeneric() { + return checkRecipeGeneric(1, 100, 0); + } + + public boolean checkRecipeGeneric(int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent) { + return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); + } + + public boolean checkRecipeGeneric(int aMaxParallelRecipes, int 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( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + + + // Based on the Processing Array. A bit overkill, but very flexible. + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + int parallelRecipes = 0; + + GT_Recipe tRecipe = this.getRecipeMap().findRecipe( + getBaseMetaTileEntity(), mLastRecipe, 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; + } + + if (!this.canBufferOutputs(tRecipe)) { + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + break; + } + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + return false; + } + + // 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); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } - tEmptySlots++; - if (tEmptySlots < outputItemCount) { - continue; + // 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); - tValidOutputHatches++; - foundRoom = true; + // 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); } } - return tValidOutputHatches; + 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[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + return true; } public GT_Recipe reduceRecipeTimeByPercentage(final GT_Recipe tRecipe, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java index ebee8b2f17..797875f2f6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -61,6 +61,11 @@ extends GregtechMeta_MultiBlockBase { } @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(208)); + } + + @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == aFacing) { return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(15)], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; @@ -84,19 +89,6 @@ extends GregtechMeta_MultiBlockBase { } @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(GregTech_API.sSoundList.get(Integer.valueOf(208)), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public boolean isFacingValid(final byte aFacing) { return aFacing > 1; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java index 6bda53def5..4f276dfb37 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java @@ -28,7 +28,6 @@ import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBase { - public GT_Recipe mLastRecipe; public int mEUStore; public GregtechMetaTileEntity_Cyclotron(int aID, String aName, String aNameRegional, int tier) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java index 498e8ae17c..c139f8a7e8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -1,11 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -15,11 +9,9 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; @@ -27,11 +19,9 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_MultiBlockBase { - private static boolean controller; private static ITexture frontFace; private static ITexture frontFaceActive; private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); @@ -71,14 +61,11 @@ extends GregtechMeta_MultiBlockBase { CORE.GT_Tooltip}; } - - @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? frontFaceActive : frontFace : Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(0)]}; } - @Override public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "IndustrialCentrifuge.png"); @@ -94,129 +81,9 @@ extends GregtechMeta_MultiBlockBase { return aFacing > 1; } - ArrayList<ItemStack> tInputList = this.getStoredInputs(); - GT_Recipe mLastRecipe; - @Override public boolean checkRecipe(final ItemStack aStack) { - /*if (!isCorrectMachinePart(mInventory[1])) { - return false; - }*/ - - Logger.WARNING("Centrifuge Debug - 1"); - final GT_Recipe.GT_Recipe_Map map = this.getRecipeMap(); - if (map == null) { - Logger.WARNING("Centrifuge Debug - False - No recipe map"); - return false; - } - Logger.WARNING("Centrifuge Debug - 2"); - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - Logger.WARNING("Centrifuge Debug - Tier variable: "+tTier); - final ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - final FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); - if ((tInputList.size() > 0) || (tFluids.length > 0)) { - GT_Recipe tRecipe = map.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 40F); - if (tRecipe != null) { - Logger.WARNING("Recipe was not invalid"); - this.mLastRecipe = tRecipe; - this.mEUt = 0; - this.mOutputItems = null; - this.mOutputFluids = null; - if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - - Logger.WARNING("False: 1"); - return false; - } - - this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - Logger.WARNING("Centrifuge Debug - 2 - Max Progress Time: "+this.mMaxProgresstime); - if (tRecipe.mEUt <= 16) { - Logger.WARNING("Centrifuge Debug - Using < 16eu/t"); - this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); - Logger.WARNING("Centrifuge Debug - 3.1 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); - } else { - Logger.WARNING("Centrifuge Debug - using > 16eu/t"); - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - Logger.WARNING("Centrifuge Debug - 3.2 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - Logger.WARNING("Centrifuge Debug - 4 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); - } - } - this.mEUt *= 1; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - Logger.WARNING("Centrifuge Debug - 5 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); - } - ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - 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 < 1; g++) { - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) { - tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - } - if (tFOut != null) { - final int tSize = tFOut.amount; - tFOut.amount = tSize * 6; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mMaxProgresstime /= 4; - if (this.mMaxProgresstime <= 0){ - this.mMaxProgresstime++; - } - Logger.WARNING("Centrifuge Debug - 6 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); - final List<ItemStack> overStacks = new ArrayList<>(); - for (int f = 0; f < tOut.length; f++) { - if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - final ItemStack tmp = tOut[f].copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); - overStacks.add(tmp); - } - } - } - if (overStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[overStacks.size()]; - tmp = overStacks.toArray(tmp); - tOut = ArrayUtils.addAll(tOut, tmp); - } - final List<ItemStack> tSList = new ArrayList<>(); - for (final ItemStack tS : tOut) { - if (tS.stackSize > 0) { - tSList.add(tS); - } - } - tOut = tSList.toArray(new ItemStack[tSList.size()]); - this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[]{tFOut}; - this.updateSlots(); - Logger.WARNING("Centrifuge: True"); - return true; - } - } - Logger.WARNING("Centrifuge: Recipe was invalid."); - return false; + return checkRecipeGeneric(4, 100, 40); } @SuppressWarnings("static-method") @@ -244,9 +111,8 @@ extends GregtechMeta_MultiBlockBase { return false; }*/ final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY; final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - //Utils.LOG_WARNING("X:"+xDir+" Y:"+yDir+" Z:"+zDir); + //Utils.LOG_WARNING("X:"+xDir+" Z:"+zDir); if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { return false; } @@ -292,14 +158,6 @@ extends GregtechMeta_MultiBlockBase { return tAmount >= 16; } - @SuppressWarnings("static-method") - public boolean ignoreController(final Block tTileEntity) { - if (!controller && (tTileEntity == GregTech_API.sBlockMachines)) { - return true; - } - return false; - } - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java index b763d424c9..a4add1ed45 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -11,7 +8,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.*; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -19,7 +15,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IndustrialCokeOven extends GregtechMeta_MultiBlockBase { @@ -42,6 +37,8 @@ extends GregtechMeta_MultiBlockBase { public String[] getDescription() { return new String[]{"Processes Logs and Coal into Charcoal and Coal Coke.", "Controller Block for the Industrial Coke Oven", + "Process 12x materials with Heat Resistant Casings", + "Or 24x materials with Heat Proof Casings", "Size: 3x3x3 (Hollow)", "Controller (front middle at bottom)", "8x Heat Resistant/Proof Coke Oven Casings (middle Layer, hollow)", @@ -49,7 +46,7 @@ extends GregtechMeta_MultiBlockBase { "1x Output Hatch (one of bottom)", "1x Input Bus (one of bottom)", "1x Output Bus (one of bottom)", - "1x Energy Hatch (one of bottom)", + "1x Energy Hatch (one of bottom) [EV or better recommended]", "1x Maintenance Hatch (one of bottom)", "1x Muffler Hatch (top middle)", "Structural Coke Oven Casings for the rest", @@ -57,6 +54,11 @@ extends GregtechMeta_MultiBlockBase { } @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == aFacing) { return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(1)], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; @@ -74,19 +76,6 @@ extends GregtechMeta_MultiBlockBase { return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(207)), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public void startProcess() { - sendLoopStart((byte) 1); -} /* @Override public boolean isCorrectMachinePart(ItemStack aStack) { @@ -100,96 +89,8 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < (tInputList.size() - 1); i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < (tFluidList.size() - 1); i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - - final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[(byte) Math.max(1, GT_Utility.getTier(this.getMaxInputVoltage()))], tFluids, tInputs), tInputs); - Logger.WARNING("Valid Output Hatches: "+tValidOutputSlots); - - //More than or one input - if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if ((tRecipe != null) && (this.mLevel >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; - this.updateSlots(); - //Utils.LOG_INFO("Coke oven: True"); - return true; - } - } - //Utils.LOG_INFO("Coke oven: False"); - return false; + return checkRecipeGeneric(this.mLevel * 12, 100, 0); } - /*public boolean checkRecipe(ItemStack aStack) { - ArrayList<ItemStack> tInputList = getStoredInputs(); - if (!tInputList.isEmpty()) { - byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - - int j = 0; - this.mOutputItems = new ItemStack[12 * this.mLevel]; - for (int i = 0; (i < 100) && (j < this.mOutputItems.length); i++) { - if (null != (this.mOutputItems[j] = GT_ModHandler.getSmeltingOutput((ItemStack) tInputList.get(i % tInputList.size()), true, null))) { - j++; - } - } - if (j > 0) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - this.mEUt = (-4 * (1 << tTier - 1) * (1 << tTier - 1) * this.mLevel); - this.mMaxProgresstime = Math.max(1, 512 / (1 << tTier - 1)); - } - updateSlots(); - return true; - } - return false; - }*/ @Override public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { @@ -212,7 +113,6 @@ extends GregtechMeta_MultiBlockBase { default: return false; } - this.mOutputItems = new ItemStack[12 * this.mLevel]; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if ((i != 0) || (j != 0)) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java index 3b86b348ad..37aa33d246 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - import gregtech.api.en |
