Skip to content

Commit

Permalink
Fix crash with wireless charger charging items that say they received…
Browse files Browse the repository at this point in the history
… negative energy
  • Loading branch information
Swedz committed Aug 15, 2024
1 parent aa1e96b commit d18baa2
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ private long charge(Player player, long maxEu)
ILongEnergyStorage energy = armor.getCapability(EnergyApi.ITEM);
if(energy != null)
{
eu += energy.receive(Math.max(0, maxEu - eu), false);
if(eu == maxEu)
long received = energy.receive(Math.max(0, maxEu - eu), false);
if(received > 0)
{
return eu;
eu += received;
if(eu == maxEu)
{
return eu;
}
}
}
}
Expand All @@ -69,10 +73,14 @@ private long charge(Player player, long maxEu)
ILongEnergyStorage energy = item.getCapability(EnergyApi.ITEM);
if(energy != null)
{
eu += energy.receive(Math.max(0, maxEu - eu), false);
if(eu == maxEu)
long received = energy.receive(Math.max(0, maxEu - eu), false);
if(received > 0)
{
return eu;
eu += received;
if(eu == maxEu)
{
return eu;
}
}
}
}
Expand Down

0 comments on commit d18baa2

Please sign in to comment.