diff --git a/src/main/java/gripe/_90/appliede/iface/EMCInterfaceLogic.java b/src/main/java/gripe/_90/appliede/iface/EMCInterfaceLogic.java index 4d88cce..6dc3f13 100644 --- a/src/main/java/gripe/_90/appliede/iface/EMCInterfaceLogic.java +++ b/src/main/java/gripe/_90/appliede/iface/EMCInterfaceLogic.java @@ -245,7 +245,7 @@ private boolean tryUsePlan(int slot, AEKey what, int amount) { } energy.extractAEPower(energyToExpend, Actionable.MODULATE, PowerMultiplier.CONFIG); - knowledge.getStorage().insert(EMCKey.base(), toDeposit, Actionable.MODULATE, requestSource); + knowledge.getStorage().insert(EMCKey.BASE, toDeposit, Actionable.MODULATE, requestSource); var deposited = BigInteger.valueOf(toDeposit); insertedItems += (int) deposited.divide(itemEmc).longValue(); diff --git a/src/main/java/gripe/_90/appliede/key/EMCKey.java b/src/main/java/gripe/_90/appliede/key/EMCKey.java index 2dc0759..8b50ebd 100644 --- a/src/main/java/gripe/_90/appliede/key/EMCKey.java +++ b/src/main/java/gripe/_90/appliede/key/EMCKey.java @@ -17,22 +17,20 @@ import gripe._90.appliede.AppliedE; public final class EMCKey extends AEKey { + public static final EMCKey BASE = new EMCKey(1); + private final int tier; private EMCKey(int tier) { if (tier <= 0) { - throw new IllegalArgumentException("Tier must be positive"); + throw new IllegalArgumentException("Tier must be non-negative"); } this.tier = tier; } public static EMCKey tier(int tier) { - return new EMCKey(tier); - } - - public static EMCKey base() { - return tier(1); + return tier == 1 ? BASE : new EMCKey(tier); } public int getTier() { diff --git a/src/main/java/gripe/_90/appliede/key/EMCKeyType.java b/src/main/java/gripe/_90/appliede/key/EMCKeyType.java index 5836e9c..6d04906 100644 --- a/src/main/java/gripe/_90/appliede/key/EMCKeyType.java +++ b/src/main/java/gripe/_90/appliede/key/EMCKeyType.java @@ -10,8 +10,8 @@ import gripe._90.appliede.AppliedE; public final class EMCKeyType extends AEKeyType { - static final Component EMC = Component.translatable("key." + AppliedE.MODID + ".emc"); public static final EMCKeyType TYPE = new EMCKeyType(); + private static final Component EMC = Component.translatable("key." + AppliedE.MODID + ".emc"); private EMCKeyType() { super(AppliedE.id("emc"), EMCKey.class, EMC); diff --git a/src/main/java/gripe/_90/appliede/service/EMCStorage.java b/src/main/java/gripe/_90/appliede/service/EMCStorage.java index 6e4fbe4..e1825c0 100644 --- a/src/main/java/gripe/_90/appliede/service/EMCStorage.java +++ b/src/main/java/gripe/_90/appliede/service/EMCStorage.java @@ -144,7 +144,7 @@ public long extractItem(AEItemKey what, long amount, Actionable mode, IActionSou while (totalEmc.compareTo(BigInteger.ZERO) > 0) { var toWithdraw = AppliedE.clampedLong(totalEmc); - var canWithdraw = extract(EMCKey.base(), toWithdraw, Actionable.SIMULATE, source); + var canWithdraw = extract(EMCKey.BASE, toWithdraw, Actionable.SIMULATE, source); if (canWithdraw < toWithdraw) { break; @@ -159,7 +159,7 @@ public long extractItem(AEItemKey what, long amount, Actionable mode, IActionSou } energy.extractAEPower(energyToExpend, Actionable.MODULATE, PowerMultiplier.CONFIG); - extract(EMCKey.base(), toWithdraw, Actionable.MODULATE, source); + extract(EMCKey.BASE, toWithdraw, Actionable.MODULATE, source); } var withdrawn = BigInteger.valueOf(toWithdraw);