diff --git a/src/main/java/gripe/_90/appliede/mappers/ChargerRecipeTypeMapper.java b/src/main/java/gripe/_90/appliede/emc/mappers/ChargerRecipeTypeMapper.java similarity index 95% rename from src/main/java/gripe/_90/appliede/mappers/ChargerRecipeTypeMapper.java rename to src/main/java/gripe/_90/appliede/emc/mappers/ChargerRecipeTypeMapper.java index 126a403..5771853 100644 --- a/src/main/java/gripe/_90/appliede/mappers/ChargerRecipeTypeMapper.java +++ b/src/main/java/gripe/_90/appliede/emc/mappers/ChargerRecipeTypeMapper.java @@ -1,4 +1,4 @@ -package gripe._90.appliede.mappers; +package gripe._90.appliede.emc.mappers; import net.minecraft.world.item.crafting.RecipeType; diff --git a/src/main/java/gripe/_90/appliede/mappers/InscriberRecipeTypeMapper.java b/src/main/java/gripe/_90/appliede/emc/mappers/InscriberRecipeTypeMapper.java similarity index 97% rename from src/main/java/gripe/_90/appliede/mappers/InscriberRecipeTypeMapper.java rename to src/main/java/gripe/_90/appliede/emc/mappers/InscriberRecipeTypeMapper.java index d3aa6a8..4990199 100644 --- a/src/main/java/gripe/_90/appliede/mappers/InscriberRecipeTypeMapper.java +++ b/src/main/java/gripe/_90/appliede/emc/mappers/InscriberRecipeTypeMapper.java @@ -1,4 +1,4 @@ -package gripe._90.appliede.mappers; +package gripe._90.appliede.emc.mappers; import java.util.Collection; import java.util.Collections; diff --git a/src/main/java/gripe/_90/appliede/mappers/TransformRecipeTypeMapper.java b/src/main/java/gripe/_90/appliede/emc/mappers/TransformRecipeTypeMapper.java similarity index 97% rename from src/main/java/gripe/_90/appliede/mappers/TransformRecipeTypeMapper.java rename to src/main/java/gripe/_90/appliede/emc/mappers/TransformRecipeTypeMapper.java index c001d0f..0c60578 100644 --- a/src/main/java/gripe/_90/appliede/mappers/TransformRecipeTypeMapper.java +++ b/src/main/java/gripe/_90/appliede/emc/mappers/TransformRecipeTypeMapper.java @@ -1,4 +1,4 @@ -package gripe._90.appliede.mappers; +package gripe._90.appliede.emc.mappers; import java.util.Collection; import java.util.Collections; diff --git a/src/main/java/gripe/_90/appliede/emc/nbt/NetworkToolNBTProcessor.java b/src/main/java/gripe/_90/appliede/emc/nbt/NetworkToolNBTProcessor.java new file mode 100644 index 0000000..db1a89c --- /dev/null +++ b/src/main/java/gripe/_90/appliede/emc/nbt/NetworkToolNBTProcessor.java @@ -0,0 +1,47 @@ +package gripe._90.appliede.emc.nbt; + +import java.math.BigInteger; + +import org.jetbrains.annotations.NotNull; + +import appeng.items.contents.NetworkToolMenuHost; +import appeng.items.tools.NetworkToolItem; + +import gripe._90.appliede.AppliedE; + +import moze_intel.projecte.api.ItemInfo; +import moze_intel.projecte.api.nbt.INBTProcessor; +import moze_intel.projecte.api.nbt.NBTProcessor; +import moze_intel.projecte.api.proxy.IEMCProxy; + +@SuppressWarnings("unused") +@NBTProcessor +public class NetworkToolNBTProcessor implements INBTProcessor { + @Override + public String getName() { + return "AE2NetworkToolProcessor"; + } + + @Override + public String getDescription() { + return "Calculates EMC value of the Applied Energistics 2 network tool."; + } + + @Override + public long recalculateEMC(@NotNull ItemInfo itemInfo, long currentEmc) throws ArithmeticException { + if (!(itemInfo.getItem() instanceof NetworkToolItem)) { + return currentEmc; + } + + var stack = itemInfo.createStack(); + var bigEmc = BigInteger.valueOf(currentEmc); + var inventory = new NetworkToolMenuHost(null, -1, stack, null).getInventory(); + + for (var item : inventory) { + var itemEmc = IEMCProxy.INSTANCE.getValue(item); + bigEmc = bigEmc.add(BigInteger.valueOf(itemEmc).multiply(BigInteger.valueOf(item.getCount()))); + } + + return AppliedE.clampedLong(bigEmc); + } +} diff --git a/src/main/java/gripe/_90/appliede/mappers/StorageCellNBTProcessor.java b/src/main/java/gripe/_90/appliede/emc/nbt/StorageCellNBTProcessor.java similarity index 91% rename from src/main/java/gripe/_90/appliede/mappers/StorageCellNBTProcessor.java rename to src/main/java/gripe/_90/appliede/emc/nbt/StorageCellNBTProcessor.java index 963c0ae..4cba2ef 100644 --- a/src/main/java/gripe/_90/appliede/mappers/StorageCellNBTProcessor.java +++ b/src/main/java/gripe/_90/appliede/emc/nbt/StorageCellNBTProcessor.java @@ -1,4 +1,4 @@ -package gripe._90.appliede.mappers; +package gripe._90.appliede.emc.nbt; import java.math.BigInteger; @@ -25,12 +25,7 @@ public String getName() { @Override public String getDescription() { - return "Calculates EMC value of Applied Energistics 2 storage cells (and terminals)."; - } - - @Override - public boolean isAvailable() { - return AppliedE.useCustomMapper(); + return "Calculates EMC value of Applied Energistics 2 storage cells (and anything else that's upgradeable)"; } @Override