Skip to content

Commit 5e7babc

Browse files
committed
fix: drop excess refund items into world on research cancel
When cost slots were full at cancel time, refund items were silently discarded with only a log warning. Excess items are now spawned as item entities at the block position via Containers.dropItemStack(), matching the same behaviour as block breaking.
1 parent f19f63e commit 5e7babc

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/com/researchcube/block/ResearchTableBlockEntity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,12 @@ public void cancelResearchWithRefund() {
576576
refundStack = inventory.insertItem(i, refundStack, false);
577577
}
578578

579-
// If slots are full, items are lost (edge case — player filled slots)
580-
if (!refundStack.isEmpty()) {
581-
ResearchCubeMod.LOGGER.warn("Could not fully refund {} x{} during cancel — {} lost",
579+
// If slots are full, drop excess items into the world
580+
if (!refundStack.isEmpty() && level != null) {
581+
BlockPos pos = getBlockPos();
582+
Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), refundStack);
583+
} else if (!refundStack.isEmpty()) {
584+
ResearchCubeMod.LOGGER.warn("Could not fully refund {} x{} during cancel — {} lost (no level)",
582585
cost.itemId(), cost.count(), refundStack.getCount());
583586
}
584587
}

0 commit comments

Comments
 (0)