From 7ef016ccced5897d680009977334df7eac41f57b Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 2 Jun 2025 20:09:13 +0300 Subject: [PATCH] Make mass storage process output instantly Same deal as previously, this bypasses the bottleneck of tile entity ticking and network latency. This change is less relevant than the previous one, because there shift-dragging or shift-double-clicking were possible with mods, while here it only really affects autoclickers. Still, it can't hurt --- .../container/ContainerMassStorage.java | 7 ++++++- .../storage/TileEntityMassStorage.java | 20 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hbm/inventory/container/ContainerMassStorage.java b/src/main/java/com/hbm/inventory/container/ContainerMassStorage.java index d0ffae2ee..fae68ad3a 100644 --- a/src/main/java/com/hbm/inventory/container/ContainerMassStorage.java +++ b/src/main/java/com/hbm/inventory/container/ContainerMassStorage.java @@ -31,6 +31,11 @@ public class ContainerMassStorage extends ContainerBase { ItemStack result = null; Slot slot = (Slot) this.inventorySlots.get(index); + // Refill instantly if needed, then do regular slot behavior + if(index == 2 && slot != null && !slot.getHasStack()) { + slot.putStack(storage.quickExtract()); + } + if(slot != null && slot.getHasStack()) { ItemStack initial = slot.getStack(); result = initial.copy(); @@ -41,7 +46,7 @@ public class ContainerMassStorage extends ContainerBase { } } else { // Try to insert instantly, then fall back to regular slot behavior - if(!storage.insert(initial) && !this.mergeItemStack(initial, 0, 1, false)) { + if(!storage.quickInsert(initial) && !this.mergeItemStack(initial, 0, 1, false)) { return null; } } diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java index fe6f15414..0618a1643 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java @@ -99,7 +99,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa return getType() != null && getStockpile() < getCapacity() && stack != null && stack.isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(stack, getType()); } - public boolean insert(ItemStack stack) { + public boolean quickInsert(ItemStack stack) { if (!canInsert(stack)) return false; @@ -115,6 +115,24 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa return true; } + public ItemStack quickExtract() { + if (!output) { + return null; + } + + int amount = getType().getMaxStackSize(); + + if (getStockpile() < amount) + return null; + + ItemStack result = slots[1].copy(); + result.stackSize = amount; + this.stack -= amount; + this.markDirty(); + + return result; + } + @Override public void serialize(ByteBuf buf) { buf.writeInt(this.stack);