diff --git a/dependencies.gradle b/dependencies.gradle index 065be4eb9..963aeec48 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -34,22 +34,22 @@ * For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph */ dependencies { - api('com.github.GTNewHorizons:NotEnoughItems:2.7.25-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-527-GTNH:dev') + api('com.github.GTNewHorizons:NotEnoughItems:2.7.27-GTNH:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-532-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.3:dev") + api("com.github.GTNewHorizons:GTNHLib:0.6.5:dev") implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.7:dev") { exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial' } - compileOnly("com.github.GTNewHorizons:GTNHLib:0.6.3:dev") { transitive = false } + compileOnly("com.github.GTNewHorizons:GTNHLib:0.6.5:dev") { transitive = false } compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.0.3:dev') compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.1:dev') compileOnly('com.github.GTNewHorizons:EnderIO:2.9.2:dev') - compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.93:dev') { + compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.97:dev') { exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework' exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial' } @@ -58,8 +58,8 @@ dependencies { compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.4-GTNH:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.5-GTNH:dev') { transitive = false } - compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.20:dev") { transitive = false } + compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.22:dev") { transitive = false } runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.4:dev") - runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:0.6.3:dev") + runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:0.6.5: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 26efa15f7..a4c113632 100644 --- a/src/main/java/com/glodblock/github/common/item/FCBaseItemCell.java +++ b/src/main/java/com/glodblock/github/common/item/FCBaseItemCell.java @@ -1,6 +1,7 @@ package com.glodblock.github.common.item; import java.text.NumberFormat; +import java.util.Arrays; import java.util.EnumSet; import java.util.List; @@ -16,8 +17,8 @@ import com.glodblock.github.api.FluidCraftAPI; import com.glodblock.github.common.storage.CellType; +import com.glodblock.github.common.storage.FluidCellInventory; import com.glodblock.github.common.storage.FluidCellInventoryHandler; -import com.glodblock.github.common.storage.IFluidCellInventory; import com.glodblock.github.common.storage.IStorageFluidCell; import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.util.NameConst; @@ -33,6 +34,7 @@ import appeng.api.storage.data.IItemList; import appeng.core.features.AEFeature; import appeng.core.localization.GuiText; +import appeng.helpers.ICellRestriction; import appeng.items.AEBaseItem; import appeng.items.contents.CellConfig; import appeng.items.contents.CellUpgrades; @@ -41,7 +43,7 @@ import appeng.util.Platform; import appeng.util.ReadableNumberConverter; -public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell { +public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell, ICellRestriction { protected CellType component; protected long totalBytes; @@ -92,12 +94,12 @@ public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition @Override public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List lines, - final boolean displayMoreInfo) { + final boolean displayMoreInfo) { final IMEInventoryHandler inventory = AEApi.instance().registries().cell() - .getCellInventory(stack, null, StorageChannel.FLUIDS); + .getCellInventory(stack, null, StorageChannel.FLUIDS); if (inventory instanceof final FluidCellInventoryHandler handler) { - final IFluidCellInventory cellInventory = handler.getCellInv(); + final FluidCellInventory cellInventory = (FluidCellInventory) handler.getCellInv(); if (cellInventory != null) { lines.add( @@ -118,7 +120,7 @@ public void addCheckedInformation(final ItemStack stack, final EntityPlayer play + GuiText.Of.getLocal() + " " + EnumChatFormatting.DARK_GREEN - + cellInventory.getTotalFluidTypes() + + cellInventory.getMaxFluidTypes() + " " + EnumChatFormatting.GRAY + GuiText.Types.getLocal()); @@ -144,7 +146,7 @@ public void addCheckedInformation(final ItemStack stack, final EntityPlayer play if (handler.isPreformatted()) { final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included - : GuiText.Excluded).getLocal(); + : GuiText.Excluded).getLocal(); lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal()); if (GuiScreen.isShiftKeyDown()) { @@ -159,6 +161,17 @@ public void addCheckedInformation(final ItemStack stack, final EntityPlayer play lines.add(GuiText.Sticky.getLocal()); } } + List restricted = handler.getRestricted(); + if (restricted != null && ((long) restricted.get(0) != 0 || (byte) restricted.get(1) != 0)) { + lines.add(GuiText.Restricted.getLocal()); + if (GuiScreen.isShiftKeyDown()) { + NumberFormat nf = NumberFormat.getNumberInstance(); + if ((long) restricted.get(0) != 0) + lines.add(GuiText.MaxFluid.getLocal() + " " + nf.format((long) restricted.get(0)) + " mB"); + if ((byte) restricted.get(1) != 0) + lines.add(GuiText.MaxTypes.getLocal() + " " + restricted.get(1)); + } + } } } } @@ -213,6 +226,29 @@ public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) { Platform.openNbtData(is).setString("FuzzyMode", fzMode.name()); } + @Override + public String getCellData(ItemStack is) { + return totalBytes + "," + + this.getTotalTypes(null) + + "," + + this.getBytesPerType(null) + + "," + + 256 * 8 + + "," + + Platform.openNbtData(is).getByte("cellRestrictionTypes") + + "," + + Platform.openNbtData(is).getLong("cellRestrictionAmount") + + "," + + "fluid"; + } + + @Override + public void setCellRestriction(ItemStack is, String newData) { + List data = Arrays.asList(newData.split(",", 2)); + Platform.openNbtData(is).setByte("cellRestrictionTypes", Byte.parseByte(data.get(0))); + Platform.openNbtData(is).setLong("cellRestrictionAmount", Long.parseLong(data.get(1))); + } + @SuppressWarnings("unchecked") protected boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) { if (player.isSneaking()) { 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 8f69bc410..034f9889d 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java @@ -1,6 +1,7 @@ package com.glodblock.github.common.storage; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import javax.annotation.Nonnull; @@ -50,6 +51,8 @@ public class FluidCellInventory implements IFluidCellInventory { public static final int singleByteAmount = 256 * 8; private boolean cardVoidOverflow = false; private boolean cardDistribution = false; + private byte restrictionTypes = 0; + private long restrictionLong = 0; public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException { if (o == null) { @@ -97,6 +100,8 @@ public FluidCellInventory(final ItemStack o, final ISaveProvider container) thro this.tagCompound = Platform.openNbtData(o); this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG); this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG); + this.restrictionTypes = this.tagCompound.getByte("cellRestrictionTypes"); + this.restrictionLong = this.tagCompound.getLong("cellRestrictionAmount"); this.cellFluids = null; } @@ -173,6 +178,11 @@ public long getUsedBytes() { @Override public long getTotalFluidTypes() { + if (restrictionTypes > 0) return restrictionTypes; + return this.cellType.getTotalTypes(this.cellItem); + } + + public long getMaxFluidTypes() { return this.cellType.getTotalTypes(this.cellItem); } @@ -195,6 +205,11 @@ public long getRemainingFluidTypes() { @Override public long getRemainingFluidCount() { + if (restrictionLong > 0) { + return Math.min( + restrictionLong - this.getStoredFluidCount(), + this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount()); + } final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount(); return remaining > 0 ? remaining : 0; } @@ -210,10 +225,22 @@ public long getRemainingFluidCountDist(IAEFluidStack l) { } 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); + if (restrictionLong > 0) { + remaining = Math.min((restrictionLong / types) - l.getStackSize(), this.getUnusedFluidCount()); + } else { + 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; + if (restrictionLong > 0) { + remaining = Math.min( + restrictionLong / types, + ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount); + } else { + remaining = ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount; + } } return remaining > 0 ? remaining : 0; } @@ -467,4 +494,8 @@ public IInventory getUpgradesInventory() { public StorageChannel getChannel() { return StorageChannel.FLUIDS; } + + public List getRestriction() { + return Arrays.asList(restrictionLong, restrictionTypes); + } } diff --git a/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java b/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java index 79e0c4975..c907d67bf 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java @@ -1,5 +1,7 @@ package com.glodblock.github.common.storage; +import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -148,4 +150,13 @@ public int getCellStatus() { public TYPE getCellType() { return TYPE.FLUID; } + + public List getRestricted() { + IFluidCellInventory cellInventory = this.getCellInv(); + if (cellInventory instanceof FluidCellInventory ci) { + return ci.getRestriction(); + + } + return null; + } }