|
12 | 12 | import net.minecraft.util.RandomSource; |
13 | 13 | import net.minecraft.world.item.ItemStack; |
14 | 14 | import net.minecraft.world.item.component.CustomData; |
| 15 | +import net.neoforged.neoforge.items.ItemHandlerHelper; |
15 | 16 | import net.neoforged.neoforge.items.ItemStackHandler; |
16 | 17 | import ru.zznty.create_factory_abstractions.generic.support.GenericOrder; |
17 | 18 |
|
@@ -153,8 +154,16 @@ protected List<BigItemStack> repackBasedOnRecipes(InventorySummary summary, Pack |
153 | 154 |
|
154 | 155 | ItemStackHandler target = new ItemStackHandler(PackageItem.SLOTS); |
155 | 156 | List<BigItemStack> stacks = craftingEntry.pattern().stacks(); |
156 | | - for (int currentSlot = 0; currentSlot < Math.min(stacks.size(), target.getSlots()); currentSlot++) |
157 | | - target.setStackInSlot(currentSlot, stacks.get(currentSlot).stack.copyWithCount(1)); |
| 157 | +// for (int currentSlot = 0; currentSlot < Math.min(stacks.size(), target.getSlots()); currentSlot++) |
| 158 | +// target.setStackInSlot(currentSlot, stacks.get(currentSlot).stack.copyWithCount(1)); |
| 159 | + |
| 160 | + for (BigItemStack stack : stacks) { |
| 161 | + ItemStack leftover = ItemHandlerHelper.insertItemStacked(target, stack.stack.copyWithCount(1), false); |
| 162 | + if (!leftover.isEmpty()) // more than 9 stacks of items |
| 163 | + // i'd like to not fail all recipes in the order, but invalid ones will get voided that way |
| 164 | + // so just pretend crafting context is invalid to yield all items back |
| 165 | + return List.of(); |
| 166 | + } |
158 | 167 |
|
159 | 168 | ItemStack box = PackageItem.containing(target); |
160 | 169 | GenericOrder.set(blockEntity.getLevel().registryAccess(), box, r.nextInt(), 0, true, 0, true, |
|
0 commit comments