Skip to content

Commit 1f9d5da

Browse files
committed
[#539] Remove the external storage counters from the internal functions
1 parent 8e30dd6 commit 1f9d5da

File tree

3 files changed

+17
-50
lines changed

3 files changed

+17
-50
lines changed

src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import me.ramidzkh.mekae2.ae2.MekanismKey;
3535
import me.ramidzkh.mekae2.ae2.MekanismKeyType;
3636
import me.ramidzkh.mekae2.item.ChemicalStorageCell;
37+
import mekanism.api.chemical.merged.MergedChemicalTank;
3738
import mekanism.common.tile.TileEntityChemicalTank;
3839
import net.minecraft.core.BlockPos;
3940
import net.minecraft.nbt.CompoundTag;
@@ -479,7 +480,8 @@ public static long getTotalExternalChemicalStorage(IGridNode node) {
479480
continue;
480481

481482
if (connectedInventoryEntity instanceof TileEntityChemicalTank tank) {
482-
total += tank.getChemicalTank().getTankFromCurrent(tank.getChemicalTank().getCurrent()).getCapacity();
483+
MergedChemicalTank.Current current = tank.getChemicalTank().getCurrent() == MergedChemicalTank.Current.EMPTY ? MergedChemicalTank.Current.GAS : tank.getChemicalTank().getCurrent();
484+
total += tank.getChemicalTank().getTankFromCurrent(current).getCapacity();
483485
}
484486
}
485487

@@ -496,9 +498,8 @@ public static long getUsedExternalItemStorage(IGridNode node) {
496498
KeyCounter keyCounter = bus.getInternalHandler().getAvailableStacks();
497499

498500
for (Object2LongMap.Entry<AEKey> aeKey : keyCounter) {
499-
if (aeKey.getKey() instanceof AEItemKey) {
501+
if (aeKey.getKey() instanceof AEItemKey)
500502
used += aeKey.getLongValue();
501-
}
502503
}
503504
}
504505

@@ -513,9 +514,8 @@ public static long getUsedExternalFluidStorage(IGridNode node) {
513514
KeyCounter keyCounter = bus.getInternalHandler().getAvailableStacks();
514515

515516
for (Object2LongMap.Entry<AEKey> aeKey : keyCounter) {
516-
if (aeKey.getKey() instanceof AEFluidKey) {
517+
if (aeKey.getKey() instanceof AEFluidKey)
517518
used += aeKey.getLongValue();
518-
}
519519
}
520520
}
521521

@@ -525,14 +525,16 @@ public static long getUsedExternalFluidStorage(IGridNode node) {
525525
public static long getUsedExternalChemicalStorage(IGridNode node) {
526526
long used = 0;
527527

528+
if (!APAddons.appMekLoaded)
529+
return 0;
530+
528531
for (IGridNode iGridNode : node.getGrid().getMachineNodes(StorageBusPart.class)) {
529532
StorageBusPart bus = (StorageBusPart) iGridNode.getService(IStorageProvider.class);
530533
KeyCounter keyCounter = bus.getInternalHandler().getAvailableStacks();
531534

532535
for (Object2LongMap.Entry<AEKey> aeKey : keyCounter) {
533-
if (aeKey.getKey() instanceof MekanismKey) {
536+
if (aeKey.getKey() instanceof MekanismKey)
534537
used += aeKey.getLongValue();
535-
}
536538
}
537539
}
538540

@@ -571,9 +573,6 @@ public static long getTotalItemStorage(IGridNode node) {
571573
}
572574
}
573575
}
574-
575-
total += getTotalExternalItemStorage(node);
576-
577576
return total;
578577
}
579578

@@ -603,14 +602,15 @@ public static long getTotalFluidStorage(IGridNode node) {
603602
}
604603
}
605604

606-
total += getTotalExternalFluidStorage(node);
607-
608605
return total;
609606
}
610607

611608
public static long getTotalChemicalStorage(IGridNode node) {
612609
long total = 0;
613610

611+
if (!APAddons.appMekLoaded)
612+
return 0;
613+
614614
for (IGridNode iGridNode : node.getGrid().getMachineNodes(DriveBlockEntity.class)) {
615615
DriveBlockEntity entity = (DriveBlockEntity) iGridNode.getService(IStorageProvider.class);
616616
if (entity == null)
@@ -626,14 +626,12 @@ public static long getTotalChemicalStorage(IGridNode node) {
626626

627627
if (stack.getItem() instanceof ChemicalStorageCell cell) {
628628
if (cell.getKeyType() instanceof MekanismKeyType) {
629-
total += (long) cell.getBytes(null) * MekanismKeyType.TYPE.getAmountPerByte();
629+
total += cell.getBytes(null);
630630
}
631631
}
632632
}
633633
}
634634

635-
total += getTotalExternalChemicalStorage(node);
636-
637635
return total;
638636
}
639637

@@ -683,8 +681,6 @@ public static long getUsedItemStorage(IGridNode node) {
683681
}
684682
}
685683

686-
used += getUsedExternalItemStorage(node);
687-
688684
return used;
689685
}
690686

@@ -722,14 +718,15 @@ public static long getUsedFluidStorage(IGridNode node) {
722718
}
723719
}
724720

725-
used += getUsedExternalFluidStorage(node);
726-
727721
return used;
728722
}
729723

730724
public static long getUsedChemicalStorage(IGridNode node) {
731725
long used = 0;
732726

727+
if (!APAddons.appMekLoaded)
728+
return 0;
729+
733730
for (IGridNode iGridNode : node.getGrid().getMachineNodes(DriveBlockEntity.class)) {
734731
DriveBlockEntity entity = (DriveBlockEntity) iGridNode.getService(IStorageProvider.class);
735732
if (entity == null)
@@ -748,8 +745,6 @@ public static long getUsedChemicalStorage(IGridNode node) {
748745
}
749746
}
750747

751-
used += getUsedExternalChemicalStorage(node);
752-
753748
return used;
754749
}
755750

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public MethodResult getUsedExternItemStorage() {
431431
if (!isAvailable())
432432
return notConnected();
433433

434-
return MethodResult.of(AppEngApi.getUsedExternalFluidStorage(node));
434+
return MethodResult.of(AppEngApi.getUsedExternalItemStorage(node));
435435
}
436436

437437
@Override

src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemPeripheral.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,94 +29,66 @@ public interface IStorageSystemPeripheral {
2929

3030
MethodResult listFluids();
3131

32-
3332
MethodResult listCraftableItems();
3433

35-
3634
MethodResult listCraftableFluids();
3735

3836
MethodResult listCells();
3937

40-
4138
MethodResult importItem(IComputerAccess computer, IArguments arguments) throws LuaException;
4239

43-
4440
MethodResult exportItem(IComputerAccess computer, IArguments arguments) throws LuaException;
4541

46-
4742
MethodResult importFluid(IComputerAccess computer, IArguments arguments) throws LuaException;
4843

49-
5044
MethodResult exportFluid(IComputerAccess computer, IArguments arguments) throws LuaException;
5145

52-
5346
MethodResult getFilteredPatterns(IArguments arguments) throws LuaException;
5447

55-
5648
MethodResult getPatterns();
5749

58-
5950
MethodResult getStoredEnergy();
6051

61-
6252
MethodResult getEnergyCapacity();
6353

64-
6554
MethodResult getEnergyUsage();
6655

6756
MethodResult getAvgPowerInjection();
6857

6958
MethodResult getTotalExternItemStorage();
7059

71-
7260
MethodResult getTotalExternFluidStorage();
7361

74-
7562
MethodResult getTotalItemStorage();
7663

77-
7864
MethodResult getTotalFluidStorage();
7965

80-
8166
MethodResult getUsedExternItemStorage();
8267

83-
8468
MethodResult getUsedExternFluidStorage();
8569

86-
8770
MethodResult getUsedItemStorage();
8871

89-
9072
MethodResult getUsedFluidStorage();
9173

92-
9374
MethodResult getAvailableExternItemStorage();
9475

95-
9676
MethodResult getAvailableExternFluidStorage();
9777

98-
9978
MethodResult getAvailableItemStorage();
10079

101-
10280
MethodResult getAvailableFluidStorage();
10381

104-
10582
MethodResult craftItem(IComputerAccess computer, IArguments arguments) throws LuaException;
10683

107-
10884
MethodResult craftFluid(IComputerAccess computer, IArguments arguments) throws LuaException;
10985

110-
11186
MethodResult isItemCraftable(IArguments arguments) throws LuaException;
11287

113-
11488
MethodResult isItemCrafting(IArguments arguments) throws LuaException;
11589

116-
11790
MethodResult isFluidCraftable(IArguments arguments) throws LuaException;
11891

119-
12092
MethodResult isFluidCrafting(IArguments arguments) throws LuaException;
12193

12294
}

0 commit comments

Comments
 (0)