|
| 1 | +/* |
| 2 | + * Copyright (c) NeoForged and contributors |
| 3 | + * SPDX-License-Identifier: LGPL-2.1-only |
| 4 | + */ |
| 5 | + |
| 6 | +package net.neoforged.neoforge.debug.crafting; |
| 7 | + |
| 8 | +import net.minecraft.core.BlockPos; |
| 9 | +import net.minecraft.world.item.Item; |
| 10 | +import net.minecraft.world.item.ItemStack; |
| 11 | +import net.minecraft.world.item.Items; |
| 12 | +import net.minecraft.world.level.block.Blocks; |
| 13 | +import net.minecraft.world.level.block.entity.FurnaceBlockEntity; |
| 14 | +import net.neoforged.testframework.DynamicTest; |
| 15 | +import net.neoforged.testframework.annotation.ForEachTest; |
| 16 | +import net.neoforged.testframework.annotation.TestHolder; |
| 17 | +import net.neoforged.testframework.gametest.EmptyTemplate; |
| 18 | +import net.neoforged.testframework.gametest.GameTest; |
| 19 | + |
| 20 | +@ForEachTest(groups = "crafting_remainder_tests") |
| 21 | +public interface CraftingRemainderTests { |
| 22 | + @GameTest |
| 23 | + @EmptyTemplate |
| 24 | + @TestHolder(description = "Ensures lava buckets turn into empty buckets when used as fuel", enabledByDefault = true) |
| 25 | + static void testLavaBucketToEmptyBucket(DynamicTest test) { |
| 26 | + test.onGameTest(helper -> helper.startSequence() |
| 27 | + .thenExecute(() -> helper.setBlock(BlockPos.ZERO, Blocks.FURNACE)) |
| 28 | + .thenMap(() -> helper.getBlockEntity(BlockPos.ZERO, FurnaceBlockEntity.class)) |
| 29 | + .thenExecute(furnace -> { |
| 30 | + furnace.setItem(/* AbstractFurnaceBlockEntity.SLOT_INPUT */ 0, new ItemStack(Items.RAW_IRON, 64)); |
| 31 | + furnace.setItem(/* AbstractFurnaceBlockEntity.SLOT_FUEL */ 1, new ItemStack(Items.LAVA_BUCKET)); |
| 32 | + }) |
| 33 | + .thenIdle(1) |
| 34 | + .thenMap(furnace -> furnace.getItem(/* AbstractFurnaceBlockEntity.SLOT_FUEL */ 1)) |
| 35 | + .thenExecute(fuel -> { |
| 36 | + if (!fuel.is(Items.BUCKET)) { |
| 37 | + helper.fail("Exepected crafting raminder to be '" + itemName(Items.BUCKET) + "' but found '" + itemName(fuel.getItem()) + "'"); |
| 38 | + } |
| 39 | + }) |
| 40 | + .thenSucceed()); |
| 41 | + } |
| 42 | + |
| 43 | + private static String itemName(Item item) { |
| 44 | + return item.builtInRegistryHolder().getRegisteredName(); |
| 45 | + } |
| 46 | +} |
0 commit comments