|
| 1 | +package org.cyclops.evilcraft.gametest; |
| 2 | + |
| 3 | +import net.minecraft.core.BlockPos; |
| 4 | +import net.minecraft.core.registries.Registries; |
| 5 | +import net.minecraft.gametest.framework.GameTestHelper; |
| 6 | +import net.minecraft.network.chat.Component; |
| 7 | +import net.minecraft.resources.Identifier; |
| 8 | +import net.minecraft.tags.BlockTags; |
| 9 | +import net.minecraft.tags.ItemTags; |
| 10 | +import net.minecraft.tags.TagKey; |
| 11 | +import net.minecraft.world.item.Item; |
| 12 | +import net.minecraft.world.item.ItemStack; |
| 13 | +import net.minecraft.world.level.block.Block; |
| 14 | +import net.minecraft.world.level.block.state.BlockState; |
| 15 | +import org.cyclops.cyclopscore.gametest.GameTest; |
| 16 | +import org.cyclops.evilcraft.Reference; |
| 17 | +import org.cyclops.evilcraft.RegistryEntries; |
| 18 | + |
| 19 | +import java.util.List; |
| 20 | + |
| 21 | +public class GameTestsUndeadLogTags { |
| 22 | + |
| 23 | + public static final String TEMPLATE_EMPTY = Reference.MOD_ID + ":empty10"; |
| 24 | + public static final BlockPos POS = BlockPos.ZERO.offset(2, 0, 2); |
| 25 | + |
| 26 | + private static final TagKey<Block> BLOCK_C_LOGS_THAT_BURN = TagKey.create(Registries.BLOCK, Identifier.parse("c:logs_that_burn")); |
| 27 | + private static final TagKey<Item> ITEM_C_LOGS_THAT_BURN = TagKey.create(Registries.ITEM, Identifier.parse("c:logs_that_burn")); |
| 28 | + |
| 29 | + private static List<Block> getUndeadLogs() { |
| 30 | + return List.of( |
| 31 | + RegistryEntries.BLOCK_UNDEAD_LOG.get(), |
| 32 | + RegistryEntries.BLOCK_UNDEAD_LOG_STRIPPED.get(), |
| 33 | + RegistryEntries.BLOCK_UNDEAD_WOOD.get(), |
| 34 | + RegistryEntries.BLOCK_UNDEAD_WOOD_STRIPPED.get() |
| 35 | + ); |
| 36 | + } |
| 37 | + |
| 38 | + @GameTest(template = TEMPLATE_EMPTY) |
| 39 | + public void testUndeadLogsBlockTags(GameTestHelper helper) { |
| 40 | + for (Block block : getUndeadLogs()) { |
| 41 | + helper.setBlock(POS, block); |
| 42 | + BlockState state = helper.getBlockState(POS); |
| 43 | + helper.assertTrue(state.is(BlockTags.LOGS), Component.literal(block + " is not in minecraft:logs")); |
| 44 | + helper.assertTrue(state.is(BlockTags.LOGS_THAT_BURN), Component.literal(block + " is not in minecraft:logs_that_burn")); |
| 45 | + helper.assertTrue(state.is(BLOCK_C_LOGS_THAT_BURN), Component.literal(block + " is not in c:logs_that_burn")); |
| 46 | + } |
| 47 | + helper.succeed(); |
| 48 | + } |
| 49 | + |
| 50 | + @GameTest(template = TEMPLATE_EMPTY) |
| 51 | + public void testUndeadLogsItemTagsAndFuel(GameTestHelper helper) { |
| 52 | + for (Block block : getUndeadLogs()) { |
| 53 | + ItemStack itemStack = new ItemStack(block); |
| 54 | + helper.assertTrue(itemStack.is(ItemTags.LOGS), Component.literal(block + " item is not in minecraft:logs")); |
| 55 | + helper.assertTrue(itemStack.is(ItemTags.LOGS_THAT_BURN), Component.literal(block + " item is not in minecraft:logs_that_burn")); |
| 56 | + helper.assertTrue(itemStack.is(ITEM_C_LOGS_THAT_BURN), Component.literal(block + " item is not in c:logs_that_burn")); |
| 57 | + helper.assertTrue(helper.getLevel().fuelValues().burnDuration(itemStack) > 0, Component.literal(block + " item is not a furnace fuel")); |
| 58 | + } |
| 59 | + helper.succeed(); |
| 60 | + } |
| 61 | + |
| 62 | +} |
0 commit comments