|
19 | 19 | package dev.technici4n.moderndynamics.test; |
20 | 20 |
|
21 | 21 | import dev.technici4n.moderndynamics.init.MdBlocks; |
| 22 | +import dev.technici4n.moderndynamics.init.MdItems; |
22 | 23 | import dev.technici4n.moderndynamics.test.framework.MdGameTestHelper; |
23 | 24 | import net.minecraft.core.BlockPos; |
| 25 | +import net.minecraft.core.Direction; |
24 | 26 | import net.minecraft.world.item.ItemStack; |
25 | 27 | import net.minecraft.world.item.Items; |
26 | 28 | import net.minecraft.world.level.block.Blocks; |
@@ -55,4 +57,38 @@ public void testHopperInsertingDamagedItem(MdGameTestHelper helper) { |
55 | 57 | }) |
56 | 58 | .thenSucceed(); |
57 | 59 | } |
| 60 | + |
| 61 | + @MdGameTest |
| 62 | + public void testExtractorLimitIsForEntireInventory(MdGameTestHelper helper) { |
| 63 | + var sourceChest = new BlockPos(0, 1, 0); |
| 64 | + helper.setBlock(sourceChest, Blocks.CHEST.defaultBlockState()); |
| 65 | + var chest = (ChestBlockEntity) helper.getBlockEntity(sourceChest); |
| 66 | + |
| 67 | + helper.pipe(new BlockPos(1, 1, 0), MdBlocks.ITEM_PIPE) |
| 68 | + .attachment(Direction.WEST, MdItems.EXTRACTOR) |
| 69 | + .configureItemIo(Direction.WEST, io -> { |
| 70 | + io.setMaxItemsExtracted(2); |
| 71 | + }); |
| 72 | + |
| 73 | + var targetChest = new BlockPos(2, 1, 0); |
| 74 | + helper.setBlock(targetChest, Blocks.CHEST.defaultBlockState()); |
| 75 | + |
| 76 | + for (int i = 0; i < 9; ++i) { |
| 77 | + chest.setItem(i, new ItemStack(Items.DIAMOND, 7)); |
| 78 | + } |
| 79 | + |
| 80 | + helper.startSequence() |
| 81 | + .thenIdle(1) |
| 82 | + .thenExecute(() -> { |
| 83 | + if (!ItemStack.matches(new ItemStack(Items.DIAMOND, 5), chest.getItem(0))) { |
| 84 | + helper.fail("Expected 6 diamonds in slot 0", targetChest); |
| 85 | + } |
| 86 | + for (int i = 1; i < 9; ++i) { |
| 87 | + if (!ItemStack.matches(new ItemStack(Items.DIAMOND, 7), chest.getItem(i))) { |
| 88 | + helper.fail("Expected 16 diamonds in slot " + i, targetChest); |
| 89 | + } |
| 90 | + } |
| 91 | + }) |
| 92 | + .thenSucceed(); |
| 93 | + } |
58 | 94 | } |
0 commit comments