Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix battery slot charge flickering #2305

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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