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.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -11,7 +9,6 @@ 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; @@ -20,7 +17,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IndustrialCuttingMachine extends GregtechMeta_MultiBlockBase { @@ -78,53 +74,7 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (final ItemStack tInput : tInputList) { - for (final FluidStack tFluid : tFluidList) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCutterRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tFluid}, new ItemStack[]{tInput}); - //tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 60F); - if (tRecipe != null) { - - //More than or one input - if (tInputList.size() > 0) { - - if (tRecipe.isRecipeInputEqual(true, new FluidStack[]{tFluid}, new ItemStack[]{tInput})) { - 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); - ItemStack[] mOutputStacks = new ItemStack[9]; - for (int i=0;i<9;i++){ - if (tRecipe.getOutput(i) != null){ - mOutputStacks[i] = tRecipe.getOutput(i); - } - } - this.mOutputItems = mOutputStacks.clone(); - //this.updateSlots(); - return true; - } - } - } - } - } - return false; + return checkRecipeGeneric(2, 100, 60); } @Override @@ -217,7 +167,7 @@ extends GregtechMeta_MultiBlockBase { @Override public int getPollutionPerTick(final ItemStack aStack) { - return 80; + return 0; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java index 2334af7cd4..1bc38dee93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -1,11 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; -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; @@ -15,7 +9,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; 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.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -24,7 +17,6 @@ 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_IndustrialElectrolyzer extends GregtechMeta_MultiBlockBase { @@ -81,133 +73,9 @@ extends GregtechMeta_MultiBlockBase { return aFacing > 1; } - ArrayList<ItemStack> tInputList = this.getStoredInputs(); - GT_Recipe mLastRecipe; - - @Override - public boolean checkRecipe(final ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full - 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(), GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.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 Slots: "+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)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 40F); - if ((tRecipe != null) && (7500 >= 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); - - 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 * 1; - } - - 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(); - - /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - updateSlots();*/ - return true; - } - } - 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 == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(2, 100, 40); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java index 5154c36833..0b5441f913 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Random; import gregtech.api.GregTech_API; @@ -26,6 +27,10 @@ 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; +import org.apache.commons.lang3.ArrayUtils; + +import static gtPlusPlus.core.util.array.ArrayUtils.removeNulls; public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_MultiBlockBase { @@ -65,6 +70,11 @@ extends GregtechMeta_MultiBlockBase { } @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(201)); + } + + @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(7)], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_MatterFab_Active : TexturesGtBlock.Overlay_MatterFab)}; @@ -102,76 +112,12 @@ 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(201)), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public boolean checkRecipe(final ItemStack aStack) { - byte tTier = (byte)Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - //int processing = 8*tTier; - int processing = 1; - //Get inputs. - 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; - } - } - } - } - - //Temp var - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + final long tVoltage = getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + final int maxParallelRecipes = Math.max(1, 8 * tTier); - //Don't check the recipe if someone got around the output bus size check. - if (this.mOutputBusses.size() != 5){ - return false; - } - for (int rx=0;rx<processing;rx++){ - //Make a recipe instance for the rest of the method. - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); - tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 60F); - - final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), tRecipe, tInputs); - Logger.WARNING("Maceration Stack - Valid Output Hatches: "+tValidOutputSlots); - - //More than or one input - if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) { - if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { - if (processRecipeXTimes(processing, tRecipe)){ - - //final ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; - - - - //this.mOutputItems = outputs; - this.mEfficiency = (10000 - ((getIdealStatus() - getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - - this.mEUt = (-4 * (1 << tTier - 1) * (1 << tTier - 1) * tTier / 2); - this.mMaxProgresstime = Math.max(1, 256 / (1 << tTier - 1)); - } - //this.mMaxProgresstime = Math.max(1, (tRecipe.mDuration)); - this.sendLoopStart((byte) 20); - this.updateSlots(); - } - } - } - return false; + return checkRecipeGeneric(maxParallelRecipes, 100, 60, 7500); } @Override @@ -262,29 +208,4 @@ extends GregtechMeta_MultiBlockBase { return true; } - private boolean processRecipeXTimes(int times, GT_Recipe tRecipe){ - - byte tTier = (byte)Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - int j = 0; - this.mOutputItems = new ItemStack[8 * tTier]; - - for (int i = 0; (i < 256) && (j < this.mOutputItems.length); ++i) { - if (i==0) { - Logger.WARNING("Adding the default output"); - this.mOutputItems[0] = tRecipe.getOutput(0); - Logger.INFO("Ading output. "+i+" | "+tRecipe.mOutputs.length + " | "+this.mOutputItems[0].stackSize+" | "+tRecipe.getOutput(0).stackSize); - } - else if (this.getBaseMetaTileEntity().getRandomNumber(7500) < tRecipe.getOutputChance(i)){ - Logger.WARNING("Adding a bonus output"); - this.mOutputItems[i] = tRecipe.getOutput(i); - } - else { - Logger.WARNING("Adding null output"); - this.mOutputItems[i] = null; - } - ++j; - } - updateSlots(); - return true; - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java index 33c73e0a82..209bbb3728 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java @@ -1,18 +1,15 @@ 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; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; 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.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -23,8 +20,11 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import java.util.ArrayList; + public class GregtechMetaTileEntity_IndustrialPlatePress extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -43,18 +43,24 @@ extends GregtechMeta_MultiBlockBase { return new String[]{"Controller Block for the Material Press", "50% faster than using single block machines of the same voltage", "Circuit for recipe goes in the Input Bus", + "Each Input Bus can have a different Circuit!", "Size: 3x3x3 (Hollow)", "Controller (front centered)", "1x Input Bus (anywhere)", "1x Output Bus (anywhere)", "1x Energy Hatch (anywhere)", "1x Maintenance Hatch (anywhere)", - "1x Muffler (anywhere)", + "1x Muffler Hatch (anywhere)", "Material Press Machine Casings for the rest (16 at least!)", CORE.GT_Tooltip}; } @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(203)); + } + + @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(4)], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; @@ -78,77 +84,26 @@ extends GregtechMeta_MultiBlockBase { } @Override - public boolean checkRecipe(final ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full - 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(), GT_Recipe.GT_Recipe_Map.sBenderRecipes.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 Slots: "+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)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 50F); - if ((tRecipe != null) && (2500 >= 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); + public boolean checkRecipe(final ItemStack aStack) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - this.updateSlots(); - return true; } + + if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), new FluidStack[]{}, + 2, 100, 50, 10000)) return true; } 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 == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } + public void startProcess() { + this.sendLoopStart((byte) 1); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java index ea6bb3eeba..6915b4c5ba 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java @@ -1,9 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Random; - import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -13,11 +9,9 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; 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 net.minecraft.block.Block; @@ -25,6 +19,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import java.util.Random; + public class GregtechMetaTileEntity_IndustrialSifter extends GregtechMeta_MultiBlockBase { private boolean controller; @@ -46,6 +42,8 @@ extends GregtechMeta_MultiBlockBase { public String[] getDescription() { return new String[]{ "Controller Block for the Industrial Sifter", + "400% faster than single-block machines of the same voltage", + "Increased output chances", "Size[WxHxL]: 5x3x5", "Controller (Center Bottom)", "1x Input Bus (Any top or bottom edge casing)", @@ -89,163 +87,24 @@ extends GregtechMeta_MultiBlockBase { public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - if (MathUtils.randInt(0, 5) == 5){ - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("reddust", (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); - } - } - } + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + if (tRandom.nextFloat() > 0.4) return; - @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(201)), 10, 1.0F, aX, aY, aZ); - } - } + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } + aBaseMetaTileEntity.getWorld().spawnParticle("smoke", + (aBaseMetaTileEntity.getXCoord() + xDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + aBaseMetaTileEntity.getYCoord() + 2.5f + (tRandom.nextFloat() * 1.2F), + (aBaseMetaTileEntity.getZCoord() + zDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + 0.0, 0.0, 0.0); - ItemStack[] mInputStacks; - int[] cloneChances; - GT_Recipe baseRecipe; - GT_Recipe cloneRecipe; + } + } @Override public boolean checkRecipe(final ItemStack aStack) { - - Logger.WARNING("1"); - - //Get inputs. - 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; - } - } - } - } - - Logger.WARNING("2"); - - //Temp var - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - //Don't check the recipe if someone got around the output bus size check. - if (this.mOutputBusses.size() != 4){ - return false; - } - - - Logger.WARNING("3"); - - //Make a recipe instance for the rest of the method. - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sSifterRecipes.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); - - if (tRecipe != null) { - this.baseRecipe = tRecipe.copy(); - } - - if ((this.cloneRecipe != tRecipe) || (this.cloneRecipe == null)){ - this.cloneRecipe = tRecipe.copy(); - Logger.WARNING("Setting Recipe"); - } - if ((this.mInputStacks != tRecipe.mInputs) || (this.mInputStacks == null)){ - this.mInputStacks = tRecipe.mInputs; - Logger.WARNING("Setting Recipe Inputs"); - } - if ((this.cloneChances != tRecipe.mChances) || (this.cloneChances == null)){ - this.cloneChances = tRecipe.mChances.clone(); - Logger.WARNING("Setting Chances"); - } - - for (int r=0;r<this.cloneChances.length;r++){ - Logger.WARNING("Original map Output["+r+"] chance = "+this.cloneChances[r]); - } - - Logger.WARNING("3.1"); - - //Change bonus chances - int[] outputChances; - - Logger.WARNING("3.2"); - - if (this.cloneRecipe.mChances != null){ - outputChances = this.cloneRecipe.mChances.clone(); - - Logger.WARNING("3.3"); - - for (int r=0;r<outputChances.length;r++){ - Logger.WARNING("Output["+r+"] chance = "+outputChances[r]); - if (outputChances[r]<10000){ - final int temp = outputChances[r]; - if ((outputChances[r] < 8000) && (outputChances[r] >= 1)){ - outputChances[r] = temp+1200; - Logger.WARNING("Output["+r+"] chance now = "+outputChances[r]); - } - else if ((outputChances[r] < 9000) && (outputChances[r] >= 8000)){ - outputChances[r] = temp+400; - Logger.WARNING("Output["+r+"] chance now = "+outputChances[r]); - } - else if ((outputChances[r] <= 9900) && (outputChances[r] >= 9000)){ - outputChances[r] = temp+100; - Logger.WARNING("Output["+r+"] chance now = "+outputChances[r]); - } - } - } - - Logger.WARNING("3.4"); - - //Rebuff Drop Rates for % output - this.cloneRecipe.mChances = outputChances; - - } - - - Logger.WARNING("4"); - - - final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), this.cloneRecipe, tInputs); - Logger.WARNING("Sifter - Valid Output Hatches: "+tValidOutputSlots); - - //More than or one input - if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) { - if ((this.cloneRecipe != null) && (this.cloneRecipe.isRecipeInputEqual(true, null, tInputs))) { - Logger.WARNING("Valid Recipe found - size "+this.cloneRecipe.mOutputs.length); - this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - - - this.mEUt = (-this.cloneRecipe.mEUt); - this.mMaxProgresstime = Math.max(1, (this.cloneRecipe.mDuration/5)); - final ItemStack[] outputs = new ItemStack[this.cloneRecipe.mOutputs.length]; - for (int i = 0; i < this.cloneRecipe.mOutputs.length; i++){ - if (this.getBaseMetaTileEntity().getRandomNumber(7500) < this.cloneRecipe.getOutputChance(i)){ - Logger.WARNING("Adding a bonus output"); - outputs[i] = this.cloneRecipe.getOutput(i); - } - else { - Logger.WARNING("Adding null output"); - outputs[i] = null; - } - } - - this.mOutputItems = outputs; - this.sendLoopStart((byte) 20); - this.updateSlots(); - //tRecipe.mChances = baseRecipe.mChances; - return true; - } - } - return false; + return checkRecipeGeneric(2, 100, 400, 8800); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java index 64a36900fe..3c09f3425a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -10,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.GT_Recipe; -import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; @@ -79,55 +76,7 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (final ItemStack tInput : tInputList) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); - tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 60F); - if (tRecipe != null) { - - final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), tRecipe, new ItemStack[]{tInput}); - Logger.WARNING("Valid Output Slots: "+tValidOutputSlots); - //More than or one input - if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) { - - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { - 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); - - ItemStack mNewOutputs[] = new ItemStack[16]; - - - - for (int f=0;f<tRecipe.mOutputs.length;f++){ - mNewOutputs[f] = tRecipe.getOutput(f); - } - - this.mOutputItems = mNewOutputs; - this.updateSlots(); - return true; - } - } - } - } - return false; + return checkRecipeGeneric(2, 100, 60); } @Override @@ -140,26 +89,28 @@ extends GregtechMeta_MultiBlockBase { int tAmount = 0; for (int i = -1; i < 2; ++i) { for (int j = -1; j < 2; ++j) { - for (int h = -1; h < 0; ++h) { - if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, - zDir + j); - - Logger.INFO("------------------"); - Logger.INFO("xDir: "+xDir+" | zDir: "+zDir); - Logger.INFO("i: "+i+" | j: "+j+" | h: "+h); - if (!addToMachineList(tTileEntity)) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if ((((tBlock != ModBlocks.blockCasings2Misc) || (tMeta != 0))) - && (((tBlock != GregTech_API.sBlockCasings3) || (tMeta != 9)))) { - Logger.INFO("Wrong Block?"); - return false; - } - tAmount++; + for (int h = -1; h < 1; ++h) { + if ((xDir + i == 0) && (zDir + j == 0) && (h == 0)) continue; // controller block + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, + zDir + j); + + Logger.INFO("------------------"); + Logger.INFO("xDir: " + xDir + " | zDir: " + zDir); + Logger.INFO("i: " + i + " | j: " + j + " | h: " + h); + if ((h == 0) || !addToMachineList(tTileEntity)) { // only bottom layer allows machine parts + // top layer, or not machine part, must be casing + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if ((((tBlock != ModBlocks.blockCasings2Misc) || (tMeta != 0))) + && (((tBlock != GregTech_API.sBlockCasings3) || (tMeta != 9)))) { + Logger.INFO("Wrong Block?"); + return false; } + tAmount++; } } + } } Logger.INFO("------------------"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java index fce26484d0..2c9a332dae 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java @@ -1,6 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -8,12 +7,10 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; 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.fluid.FluidUtils; -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 ic2.core.init.BlocksItems; @@ -28,7 +25,6 @@ import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IndustrialWashPlant extends GregtechMeta_MultiBlockBase { - public GT_Recipe mLastRecipe; public GregtechMetaTileEntity_IndustrialWashPlant(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -86,70 +82,8 @@ extends GregtechMeta_MultiBlockBase { } @Override - public boolean checkRecipe(final ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full - ArrayList<ItemStack> tInputList = getStoredInputs(); - ArrayList<FluidStack> tFluidInputs = getStoredFluids(); - for (ItemStack tInput : tInputList) { - - if (tInput.stackSize >= 2){ - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sOreWasherRecipes.findRecipe(getBaseMetaTileEntity(), this.mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluidInputs.isEmpty() ? null : new FluidStack[]{tFluidInputs.get(0)}, new ItemStack[]{tInput}); - - if ((tRecipe == null && !mRunningOnLoad)) { - this.mLastRecipe = null; - return false; - } - - if (tRecipe != null) { - FluidStack[] mFluidInputList = new FluidStack[tFluidInputs.size()]; - int tri = 0; - for (FluidStack f : tFluidInputs){ - mFluidInputList[tri] = f; - tri++; - } - if (tRecipe.isRecipeInputEqual(true, mFluidInputList, tInput)) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - this.mEUt = tRecipe.mEUt; - - 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); - - if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, mFluidInputList, new ItemStack[]{tInput})) { - Logger.WARNING("Recipe Complete."); - this.mLastRecipe = tRecipe; - this.mEUt = MathUtils.findPercentageOfInt(this.mLastRecipe.mEUt, 80); - this.mMaxProgresstime = MathUtils.findPercentageOfInt(this.mLastRecipe.mDuration, 20); - this.mEfficiencyIncrease = 10000; - this.addOutput(tRecipe.getOutput(0)); - this.addOutput(tRecipe.getOutput(0)); - this.addOutput(tRecipe.getOutput(1)); - this.addOutput(tRecipe.getOutput(1)); - mRunningOnLoad = false; - this.updateSlots(); - return true; - } - - } - } - } - } - return false; + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(2, 100, 80); } @Override @@ -246,7 +180,7 @@ extends GregtechMeta_MultiBlockBase { @Override public int getPollutionPerTick(final ItemStack aStack) { - return 20; + return 0; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java index ece7740394..5cad86bdc4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java @@ -1,7 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - +import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -11,11 +10,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 net.minecraft.block.Block; @@ -53,6 +50,11 @@ extends GregtechMeta_MultiBlockBase { } @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(204)); + } + + @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(6)], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; @@ -77,46 +79,7 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (final ItemStack tInput : tInputList) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); - tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 60F); - if (tRecipe != null) { - - final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), tRecipe, new ItemStack[]{tInput}); - Logger.WARNING("Valid Output Slots: "+tValidOutputSlots); - //More than or one input - if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) { - - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { - 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.updateSlots(); - return true; - } - } - } - } - return false; + return checkRecipeGeneric(2, 100, 60); } @Override |