diff --git a/src/main/java/appeng/blockentity/misc/CondenserBlockEntity.java b/src/main/java/appeng/blockentity/misc/CondenserBlockEntity.java index 5e3427ad57b..0689ebae53e 100644 --- a/src/main/java/appeng/blockentity/misc/CondenserBlockEntity.java +++ b/src/main/java/appeng/blockentity/misc/CondenserBlockEntity.java @@ -110,28 +110,25 @@ public void addPower(double rawPower) { private void fillOutput() { var requiredPower = this.getRequiredPower(); - var output = this.getOutput(); - while (requiredPower <= this.getStoredPower() && !output.isEmpty() && requiredPower > 0) { - if (this.canAddOutput(output)) { + while (requiredPower <= this.getStoredPower() && !getOutput().isEmpty() && requiredPower > 0) { + if (this.canAddOutput()) { this.setStoredPower(this.getStoredPower() - requiredPower); - this.addOutput(output); + this.addOutput(); } else { break; } } } - private boolean canAddOutput(ItemStack output) { - return this.outputSlot.insertItem(0, output, true).isEmpty(); + boolean canAddOutput() { + return this.outputSlot.insertItem(0, getOutput(), true).isEmpty(); } /** * make sure you validate with canAddOutput prior to this. - * - * @param output to be added output */ - private void addOutput(ItemStack output) { - this.outputSlot.insertItem(0, output, false); + private void addOutput() { + this.outputSlot.insertItem(0, getOutput(), false); } InternalInventory getOutputSlot() { @@ -200,6 +197,11 @@ public ItemStack getStackInSlot(int slot) { return ItemStack.EMPTY; } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + return canAddOutput(); + } + @Override public void setItemDirect(int slotIndex, ItemStack stack) { if (!stack.isEmpty()) { @@ -209,6 +211,9 @@ public void setItemDirect(int slotIndex, ItemStack stack) { @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + if (!canAddOutput()) { + return stack; + } if (!simulate && !stack.isEmpty()) { CondenserBlockEntity.this.addPower(stack.getCount()); } diff --git a/src/main/java/appeng/blockentity/misc/CondenserMEStorage.java b/src/main/java/appeng/blockentity/misc/CondenserMEStorage.java index 77c9ea28621..c1bce57a656 100644 --- a/src/main/java/appeng/blockentity/misc/CondenserMEStorage.java +++ b/src/main/java/appeng/blockentity/misc/CondenserMEStorage.java @@ -37,6 +37,9 @@ class CondenserMEStorage implements MEStorage { @Override public long insert(AEKey what, long amount, Actionable mode, IActionSource source) { MEStorage.checkPreconditions(what, amount, mode, source); + if (!target.canAddOutput()) { + return 0; + } if (mode == Actionable.MODULATE) { this.target.addPower(amount / what.getAmountPerOperation()); }