From 2a672556e647163d0c4361f197603e95f6ccf22f Mon Sep 17 00:00:00 2001 From: Dimach Date: Sun, 30 Jul 2017 04:09:59 +0300 Subject: [PATCH] Added new info to batbuffer sensor card (nuclear control panel) - average input and output. Also fixed bug in average input/output calculation. --- .../api/metatileentity/BaseMetaTileEntity.java | 16 +++++++++++----- .../GT_MetaTileEntity_BasicBatteryBuffer.java | 7 +++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 177810f9..758743b1 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -53,7 +53,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE protected long mStoredEnergy = 0, mStoredSteam = 0; protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; protected boolean mReleaseEnergy = false; - protected int[] mAverageEUInput = new int[]{0, 0, 0, 0, 0}, mAverageEUOutput = new int[]{0, 0, 0, 0, 0}; + protected int[] mAverageEUInput = new int[11], mAverageEUOutput = new int[11]; private boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; @@ -1574,15 +1574,21 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public long getAverageElectricInput() { int rEU = 0; - for (int tEU : mAverageEUInput) rEU += tEU; - return rEU / mAverageEUInput.length; + for (int i = 0; i < mAverageEUInput.length; i++) { + if (i != mAverageEUInputIndex) + rEU += mAverageEUInput[i]; + } + return rEU / (mAverageEUInput.length - 1); } @Override public long getAverageElectricOutput() { int rEU = 0; - for (int tEU : mAverageEUOutput) rEU += tEU; - return rEU / mAverageEUOutput.length; + for (int i = 0; i < mAverageEUOutput.length; i++) { + if (i != mAverageEUOutputIndex) + rEU += mAverageEUOutput[i]; + } + return rEU / (mAverageEUOutput.length - 1); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index 5c248055..41788c65 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -314,12 +314,15 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier mStored = tmp[0]; mMax = tmp[1]; } - return new String[]{ getLocalName(), "Stored Items:", GT_Utility.formatNumbers(mStored) + " EU /", - GT_Utility.formatNumbers(mMax) + " EU"}; + GT_Utility.formatNumbers(mMax) + " EU", + "Average input:", + getBaseMetaTileEntity().getAverageElectricInput()+"", + "Average output:", + getBaseMetaTileEntity().getAverageElectricOutput()+""}; } @Override