From a543f32754a43b911cf1152f29beca1a3410bb52 Mon Sep 17 00:00:00 2001 From: Korewa_Li Date: Tue, 3 Jan 2023 10:14:41 +0700 Subject: [PATCH 1/3] Fix issue with some pipes don't markDirty itself cause writeToNBT don't fire up --- common/logisticspipes/gui/GuiFirewall.java | 9 +++++++++ common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java | 2 ++ common/logisticspipes/gui/GuiFluidSupplierPipe.java | 2 ++ common/logisticspipes/gui/GuiInvSysConnector.java | 7 +++++++ common/logisticspipes/gui/GuiLogisticsCraftingTable.java | 7 +++++++ common/logisticspipes/gui/GuiSatellitePipe.java | 2 ++ common/logisticspipes/ticks/VersionChecker.java | 3 +-- 7 files changed, 30 insertions(+), 2 deletions(-) diff --git a/common/logisticspipes/gui/GuiFirewall.java b/common/logisticspipes/gui/GuiFirewall.java index faf2ea94ea..8220d48342 100644 --- a/common/logisticspipes/gui/GuiFirewall.java +++ b/common/logisticspipes/gui/GuiFirewall.java @@ -3,7 +3,10 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; +import logisticspipes.network.PacketHandler; +import logisticspipes.network.packets.gui.GuiClosePacket; import logisticspipes.pipes.PipeItemsFirewall; +import logisticspipes.proxy.MainProxy; import logisticspipes.utils.gui.DummyContainer; import logisticspipes.utils.gui.GuiGraphics; import logisticspipes.utils.gui.GuiStringHandlerButton; @@ -65,6 +68,12 @@ protected void actionPerformed(GuiButton button) { } } + @Override + public void onGuiClosed() { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(pipe.container)); + super.onGuiClosed(); + } + @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true); diff --git a/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java b/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java index 64b0f54c65..810d6bc4fb 100644 --- a/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java +++ b/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java @@ -12,6 +12,7 @@ import net.minecraft.inventory.IInventory; import logisticspipes.network.PacketHandler; +import logisticspipes.network.packets.gui.GuiClosePacket; import logisticspipes.network.packets.pipe.FluidSupplierAmount; import logisticspipes.network.packets.pipe.FluidSupplierMinMode; import logisticspipes.network.packets.pipe.FluidSupplierMode; @@ -114,6 +115,7 @@ protected void actionPerformed(GuiButton guibutton) throws IOException { @Override public void onGuiClosed() { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(logic.container)); super.onGuiClosed(); } } diff --git a/common/logisticspipes/gui/GuiFluidSupplierPipe.java b/common/logisticspipes/gui/GuiFluidSupplierPipe.java index a2b3fb5e37..dc5b69b697 100644 --- a/common/logisticspipes/gui/GuiFluidSupplierPipe.java +++ b/common/logisticspipes/gui/GuiFluidSupplierPipe.java @@ -15,6 +15,7 @@ import org.lwjgl.opengl.GL11; import logisticspipes.network.PacketHandler; +import logisticspipes.network.packets.gui.GuiClosePacket; import logisticspipes.network.packets.pipe.FluidSupplierMode; import logisticspipes.pipes.PipeItemsFluidSupplier; import logisticspipes.proxy.MainProxy; @@ -88,6 +89,7 @@ protected void actionPerformed(GuiButton guibutton) throws IOException { @Override public void onGuiClosed() { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(logic.container)); super.onGuiClosed(); } } diff --git a/common/logisticspipes/gui/GuiInvSysConnector.java b/common/logisticspipes/gui/GuiInvSysConnector.java index dc6d6aa8ee..c1587beffe 100644 --- a/common/logisticspipes/gui/GuiInvSysConnector.java +++ b/common/logisticspipes/gui/GuiInvSysConnector.java @@ -15,6 +15,7 @@ import logisticspipes.interfaces.IGUIChannelInformationReceiver; import logisticspipes.network.PacketHandler; +import logisticspipes.network.packets.gui.GuiClosePacket; import logisticspipes.network.packets.pipe.InvSysConContentRequest; import logisticspipes.network.packets.pipe.InvSysConOpenSelectChannelPopupPacket; import logisticspipes.network.packets.pipe.InvSysConResistance; @@ -185,6 +186,12 @@ protected void actionPerformed(GuiButton button) throws IOException { } } + @Override + public void onGuiClosed() { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(pipe.container)); + super.onGuiClosed(); + } + @Override protected void mouseClicked(int x, int y, int k) throws IOException { if (!resistanceCountBar.handleClick(x, y, k)) { diff --git a/common/logisticspipes/gui/GuiLogisticsCraftingTable.java b/common/logisticspipes/gui/GuiLogisticsCraftingTable.java index 530a723363..dfc1dc8d5a 100644 --- a/common/logisticspipes/gui/GuiLogisticsCraftingTable.java +++ b/common/logisticspipes/gui/GuiLogisticsCraftingTable.java @@ -10,6 +10,7 @@ import logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity; import logisticspipes.network.PacketHandler; import logisticspipes.network.packets.block.CraftingCycleRecipe; +import logisticspipes.network.packets.gui.GuiClosePacket; import logisticspipes.proxy.MainProxy; import logisticspipes.utils.gui.DummyContainer; import logisticspipes.utils.gui.GuiGraphics; @@ -109,6 +110,12 @@ protected void actionPerformed(GuiButton button) { } } + @Override + public void onGuiClosed() { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(_crafter)); + super.onGuiClosed(); + } + private boolean isMouseInFuzzyPanel(int mx, int my) { if (fuzzyPanelSelection == -1) { return false; diff --git a/common/logisticspipes/gui/GuiSatellitePipe.java b/common/logisticspipes/gui/GuiSatellitePipe.java index de90fe4d8b..dd0a29f651 100644 --- a/common/logisticspipes/gui/GuiSatellitePipe.java +++ b/common/logisticspipes/gui/GuiSatellitePipe.java @@ -18,6 +18,7 @@ import org.lwjgl.input.Keyboard; import logisticspipes.network.PacketHandler; +import logisticspipes.network.packets.gui.GuiClosePacket; import logisticspipes.network.packets.satpipe.SatelliteSetNamePacket; import logisticspipes.pipes.SatelliteNamingResult; import logisticspipes.proxy.MainProxy; @@ -62,6 +63,7 @@ public void initGui() { @Override public void closeGui() throws IOException { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(satellitePipe.getContainer())); super.closeGui(); Keyboard.enableRepeatEvents(false); } diff --git a/common/logisticspipes/ticks/VersionChecker.java b/common/logisticspipes/ticks/VersionChecker.java index 3930fabc96..757a8159d4 100644 --- a/common/logisticspipes/ticks/VersionChecker.java +++ b/common/logisticspipes/ticks/VersionChecker.java @@ -157,8 +157,7 @@ public VersionInfo call() throws Exception { } /** - * Integration with Version Checker - * (http://www.minecraftforum.net/topic/2721902-/) + * Integration with Version Checker */ private void sendIMCOutdatedMessage(VersionInfo versionInfo) { if (Loader.isModLoaded("VersionChecker")) { From 18017577c9bbfc822ff9f56154ec4e5c229f421f Mon Sep 17 00:00:00 2001 From: Korewa_Li Date: Sat, 28 Jan 2023 13:03:25 +0700 Subject: [PATCH 2/3] Custom method for room checking Currently used for TestBridge --- .../interfaces/IInventoryUtil.java | 11 +++++++ .../modules/ModuleActiveSupplier.java | 4 +-- .../AEInterfaceInventoryHandler.java | 29 +++++++++++++----- .../BuildCraftTransactorHandler.java | 12 ++++++++ .../logisticspipes/utils/InventoryUtil.java | 30 ++++++++++++++++--- .../compat/BarrelInventoryHandler.kt | 15 +++++++++- .../proxy/StorageDrawersProxyImpl.kt | 11 +++++++ 7 files changed, 98 insertions(+), 14 deletions(-) diff --git a/common/logisticspipes/interfaces/IInventoryUtil.java b/common/logisticspipes/interfaces/IInventoryUtil.java index 08104faaf0..715b3d5939 100644 --- a/common/logisticspipes/interfaces/IInventoryUtil.java +++ b/common/logisticspipes/interfaces/IInventoryUtil.java @@ -1,5 +1,6 @@ package logisticspipes.interfaces; +import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; @@ -41,6 +42,16 @@ public interface IInventoryUtil { */ int roomForItem(@Nonnull ItemStack stack); + /** + * Inventory space count which terminates when space for max items are + * found. + * + * @return spaces found. If this is less than max, then there are no + * spaces for that amount. + * @param stacks + */ + boolean roomForItem(@Nonnull Iterator stacks); + @Nonnull Set getItems(); diff --git a/common/logisticspipes/modules/ModuleActiveSupplier.java b/common/logisticspipes/modules/ModuleActiveSupplier.java index 2278dd7972..b628b0cbc5 100644 --- a/common/logisticspipes/modules/ModuleActiveSupplier.java +++ b/common/logisticspipes/modules/ModuleActiveSupplier.java @@ -246,7 +246,7 @@ private void createPatternRequest(IInventoryUtil invUtil) { haveCount = have.getStackSize(); } if ((patternMode.getValue() == PatternMode.Bulk50 && haveCount > needed.getStackSize() / 2) || ( - patternMode.getValue() == PatternMode.Bulk100 && haveCount >= needed.getStackSize())) { + patternMode.getValue() == PatternMode.Bulk100 && haveCount > 0)) { continue; } @@ -337,7 +337,7 @@ private void createSupplyRequest(IInventoryUtil invUtil) { } if (spaceAvailable < 1 || (requestMode.getValue() == SupplyMode.Bulk50 && haveCount > item.getValue() / 2) - || (requestMode.getValue() == SupplyMode.Bulk100 && haveCount >= item.getValue())) { + || (requestMode.getValue() == SupplyMode.Bulk100 && haveCount > 1)) { item.setValue(0); continue; } diff --git a/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java b/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java index 6da2914498..62d4324482 100644 --- a/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java +++ b/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java @@ -1,13 +1,7 @@ package logisticspipes.proxy.specialinventoryhandler; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -184,6 +178,27 @@ public int roomForItem(@Nonnull ItemStack itemStack) { return 0; } + @Override + public boolean roomForItem(@Nonnull Iterator iterator) { + while (iterator.hasNext()){ + ItemStack itemStack = iterator.next(); + IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + IStorageMonitorable tmp = acc.getInventory(source); + if (tmp == null || tmp.getInventory(channel) == null) { + return false; + } + IAEItemStack stack = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(itemStack); + if (stack == null) return false; + while (stack.getStackSize() > 0) { + if (tmp.getInventory(channel).canAccept(stack)) { + return true; + } + stack.decStackSize(1); + } + } + return false; + } + @Override @Nonnull public Set getItems() { diff --git a/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java b/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java index 5855056af2..22bd53852a 100644 --- a/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java +++ b/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java @@ -1,6 +1,7 @@ package logisticspipes.proxy.specialinventoryhandler; import java.util.Collections; +import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; @@ -16,6 +17,8 @@ import logisticspipes.utils.item.ItemIdentifier; import network.rs485.logisticspipes.inventory.ProviderMode; +import org.jetbrains.annotations.NotNull; + public class BuildCraftTransactorHandler extends SpecialInventoryHandler implements SpecialInventoryHandler.Factory { private IItemTransactor cap = null; @@ -68,6 +71,15 @@ public int roomForItem(@Nonnull ItemStack stack) { return stack.getCount() - cap.insert(stack, false, true).getCount(); } + @Override + public boolean roomForItem(@NotNull Iterator stacks) { + while (stacks.hasNext()) { + ItemStack stack = stacks.next(); + if (cap.insert(stack, false, true).getCount() != 0) return false; + } + return true; + } + @Override @Nonnull public Set getItems() { diff --git a/common/logisticspipes/utils/InventoryUtil.java b/common/logisticspipes/utils/InventoryUtil.java index 48661d0c9c..fa15f24c9d 100644 --- a/common/logisticspipes/utils/InventoryUtil.java +++ b/common/logisticspipes/utils/InventoryUtil.java @@ -7,10 +7,7 @@ package logisticspipes.utils; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.*; import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -158,6 +155,31 @@ public int roomForItem(@Nonnull ItemStack stack) { return totalRoom; } + @Override + public boolean roomForItem(@Nonnull Iterator iterator) { + int slot = 0; + while (iterator.hasNext()) { + ItemStack toBeSimulated = iterator.next(); + if (!toBeSimulated.isEmpty()) { + while (slot < this.inventory.getSlots()) { + toBeSimulated = this.inventory.insertItem(slot, toBeSimulated, true); + if (slot == this.inventory.getSlots() - 1) { + return !iterator.hasNext() && toBeSimulated.isEmpty(); + } + + // Always increase slot by default + slot++; + + if (toBeSimulated.isEmpty()) { + break; + } + } + } + } + + return true; + } + @Override public int getSizeInventory() { return inventory.getSlots(); diff --git a/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt b/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt index 7154db6cf2..e675fa2200 100644 --- a/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt +++ b/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt @@ -123,6 +123,19 @@ class BarrelInventoryHandler(val tile: IBarrel, val mode: ProviderMode) : Specia } else 0 } + /** + * This function isn't required!!! + */ + override fun roomForItem(stacks: MutableIterator): Boolean { + while (stacks.hasNext()) { + val identifier = ItemIdentifier.get(stacks.next()) + return if (isValidItem(identifier)) { + tile.maxItemCount >= itemCount(identifier) + } else false + } + return false + } + override fun itemCount(itemIdent: ItemIdentifier): Int { return if (!isEmpty() && isValidItem(itemIdent)) tile.itemCount.providerMode() else 0 @@ -155,4 +168,4 @@ class BarrelInventoryHandler(val tile: IBarrel, val mode: ProviderMode) : Specia * Returns the ItemIdentifier from the getItem method. */ private fun getIdentifier(): ItemIdentifier = ItemIdentifier.get(getItem()) -} \ No newline at end of file +} diff --git a/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt b/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt index 02cc2f9a9f..96329050fb 100644 --- a/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt +++ b/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt @@ -185,6 +185,17 @@ class StorageDrawersInventoryHandler( .let { if (it.isEnabled && it.canItemBeStored(stack)) it.acceptingRemainingCapacity else 0 } }.sum() + override fun roomForItem(stacks: MutableIterator): Boolean { + while (stacks.hasNext()) { + val stack = stacks.next() + if (accessibleDrawerSlots().map { slot -> + drawerGroup.getDrawer(slot) + .let { if (it.isEnabled && it.canItemBeStored(stack)) it.acceptingRemainingCapacity else 0 } + }.sum() != stack.count) return false + } + return true + } + override fun getSingleItem(item: ItemIdentifier?): ItemStack = throw NotImplementedError("Unused operation") } From 2735804a754629ce0d9f02a15fdb09960e940737 Mon Sep 17 00:00:00 2001 From: Korewa_Li Date: Wed, 1 Feb 2023 00:29:25 +0700 Subject: [PATCH 3/3] Null checker, remove unnecessary method --- common/logisticspipes/gui/GuiChassisPipe.java | 6 +++- common/logisticspipes/gui/GuiFirewall.java | 6 +++- .../gui/GuiFluidSupplierMk2Pipe.java | 6 +++- .../gui/GuiFluidSupplierPipe.java | 6 +++- .../gui/GuiInvSysConnector.java | 7 +++-- .../logisticspipes/gui/GuiSatellitePipe.java | 5 +++- .../interfaces/IInventoryUtil.java | 11 ------- .../AEInterfaceInventoryHandler.java | 29 +++++------------- .../BuildCraftTransactorHandler.java | 12 -------- .../logisticspipes/utils/InventoryUtil.java | 30 +++---------------- .../compat/BarrelInventoryHandler.kt | 13 -------- .../proxy/StorageDrawersProxyImpl.kt | 11 ------- 12 files changed, 40 insertions(+), 102 deletions(-) diff --git a/common/logisticspipes/gui/GuiChassisPipe.java b/common/logisticspipes/gui/GuiChassisPipe.java index d0ab6d48fc..dc914458b8 100644 --- a/common/logisticspipes/gui/GuiChassisPipe.java +++ b/common/logisticspipes/gui/GuiChassisPipe.java @@ -15,6 +15,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import logisticspipes.config.Configs; import logisticspipes.items.ItemModule; @@ -117,7 +118,10 @@ private void updateModuleConfigButtonVisibility(int slot) { @Override public void onGuiClosed() { - MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(_chassiPipe.container)); + final TileEntity container = _chassiPipe.getContainer(); + if (container != null) { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(container)); + } super.onGuiClosed(); } diff --git a/common/logisticspipes/gui/GuiFirewall.java b/common/logisticspipes/gui/GuiFirewall.java index 8220d48342..fda6522901 100644 --- a/common/logisticspipes/gui/GuiFirewall.java +++ b/common/logisticspipes/gui/GuiFirewall.java @@ -2,6 +2,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; import logisticspipes.network.PacketHandler; import logisticspipes.network.packets.gui.GuiClosePacket; @@ -70,7 +71,10 @@ protected void actionPerformed(GuiButton button) { @Override public void onGuiClosed() { - MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(pipe.container)); + final TileEntity container = pipe.getContainer(); + if (container != null) { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(container)); + } super.onGuiClosed(); } diff --git a/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java b/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java index 810d6bc4fb..f87ec6e659 100644 --- a/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java +++ b/common/logisticspipes/gui/GuiFluidSupplierMk2Pipe.java @@ -10,6 +10,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; import logisticspipes.network.PacketHandler; import logisticspipes.network.packets.gui.GuiClosePacket; @@ -115,7 +116,10 @@ protected void actionPerformed(GuiButton guibutton) throws IOException { @Override public void onGuiClosed() { - MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(logic.container)); + final TileEntity container = logic.getContainer(); + if (container != null) { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(container)); + } super.onGuiClosed(); } } diff --git a/common/logisticspipes/gui/GuiFluidSupplierPipe.java b/common/logisticspipes/gui/GuiFluidSupplierPipe.java index dc5b69b697..1529d58e4d 100644 --- a/common/logisticspipes/gui/GuiFluidSupplierPipe.java +++ b/common/logisticspipes/gui/GuiFluidSupplierPipe.java @@ -10,6 +10,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -89,7 +90,10 @@ protected void actionPerformed(GuiButton guibutton) throws IOException { @Override public void onGuiClosed() { - MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(logic.container)); + final TileEntity container = logic.getContainer(); + if (container != null) { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(container)); + } super.onGuiClosed(); } } diff --git a/common/logisticspipes/gui/GuiInvSysConnector.java b/common/logisticspipes/gui/GuiInvSysConnector.java index c1587beffe..22b9ac7626 100644 --- a/common/logisticspipes/gui/GuiInvSysConnector.java +++ b/common/logisticspipes/gui/GuiInvSysConnector.java @@ -8,6 +8,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -188,8 +189,10 @@ protected void actionPerformed(GuiButton button) throws IOException { @Override public void onGuiClosed() { - MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(pipe.container)); - super.onGuiClosed(); + final TileEntity container = pipe.getContainer(); + if (container != null) { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(container)); + } super.onGuiClosed(); } @Override diff --git a/common/logisticspipes/gui/GuiSatellitePipe.java b/common/logisticspipes/gui/GuiSatellitePipe.java index dd0a29f651..3fdfcb8e2e 100644 --- a/common/logisticspipes/gui/GuiSatellitePipe.java +++ b/common/logisticspipes/gui/GuiSatellitePipe.java @@ -63,7 +63,10 @@ public void initGui() { @Override public void closeGui() throws IOException { - MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(satellitePipe.getContainer())); + final TileEntity container = satellitePipe.getContainer(); + if (container != null) { + MainProxy.sendPacketToServer(PacketHandler.getPacket(GuiClosePacket.class).setTilePos(container)); + } super.closeGui(); Keyboard.enableRepeatEvents(false); } diff --git a/common/logisticspipes/interfaces/IInventoryUtil.java b/common/logisticspipes/interfaces/IInventoryUtil.java index 715b3d5939..08104faaf0 100644 --- a/common/logisticspipes/interfaces/IInventoryUtil.java +++ b/common/logisticspipes/interfaces/IInventoryUtil.java @@ -1,6 +1,5 @@ package logisticspipes.interfaces; -import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; @@ -42,16 +41,6 @@ public interface IInventoryUtil { */ int roomForItem(@Nonnull ItemStack stack); - /** - * Inventory space count which terminates when space for max items are - * found. - * - * @return spaces found. If this is less than max, then there are no - * spaces for that amount. - * @param stacks - */ - boolean roomForItem(@Nonnull Iterator stacks); - @Nonnull Set getItems(); diff --git a/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java b/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java index 62d4324482..6da2914498 100644 --- a/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java +++ b/common/logisticspipes/proxy/specialinventoryhandler/AEInterfaceInventoryHandler.java @@ -1,7 +1,13 @@ package logisticspipes.proxy.specialinventoryhandler; -import java.util.*; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -178,27 +184,6 @@ public int roomForItem(@Nonnull ItemStack itemStack) { return 0; } - @Override - public boolean roomForItem(@Nonnull Iterator iterator) { - while (iterator.hasNext()){ - ItemStack itemStack = iterator.next(); - IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); - IStorageMonitorable tmp = acc.getInventory(source); - if (tmp == null || tmp.getInventory(channel) == null) { - return false; - } - IAEItemStack stack = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(itemStack); - if (stack == null) return false; - while (stack.getStackSize() > 0) { - if (tmp.getInventory(channel).canAccept(stack)) { - return true; - } - stack.decStackSize(1); - } - } - return false; - } - @Override @Nonnull public Set getItems() { diff --git a/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java b/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java index 22bd53852a..5855056af2 100644 --- a/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java +++ b/common/logisticspipes/proxy/specialinventoryhandler/BuildCraftTransactorHandler.java @@ -1,7 +1,6 @@ package logisticspipes.proxy.specialinventoryhandler; import java.util.Collections; -import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; @@ -17,8 +16,6 @@ import logisticspipes.utils.item.ItemIdentifier; import network.rs485.logisticspipes.inventory.ProviderMode; -import org.jetbrains.annotations.NotNull; - public class BuildCraftTransactorHandler extends SpecialInventoryHandler implements SpecialInventoryHandler.Factory { private IItemTransactor cap = null; @@ -71,15 +68,6 @@ public int roomForItem(@Nonnull ItemStack stack) { return stack.getCount() - cap.insert(stack, false, true).getCount(); } - @Override - public boolean roomForItem(@NotNull Iterator stacks) { - while (stacks.hasNext()) { - ItemStack stack = stacks.next(); - if (cap.insert(stack, false, true).getCount() != 0) return false; - } - return true; - } - @Override @Nonnull public Set getItems() { diff --git a/common/logisticspipes/utils/InventoryUtil.java b/common/logisticspipes/utils/InventoryUtil.java index fa15f24c9d..48661d0c9c 100644 --- a/common/logisticspipes/utils/InventoryUtil.java +++ b/common/logisticspipes/utils/InventoryUtil.java @@ -7,7 +7,10 @@ package logisticspipes.utils; -import java.util.*; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -155,31 +158,6 @@ public int roomForItem(@Nonnull ItemStack stack) { return totalRoom; } - @Override - public boolean roomForItem(@Nonnull Iterator iterator) { - int slot = 0; - while (iterator.hasNext()) { - ItemStack toBeSimulated = iterator.next(); - if (!toBeSimulated.isEmpty()) { - while (slot < this.inventory.getSlots()) { - toBeSimulated = this.inventory.insertItem(slot, toBeSimulated, true); - if (slot == this.inventory.getSlots() - 1) { - return !iterator.hasNext() && toBeSimulated.isEmpty(); - } - - // Always increase slot by default - slot++; - - if (toBeSimulated.isEmpty()) { - break; - } - } - } - } - - return true; - } - @Override public int getSizeInventory() { return inventory.getSlots(); diff --git a/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt b/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt index e675fa2200..cbfc841d7e 100644 --- a/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt +++ b/src/main/kotlin/network/rs485/logisticspipes/compat/BarrelInventoryHandler.kt @@ -123,19 +123,6 @@ class BarrelInventoryHandler(val tile: IBarrel, val mode: ProviderMode) : Specia } else 0 } - /** - * This function isn't required!!! - */ - override fun roomForItem(stacks: MutableIterator): Boolean { - while (stacks.hasNext()) { - val identifier = ItemIdentifier.get(stacks.next()) - return if (isValidItem(identifier)) { - tile.maxItemCount >= itemCount(identifier) - } else false - } - return false - } - override fun itemCount(itemIdent: ItemIdentifier): Int { return if (!isEmpty() && isValidItem(itemIdent)) tile.itemCount.providerMode() else 0 diff --git a/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt b/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt index 96329050fb..02cc2f9a9f 100644 --- a/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt +++ b/src/main/kotlin/network/rs485/logisticspipes/proxy/StorageDrawersProxyImpl.kt @@ -185,17 +185,6 @@ class StorageDrawersInventoryHandler( .let { if (it.isEnabled && it.canItemBeStored(stack)) it.acceptingRemainingCapacity else 0 } }.sum() - override fun roomForItem(stacks: MutableIterator): Boolean { - while (stacks.hasNext()) { - val stack = stacks.next() - if (accessibleDrawerSlots().map { slot -> - drawerGroup.getDrawer(slot) - .let { if (it.isEnabled && it.canItemBeStored(stack)) it.acceptingRemainingCapacity else 0 } - }.sum() != stack.count) return false - } - return true - } - override fun getSingleItem(item: ItemIdentifier?): ItemStack = throw NotImplementedError("Unused operation") }