From 9d7ea595609228d8341c0dc7c9a7461153d764bb Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 19 Sep 2017 17:30:43 +1000 Subject: $ Re-did some recipe handling, several different multi-blocks now give the correct outputs. Fixes #68. --- .../base/GregtechMeta_MultiBlockBase.java | 2 +- ...regtechMetaTileEntity_IndustrialCentrifuge.java | 161 +++++-------- ...MetaTileEntity_IndustrialThermalCentrifuge.java | 15 +- ...GregtechMetaTileEntity_IndustrialWashPlant.java | 264 ++++++++++++--------- 4 files changed, 233 insertions(+), 209 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') 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 fa551407ce..5949d008ff 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 @@ -937,7 +937,7 @@ public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity { } public int getValidOutputSlots(final IGregTechTileEntity machineCalling, final GT_Recipe sRecipes, final ItemStack[] sInputs){ - Utils.LOG_INFO("Finding valid output slots for "+machineCalling.getInventoryName()); + //Utils.LOG_INFO("Finding valid output slots for "+machineCalling.getInventoryName()); try{ 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 7a35f63605..5dedad1aee 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 @@ -57,7 +57,7 @@ extends GregtechMeta_MultiBlockBase { public String[] getDescription() { return new String[]{ "Controller Block for the Industrial Centrifuge", - "40% faster than using single block machines of the same voltage", + "50% faster than using single block machines of the same voltage", "Size: 3x3x3 (Hollow)", "Controller (Front Center) [Orange]", "1x Maintenance Hatch (Rear Center) [Green]", @@ -99,123 +99,90 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(final ItemStack aStack) { - /*if (!isCorrectMachinePart(mInventory[1])) { - return false; - }*/ - - Utils.LOG_WARNING("Centrifuge Debug - 1"); - final GT_Recipe.GT_Recipe_Map map = this.getRecipeMap(); - if (map == null) { - Utils.LOG_WARNING("Centrifuge Debug - False - No recipe map"); - return false; + ArrayList tInputList = getStoredInputs(); + int tInputList_sS = tInputList.size(); + for (int i = 0; i < tInputList_sS - 1; ++i) { + for (int j = i + 1; j < tInputList_sS; ++j) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + tInputList_sS = tInputList.size(); + } else { + tInputList.remove(i--); + tInputList_sS = tInputList.size(); + break; + } + } + } } - Utils.LOG_WARNING("Centrifuge Debug - 2"); - final ArrayList tInputList = this.getStoredInputs(); - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - Utils.LOG_WARNING("Centrifuge Debug - Tier variable: "+tTier); - final ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); - final ArrayList 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) { - Utils.LOG_WARNING("Recipe was not invalid"); - this.mLastRecipe = tRecipe; - this.mEUt = 0; - this.mOutputItems = null; - this.mOutputFluids = null; - if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - - Utils.LOG_WARNING("False: 1"); - return false; + ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); + + ArrayList tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; ++i) { + for (int j = i + 1; j < tFluidList_sS; ++j) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } } - - this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); + } + } + FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.findRecipe(getBaseMetaTileEntity(), false, + gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 50F); + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - ((getIdealStatus() - getRepairStatus()) * 1000)); this.mEfficiencyIncrease = 10000; - Utils.LOG_WARNING("Centrifuge Debug - 2 - Max Progress Time: "+this.mMaxProgresstime); + int tHeatCapacityDivTiers = (tRecipe.mSpecialValue) + 2; if (tRecipe.mEUt <= 16) { - Utils.LOG_WARNING("Centrifuge Debug - Using < 16eu/t"); - this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); - Utils.LOG_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)]); + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); } else { - Utils.LOG_WARNING("Centrifuge Debug - using > 16eu/t"); this.mEUt = tRecipe.mEUt; this.mMaxProgresstime = tRecipe.mDuration; - Utils.LOG_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)]); + int i = 2; while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; - this.mMaxProgresstime /= 2; - Utils.LOG_WARNING("Centrifuge Debug - 4 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); + this.mMaxProgresstime /= ((tHeatCapacityDivTiers >= i) ? 4 : 2); + i += 2; } } - this.mEUt *= 1; + if (tHeatCapacityDivTiers > 0) + this.mEUt = (int) (this.mEUt * Math.pow(0.95D, tHeatCapacityDivTiers)); if (this.mEUt > 0) { this.mEUt = (-this.mEUt); - Utils.LOG_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++; - } - Utils.LOG_WARNING("Centrifuge Debug - 6 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); - final List 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); - } + + ItemStack mNewOutputs[] = new ItemStack[tRecipe.mOutputs.length]; + + for (int i = 0; i < tRecipe.mOutputs.length; i++){ + if (this.getBaseMetaTileEntity().getRandomNumber(7500) < tRecipe.getOutputChance(i)){ + //Utils.LOG_INFO("Adding a bonus output | "+tRecipe.getOutputChance(i)); + mNewOutputs[i] = tRecipe.getOutput(i); } - } - if (overStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[overStacks.size()]; - tmp = overStacks.toArray(tmp); - tOut = ArrayUtils.addAll(tOut, tmp); - } - final List tSList = new ArrayList<>(); - for (final ItemStack tS : tOut) { - if (tS.stackSize > 0) { - tSList.add(tS); + else { + //Utils.LOG_INFO("Adding null output"); + mNewOutputs[i] = null; } } - tOut = tSList.toArray(new ItemStack[tSList.size()]); - this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[]{tFOut}; - this.updateSlots(); - Utils.LOG_WARNING("Centrifuge: True"); + + this.mOutputItems = mNewOutputs; + this.mOutputFluids = new FluidStack[] { tRecipe.getFluidOutput(0) }; + updateSlots(); return true; } } - Utils.LOG_WARNING("Centrifuge: Recipe was invalid."); return false; } 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 2f61156653..c4f5c8df41 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 @@ -43,7 +43,7 @@ extends GregtechMeta_MultiBlockBase { public String[] getDescription() { return new String[]{ "Controller Block for the Industrial Thermal Centrifuge", - "40% faster than using single block machines of the same voltage", + "60% faster than using single block machines of the same voltage", "Size: 3x2x3 [WxLxH] (Hollow)", "Controller (front centered)", "1x Input Bus (Any casing)", "1x Output Bus (Any casing)", @@ -88,7 +88,7 @@ extends GregtechMeta_MultiBlockBase { 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, 40F); + tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 60F); if (tRecipe != null) { final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), tRecipe, new ItemStack[]{tInput}); @@ -114,7 +114,16 @@ extends GregtechMeta_MultiBlockBase { this.mEUt = (-this.mEUt); } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + + ItemStack mNewOutputs[] = new ItemStack[16]; + + + + for (int f=0;f 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 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--); + + ArrayList tInputList = getStoredInputs(); + ArrayList tFluidInputs = getStoredFluids(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sOreWasherRecipes.findRecipe(getBaseMetaTileEntity(), false, + gregtech.api.enums.GT_Values.V[tTier], + new FluidStack[] { (tFluidInputs.isEmpty()) ? null : (FluidStack) tFluidInputs.get(0) }, + new ItemStack[] { tInput }); + if (tRecipe != null) { + 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 { - tFluidList.remove(i--); - break; + 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; + } } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - - Utils.LOG_INFO("0"); - final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), GT_Recipe.GT_Recipe_Map.sOreWasherRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[(byte) Math.max(1, GT_Utility.getTier(this.getMaxInputVoltage()))], tFluids, tInputs), tInputs); - Utils.LOG_INFO("Valid Output Slots: "+tValidOutputSlots); - - //More than or one input - if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) { - Utils.LOG_INFO("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.sOreWasherRecipes.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); } - } - 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; - } + this.mMaxProgresstime = (this.mMaxProgresstime * 2 / (1 + 3)); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + if (tRecipe.mOutputs.length > 0){ + //this.mOutputItems = new ItemStack[] { tRecipe.getOutput(0) }; + ItemStack mNewOutputs[] = new ItemStack[tRecipe.mOutputs.length]; + for (int f=0;f 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 (tRecipe.mFluidOutputs.length >= 0){ + //this.mOutputFluids = new FluidStack[] { tRecipe.getFluidOutput(0) }; + FluidStack outputFluids[] = new FluidStack[1]; + if (true){ + Utils.LOG_INFO("Adding Sludge"); + outputFluids[0] = FluidUtils.getFluidStack("fluid.sludge", 100); + } + this.mOutputFluids = outputFluids; + updateSlots(); } - } - if (overStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[overStacks.size()]; - tmp = overStacks.toArray(tmp); - tOut = ArrayUtils.addAll(tOut, tmp); - } - final List 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; - } + updateSlots(); + return true; + } } return false; } @@ -436,7 +382,109 @@ extends GregtechMeta_MultiBlockBase { else { Utils.LOG_WARNING("Did not fill structure."); } + this.mFilledCount = tAmount; return (tAmount >= 45); } + public boolean removeWater() { + + //Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + if (mDirectionX == 0){ + mCurrentDirectionX = 2; + mCurrentDirectionZ = 3; + mOffsetX_Lower = -2; + mOffsetX_Upper = 2; + mOffsetZ_Lower = -3; + mOffsetZ_Upper = 3; + } + else { + mCurrentDirectionX = 3; + mCurrentDirectionZ = 2; + mOffsetX_Lower = -3; + mOffsetX_Upper = 3; + mOffsetZ_Lower = -2; + mOffsetZ_Upper = 2; + } + + //if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower; i <=mOffsetX_Upper; ++i) { + for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) { + for (int h = -1; h < 2; ++h) { + if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, + zDir + j); + if (!addToMachineList(tTileEntity)) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if ((tBlock != getCasingBlock()) && (tMeta != getCasingMeta())) { + if ((i != mOffsetX_Lower && j != mOffsetZ_Lower + && i != mOffsetX_Upper && j != mOffsetZ_Upper) && (h == 0 || h == 1)){ + if (tBlock == Blocks.flowing_water || tBlock == Blocks.water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)){ + if (MathUtils.randInt(1, 20000) == 1){ + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord()+xDir + i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir + j, Blocks.air); + + if (this.mOutputHatches.size() > 0){ + this.addOutput(FluidUtils.getFluidStack("fluid.sludge", 200)); + } + + } + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water){ + ++tAmount; + } + else if (tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)){ + ++tAmount; + ++tAmount; + } + } + } + } + } + } + } + } + } + if ((tAmount < this.mFilledCount)){ + Utils.LOG_WARNING("Drained structure."); + } + else { + Utils.LOG_WARNING("Did not drain structure."); + } + this.mFilledCount = tAmount; + return (tAmount < this.mFilledCount); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isActive()){ + removeWater(); + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mFilledCount", this.mFilledCount); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mFilledCount = aNBT.getInteger("mFilledCount"); + super.loadNBTData(aNBT); + } + } \ No newline at end of file -- cgit