From 2e9a5dc8ea4d2500779d329d9e86d104ad38b614 Mon Sep 17 00:00:00 2001 From: PrototypeTrousers Date: Wed, 12 Oct 2022 04:48:02 -0300 Subject: [PATCH] wip interfaces stacksizes --- .../GuiInterfaceConfigurationTerminal.java | 8 ++++++-- .../java/appeng/container/AEBaseContainer.java | 14 ++++---------- .../ContainerInterfaceConfigurationTerminal.java | 5 ++++- src/main/java/appeng/helpers/DualityInterface.java | 4 ++-- .../tile/inventory/AppEngInternalAEInventory.java | 9 ++++++++- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java index e86b2c404..174c176a3 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java @@ -289,7 +289,11 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI for (int x = 0; x < current.getInventory().getSlots(); x++) { final String which = Integer.toString(x); if (invData.hasKey(which)) { - current.getInventory().setStackInSlot(x, new ItemStack(invData.getCompoundTag(which))); + NBTTagCompound tag = invData.getCompoundTag(which); + current.getInventory().setStackInSlot(x, new ItemStack(tag)); + if (tag.hasKey("stackSize")) { + current.getInventory().getStackInSlot(x).setCount(tag.getInteger("stackSize")); + } } } } catch (final NumberFormatException ignored) { @@ -435,7 +439,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI ClientDCInternalInv o = this.byId.get(id); if (o == null) { - this.byId.put(id, o = new ClientDCInternalInv(DualityInterface.NUMBER_OF_CONFIG_SLOTS, id, sortBy, string, 64)); + this.byId.put(id, o = new ClientDCInternalInv(DualityInterface.NUMBER_OF_CONFIG_SLOTS, id, sortBy, string, 512)); this.refreshList = true; } diff --git a/src/main/java/appeng/container/AEBaseContainer.java b/src/main/java/appeng/container/AEBaseContainer.java index 3b8887c02..a9f91af09 100644 --- a/src/main/java/appeng/container/AEBaseContainer.java +++ b/src/main/java/appeng/container/AEBaseContainer.java @@ -545,23 +545,20 @@ public abstract class AEBaseContainer extends Container { switch (action) { case PICKUP_OR_SET_DOWN: - if (hand.isEmpty()) { s.putStack(ItemStack.EMPTY); } else { s.putStack(hand.copy()); } - break; case PLACE_SINGLE: - if (!hand.isEmpty()) { final ItemStack is = hand.copy(); is.setCount(1); s.putStack(is); } else { final ItemStack is = s.getStack().copy(); - if (is.getCount() < is.getMaxStackSize()) + if (is.getCount() < is.getMaxStackSize() * 8) is.grow(1); s.putStack(is); } @@ -575,7 +572,6 @@ public abstract class AEBaseContainer extends Container { } break; case SPLIT_OR_PLACE_SINGLE: - ItemStack is = s.getStack(); if (!is.isEmpty()) { if (hand.isEmpty()) { @@ -586,14 +582,12 @@ public abstract class AEBaseContainer extends Container { is = hand.copy(); is.setCount(1); } - s.putStack(is); } else if (!hand.isEmpty()) { is = hand.copy(); is.setCount(1); s.putStack(is); } - break; case CREATIVE_DUPLICATE: case MOVE_REGION: @@ -606,9 +600,9 @@ public abstract class AEBaseContainer extends Container { if (action == InventoryAction.MOVE_REGION) { final List from = new ArrayList<>(); - for (final Object j : this.inventorySlots) { - if (j instanceof Slot && j.getClass() == s.getClass() && !(j instanceof SlotCraftingTerm)) { - from.add((Slot) j); + for (final Slot j : this.inventorySlots) { + if (j != null && j.getClass() == s.getClass() && !(j instanceof SlotCraftingTerm)) { + from.add(j); } } diff --git a/src/main/java/appeng/container/implementations/ContainerInterfaceConfigurationTerminal.java b/src/main/java/appeng/container/implementations/ContainerInterfaceConfigurationTerminal.java index 75addb848..7209d3aa9 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterfaceConfigurationTerminal.java +++ b/src/main/java/appeng/container/implementations/ContainerInterfaceConfigurationTerminal.java @@ -184,7 +184,7 @@ public final class ContainerInterfaceConfigurationTerminal extends AEBaseContain } break; case PLACE_SINGLE: - if (inSlot.getMaxStackSize() > inSlot.getCount()) { + if (inSlot.getCount() < inSlot.getMaxStackSize() * 8) { inSlot.grow(1); ItemHandlerUtil.setStackInSlot(theSlot, 0, inSlot); } @@ -299,6 +299,9 @@ public final class ContainerInterfaceConfigurationTerminal extends AEBaseContain if (!is.isEmpty()) { is.writeToNBT(itemNBT); + if (is.getCount() > is.getMaxStackSize()) { + itemNBT.setInteger("stackSize", is.getCount()); + } } tag.setTag(Integer.toString(x + offset), itemNBT); diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index b2e936fe0..7c37afe23 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -114,8 +114,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn private final IActionSource mySource; private final IActionSource interfaceRequestSource; private final ConfigManager cm = new ConfigManager(this); - private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS); - private final AppEngInternalInventory storage = new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS); + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS, 512); + private final AppEngInternalInventory storage = new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS, 512); private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, NUMBER_OF_PATTERN_SLOTS); private final MEMonitorPassThrough items = new MEMonitorPassThrough<>(new NullInventory(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); private final MEMonitorPassThrough fluids = new MEMonitorPassThrough<>(new NullInventory(), AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); diff --git a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java index d799912a4..75717d8c4 100644 --- a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java @@ -52,6 +52,13 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab this.inv = new IAEItemStack[s]; } + public AppEngInternalAEInventory(final IAEAppEngInventory te, final int s, int stackSize) { + this.te = te; + this.size = s; + this.maxStack = stackSize; + this.inv = new IAEItemStack[s]; + } + public void setMaxStackSize(final int s) { this.maxStack = s; } @@ -216,7 +223,7 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab @Override public int getSlotLimit(int slot) { - return this.maxStack > 64 ? 64 : this.maxStack; + return this.maxStack; } @Override