|
7 | 7 | import net.minecraft.world.InteractionHand; |
8 | 8 | import net.minecraft.world.entity.player.Player; |
9 | 9 | import net.minecraft.world.item.ItemStack; |
| 10 | +import net.minecraft.world.item.Items; |
10 | 11 | import net.minecraft.world.level.GameType; |
11 | 12 | import net.minecraft.world.level.block.Blocks; |
12 | 13 | import net.minecraft.world.level.block.entity.ChestBlockEntity; |
@@ -235,6 +236,46 @@ public void testCraftFromChestsToChestStairs(GameTestHelper helper) { |
235 | 236 | }); |
236 | 237 | } |
237 | 238 |
|
| 239 | + @GameTest(template = TEMPLATE_EMPTY) |
| 240 | + public void testCraftFromChestsToChestCakeReusable(GameTestHelper helper) { |
| 241 | + helper.setBlock(POS.offset(2, 2, 2), RegistryEntries.BLOCK_STRUCTURED_CRAFTER.value() |
| 242 | + .defaultBlockState() |
| 243 | + .setValue(BlockStructuredCrafter.FACING, Direction.NORTH)); |
| 244 | + |
| 245 | + // Define inputs |
| 246 | + setChestWithItem(helper, POS.offset(3, 3, 3), new ItemStack(Items.MILK_BUCKET)); |
| 247 | + setChestWithItem(helper, POS.offset(2, 3, 3), new ItemStack(Items.MILK_BUCKET)); |
| 248 | + setChestWithItem(helper, POS.offset(1, 3, 3), new ItemStack(Items.MILK_BUCKET)); |
| 249 | + setChestWithItem(helper, POS.offset(3, 2, 3), new ItemStack(Items.SUGAR)); |
| 250 | + setChestWithItem(helper, POS.offset(2, 2, 3), new ItemStack(Items.EGG)); |
| 251 | + setChestWithItem(helper, POS.offset(1, 2, 3), new ItemStack(Items.SUGAR)); |
| 252 | + setChestWithItem(helper, POS.offset(3, 1, 3), new ItemStack(Items.WHEAT)); |
| 253 | + setChestWithItem(helper, POS.offset(2, 1, 3), new ItemStack(Items.WHEAT)); |
| 254 | + setChestWithItem(helper, POS.offset(1, 1, 3), new ItemStack(Items.WHEAT)); |
| 255 | + |
| 256 | + // Set output chest |
| 257 | + helper.setBlock(POS.offset(2, 2, 1), Blocks.CHEST); |
| 258 | + |
| 259 | + // Activate crafter |
| 260 | + helper.setBlock(POS.offset(1, 2, 2), Blocks.REDSTONE_BLOCK); |
| 261 | + |
| 262 | + helper.succeedWhen(() -> { |
| 263 | + // Result |
| 264 | + assertChestContains(helper, POS.offset(2, 2, 1), new ItemStack(Blocks.CAKE)); |
| 265 | + |
| 266 | + // Inputs must be consumed |
| 267 | + assertChestContains(helper, POS.offset(3, 3, 3), new ItemStack(Items.BUCKET)); |
| 268 | + assertChestContains(helper, POS.offset(2, 3, 3), new ItemStack(Items.BUCKET)); |
| 269 | + assertChestContains(helper, POS.offset(1, 3, 3), new ItemStack(Items.BUCKET)); |
| 270 | + assertChestEmpty(helper, POS.offset(3, 2, 3)); |
| 271 | + assertChestEmpty(helper, POS.offset(2, 2, 3)); |
| 272 | + assertChestEmpty(helper, POS.offset(1, 2, 3)); |
| 273 | + assertChestEmpty(helper, POS.offset(3, 1, 3)); |
| 274 | + assertChestEmpty(helper, POS.offset(2, 1, 3)); |
| 275 | + assertChestEmpty(helper, POS.offset(1, 1, 3)); |
| 276 | + }); |
| 277 | + } |
| 278 | + |
238 | 279 | protected void setChestWithItem(GameTestHelper helper, BlockPos pos, ItemStack itemStack) { |
239 | 280 | helper.setBlock(pos, Blocks.CHEST); |
240 | 281 | ChestBlockEntity chest = helper.getBlockEntity(pos); |
|
0 commit comments