diff --git a/dependencies.gradle b/dependencies.gradle index add0553d3..9441c4380 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -35,7 +35,7 @@ */ dependencies { api('com.github.GTNewHorizons:NotEnoughItems:2.7.18-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-521-GTNH:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-523-GTNH:dev') api('curse.maven:cofh-core-69162:2388751') api('com.github.GTNewHorizons:waila:1.8.2:dev') api("com.github.GTNewHorizons:GTNHLib:0.6.1:dev") diff --git a/src/main/java/com/glodblock/github/common/item/FCBaseItemCell.java b/src/main/java/com/glodblock/github/common/item/FCBaseItemCell.java index 39574f783..26efa15f7 100644 --- a/src/main/java/com/glodblock/github/common/item/FCBaseItemCell.java +++ b/src/main/java/com/glodblock/github/common/item/FCBaseItemCell.java @@ -190,7 +190,7 @@ public boolean isEditable(ItemStack is) { @Override public IInventory getUpgradesInventory(ItemStack is) { - return new CellUpgrades(is, 2); + return new CellUpgrades(is, 5); } @Override diff --git a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java index 979b0237e..8f69bc410 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java @@ -19,7 +19,9 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; +import appeng.api.config.Upgrades; import appeng.api.exceptions.AppEngException; +import appeng.api.implementations.items.IUpgradeModule; import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.ISaveProvider; @@ -46,6 +48,8 @@ public class FluidCellInventory implements IFluidCellInventory { protected IItemList cellFluids; protected final NBTTagCompound tagCompound; public static final int singleByteAmount = 256 * 8; + private boolean cardVoidOverflow = false; + private boolean cardDistribution = false; public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException { if (o == null) { @@ -74,6 +78,21 @@ public FluidCellInventory(final ItemStack o, final ISaveProvider container) thro } } + final IInventory upgrades = this.getUpgradesInventory(); + for (int x = 0; x < upgrades.getSizeInventory(); x++) { + final ItemStack is = upgrades.getStackInSlot(x); + if (is != null && is.getItem() instanceof IUpgradeModule) { + final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is); + if (u != null) { + switch (u) { + case VOID_OVERFLOW -> cardVoidOverflow = true; + case DISTRIBUTION -> cardDistribution = true; + default -> {} + } + } + } + } + this.container = container; this.tagCompound = Platform.openNbtData(o); this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG); @@ -180,6 +199,25 @@ public long getRemainingFluidCount() { return remaining > 0 ? remaining : 0; } + @Override + public long getRemainingFluidCountDist(IAEFluidStack l) { + long remaining; + long types = 0; + for (int i = 0; i < this.getTotalFluidTypes(); i++) { + if (this.getConfigInventory().getStackInSlot(i) != null) { + types++; + } + } + if (types == 0) types = this.getTotalFluidTypes(); + if (l != null) { + remaining = (((this.getTotalBytes() / types) - (int) Math.ceil((double) l.getStackSize() / singleByteAmount) + - getBytesPerType()) * singleByteAmount) + (singleByteAmount - l.getStackSize() % singleByteAmount); + } else { + remaining = ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount; + } + return remaining > 0 ? remaining : 0; + } + @Override public int getUnusedFluidCount() { final int div = (int) (this.getStoredFluidCount() % singleByteAmount); @@ -293,9 +331,17 @@ public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActio final IAEFluidStack l = this.getCellFluids().findPrecise(input); if (l != null) { - final long remainingFluidSlots = this.getRemainingFluidCount(); + long remainingFluidSlots; + if (cardDistribution) { + remainingFluidSlots = this.getRemainingFluidCountDist(l); + } else { + remainingFluidSlots = this.getRemainingFluidCount(); + } - if (remainingFluidSlots < 0) { + if (remainingFluidSlots <= 0) { + if (cardVoidOverflow) { + return null; + } return input; } @@ -320,8 +366,13 @@ public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActio if (this.canHoldNewFluid()) // room for new type, and for at least one item! { - final long remainingFluidCount = this.getRemainingFluidCount() - - ((long) this.getBytesPerType() * singleByteAmount); + long remainingFluidCount; + if (cardDistribution) { + remainingFluidCount = this.getRemainingFluidCountDist(null); + } else { + remainingFluidCount = this.getRemainingFluidCount() + - ((long) this.getBytesPerType() * singleByteAmount); + } if (remainingFluidCount > 0) { if (input.getStackSize() > remainingFluidCount) { diff --git a/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java b/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java index 486591792..dfea48582 100644 --- a/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java @@ -60,6 +60,11 @@ public interface IFluidCellInventory extends IMEInventory { */ long getRemainingFluidCount(); + /** + * @return how many more fluids can be stored with Distribution card. + */ + long getRemainingFluidCountDist(IAEFluidStack l); + /** * @return how many fluid types remain. */ diff --git a/src/main/java/com/glodblock/github/proxy/CommonProxy.java b/src/main/java/com/glodblock/github/proxy/CommonProxy.java index 39eb7864b..d727a01c0 100644 --- a/src/main/java/com/glodblock/github/proxy/CommonProxy.java +++ b/src/main/java/com/glodblock/github/proxy/CommonProxy.java @@ -76,6 +76,15 @@ public void postInit(FMLPostInitializationEvent event) { Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096K), 1); Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL64K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL256K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096K), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384K), 1); + Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1); Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1); Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1); @@ -85,6 +94,24 @@ public void postInit(FMLPostInitializationEvent event) { Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1); Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL64KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL256KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1); + Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1); + + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1); + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1); + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1); + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL64KM), 1); + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL256KM), 1); + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024KM), 1); + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1); + Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1); + Upgrades.FAKE_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1); Upgrades.FAKE_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1); Upgrades.FAKE_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P), 1);