Skip to content

Commit

Permalink
Fix #5857: Items added to ME storage statistic is affected by fluids
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored and shartte committed Dec 23, 2021
1 parent ade1191 commit 3aca8e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/main/java/appeng/api/storage/StorageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import java.util.Objects;

import com.google.common.primitives.Ints;

import net.minecraft.nbt.CompoundTag;

import appeng.api.config.Actionable;
Expand All @@ -33,6 +35,7 @@
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionSource;
import appeng.api.stacks.AEItemKey;
import appeng.api.stacks.AEKey;
import appeng.core.stats.AeStats;
import appeng.crafting.CraftingLink;
Expand Down Expand Up @@ -98,9 +101,10 @@ public static long poweredExtraction(IEnergySource energy, MEStorage inv,
energy.extractAEPower(retrieved / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG);
var ret = inv.extract(request, itemToExtract, Actionable.MODULATE, src);

if (ret != 0) {
src.player()
.ifPresent(player -> AeStats.ItemsExtracted.addToPlayer(player, (int) ret));
if (ret != 0 && request instanceof AEItemKey) {
src.player().ifPresent(player -> {
AeStats.ItemsExtracted.addToPlayer(player, Ints.saturatedCast(ret));
});
}
return ret;
} else {
Expand Down Expand Up @@ -161,9 +165,11 @@ public static long poweredInsert(IEnergySource energy, MEStorage inv, AEKey inpu
energy.extractAEPower(amount / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG);
var inserted = inv.insert(input, amount, Actionable.MODULATE, src);

src.player().ifPresent(player -> {
AeStats.ItemsInserted.addToPlayer(player, (int) inserted);
});
if (input instanceof AEItemKey) {
src.player().ifPresent(player -> {
AeStats.ItemsInserted.addToPlayer(player, Ints.saturatedCast(inserted));
});
}

return inserted;
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/appeng/core/stats/AeStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@

public enum AeStats {

// done
ItemsInserted("items_inserted"),

// done
ItemsExtracted("items_extracted");

private final ResourceLocation registryName;
Expand Down

0 comments on commit 3aca8e0

Please sign in to comment.