Skip to content

Commit

Permalink
Fix battery slot charge flickering (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Dec 17, 2023
1 parent 46b30c7 commit 025d469
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ private boolean handleElectricItem(IElectricItem electricItem) {
// Check if the item is a battery (or similar), and if we can receive some amount of energy
if (electricItem.canProvideChargeExternally() && getEnergyCanBeInserted() > 0) {

// Drain from the battery if we are below half energy capacity, and if the tier matches
if (chargePercent <= 0.5 && chargeTier == machineTier) {
// Drain from the battery if we are below 1/3rd energy capacity, and if the tier matches
if (chargePercent <= 0.33 && chargeTier == machineTier) {
long dischargedBy = electricItem.discharge(getEnergyCanBeInserted(), machineTier, false, true, false);
addEnergy(dischargedBy);
return dischargedBy > 0L;
}
}

// Else, check if we have above 50% power
if (chargePercent > 0.5) {
// Else, check if we have above 2/3rds charge
if (chargePercent > 0.66) {
long chargedBy = electricItem.charge(getEnergyStored(), chargeTier, false, false);
removeEnergy(chargedBy);
return chargedBy > 0;
Expand All @@ -178,7 +178,7 @@ private boolean handleForgeEnergyItem(IEnergyStorage energyStorage) {
int machineTier = GTUtility.getTierByVoltage(Math.max(getInputVoltage(), getOutputVoltage()));
double chargePercent = getEnergyStored() / (getEnergyCapacity() * 1.0);

if (chargePercent > 0.5) {
if (chargePercent > 0.66) { // 2/3rds full
long chargedBy = FeCompat.insertEu(energyStorage, GTValues.V[machineTier]);
removeEnergy(chargedBy);
return chargedBy > 0;
Expand Down

0 comments on commit 025d469

Please sign in to comment.