Skip to content

Commit 1ce17aa

Browse files
committed
Fix stocking hatches duping like crazy (Agh I want to redo how ARL sees and takes items from hatches so badly!1!1!)
1 parent 0a4bf36 commit 1ce17aa

File tree

7 files changed

+34
-32
lines changed

7 files changed

+34
-32
lines changed

src/main/java/gregtech/api/mui/widget/appeng/AEConfigSlot.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import gregtech.api.mui.GTGuis;
55
import gregtech.api.mui.sync.appeng.AESyncHandler;
66

7-
import net.minecraft.client.resources.I18n;
8-
97
import appeng.api.storage.data.IAEStack;
108
import com.cleanroommc.modularui.api.IPanelHandler;
119
import com.cleanroommc.modularui.api.drawable.IDrawable;

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputBase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import gregtech.api.capability.IControllable;
66
import gregtech.api.capability.IGhostSlotConfigurable;
77
import gregtech.api.capability.impl.GhostCircuitItemStackHandler;
8-
import gregtech.api.metatileentity.multiblock.MultiblockControllerBase;
98
import gregtech.api.mui.GTGuiTextures;
109
import gregtech.api.mui.GTGuis;
1110
import gregtech.api.mui.sync.appeng.AEFluidSyncHandler;

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEStockingBus.java

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -411,37 +411,38 @@ public ExportOnlyAEStockingItemSlot(MetaTileEntityMEStockingBus holder) {
411411

412412
@Override
413413
public @NotNull ItemStack extractItem(int slot, int amount, boolean simulate) {
414-
if (slot == 0 && this.stock != null) {
415-
if (this.config != null) {
416-
// Extract the items from the real net to either validate (simulate)
417-
// or extract (modulate) when this is called
418-
IMEMonitor<IAEItemStack> monitor = holder.getMonitor();
419-
if (monitor == null) return ItemStack.EMPTY;
420-
421-
Actionable action = simulate ? Actionable.SIMULATE : Actionable.MODULATE;
422-
IAEItemStack request;
423-
if (this.config instanceof WrappedItemStack wis) {
424-
request = wis.getAEStack();
425-
} else {
426-
request = this.config.copy();
414+
if (slot != 0 || this.stock == null || this.stock.getStackSize() <= 0) return ItemStack.EMPTY;
415+
416+
if (this.config != null) {
417+
// Extract the items from the real net to either validate (simulate)
418+
// or extract (modulate) when this is called
419+
IMEMonitor<IAEItemStack> monitor = holder.getMonitor();
420+
if (monitor == null) return ItemStack.EMPTY;
421+
422+
Actionable action = simulate ? Actionable.SIMULATE : Actionable.MODULATE;
423+
IAEItemStack request;
424+
if (this.config instanceof WrappedItemStack wis) {
425+
request = wis.getAEStack();
426+
} else {
427+
request = this.config.copy();
428+
}
429+
request.setStackSize(amount);
430+
431+
IAEItemStack result = monitor.extractItems(request, action, holder.getActionSource());
432+
if (result != null) {
433+
int extracted = (int) Math.min(result.getStackSize(), amount);
434+
this.stock.decStackSize(extracted); // may as well update the display here
435+
if (this.trigger != null) {
436+
this.trigger.accept(0);
427437
}
428-
request.setStackSize(amount);
429-
430-
IAEItemStack result = monitor.extractItems(request, action, holder.getActionSource());
431-
if (result != null) {
432-
int extracted = (int) Math.min(result.getStackSize(), amount);
433-
this.stock.decStackSize(extracted); // may as well update the display here
434-
if (this.trigger != null) {
435-
this.trigger.accept(0);
436-
}
437-
if (extracted != 0) {
438-
ItemStack resultStack = this.config.createItemStack();
439-
resultStack.setCount(extracted);
440-
return resultStack;
441-
}
438+
if (extracted != 0) {
439+
ItemStack resultStack = this.config.createItemStack();
440+
resultStack.setCount(extracted);
441+
return resultStack;
442442
}
443443
}
444444
}
445+
445446
return ItemStack.EMPTY;
446447
}
447448
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEStockingHatch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,10 @@ protected MetaTileEntityMEStockingHatch getHolder() {
414414

415415
@Override
416416
public @Nullable FluidStack drain(int maxDrain, boolean doDrain) {
417-
if (this.stock == null) {
417+
if (this.stock == null || this.stock.getStackSize() <= 0) {
418418
return null;
419419
}
420+
420421
if (this.config != null) {
421422
IMEMonitor<IAEFluidStack> monitor = getHolder().getMonitor();
422423
if (monitor == null) return null;

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/slot/ExportOnlyAEFluidSlot.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public FluidStack getFluid() {
105105
if (this.stock instanceof WrappedFluidStack wrappedFluidStack) {
106106
return wrappedFluidStack.getDefinition();
107107
}
108+
108109
return null;
109110
}
110111

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/stack/WrappedFluidStack.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ public Fluid getFluid() {
217217

218218
@Override
219219
public @NotNull FluidStack getDefinition() {
220+
delegate.amount = (int) stackSize;
220221
return delegate;
221222
}
222223

@@ -247,6 +248,6 @@ public int hashCode() {
247248

248249
@Override
249250
public String toString() {
250-
return String.format("Wrapped: %s", delegate);
251+
return String.format("Wrapped: %s, Stack Size: %d", delegate, stackSize);
251252
}
252253
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/stack/WrappedItemStack.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ public boolean isSameType(ItemStack itemStack) {
250250

251251
@Override
252252
public @NotNull ItemStack getDefinition() {
253+
delegate.setCount((int) stackSize);
253254
return this.delegate;
254255
}
255256

0 commit comments

Comments
 (0)