-
Notifications
You must be signed in to change notification settings - Fork 753
/
ToolItemTest.java
55 lines (47 loc) · 2.07 KB
/
ToolItemTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package slimeknights.tconstruct.library.tools.item;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.ForgeRegistries;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import slimeknights.tconstruct.fixture.MaterialFixture;
import slimeknights.tconstruct.fixture.MaterialItemFixture;
import slimeknights.tconstruct.fixture.ToolDefinitionFixture;
import slimeknights.tconstruct.library.materials.MaterialRegistryExtension;
import slimeknights.tconstruct.library.tools.helper.ToolBuildHandler;
import slimeknights.tconstruct.library.tools.helper.ToolDamageUtil;
import slimeknights.tconstruct.library.tools.nbt.MaterialNBT;
import slimeknights.tconstruct.library.tools.stat.ModifierStatsBuilder;
import slimeknights.tconstruct.test.BaseMcTest;
@ExtendWith(MaterialRegistryExtension.class)
public abstract class ToolItemTest extends BaseMcTest {
protected static ModifiableItem tool;
protected ItemStack testItemStack;
@BeforeAll
synchronized static void beforeAllToolCore() {
MaterialItemFixture.init();
if (tool == null) {
tool = new ModifiableItem(new Item.Properties().stacksTo(1), ToolDefinitionFixture.getStandardToolDefinition());
ForgeRegistries.ITEMS.register(new ResourceLocation("test", "toolcore"), tool);
}
setupTierSorting();
ModifierStatsBuilder.disableFilter();
}
@BeforeEach
void setUpToolCore() {
testItemStack = buildTestTool(tool);
}
protected ItemStack buildTestTool(IModifiable tool) {
return ToolBuildHandler.buildItemFromMaterials(tool, MaterialNBT.of(MaterialFixture.MATERIAL_WITH_HEAD, MaterialFixture.MATERIAL_WITH_HANDLE, MaterialFixture.MATERIAL_WITH_EXTRA));
}
/** Checks if the test item is broken */
protected boolean IsTestItemBroken() {
return ToolDamageUtil.isBroken(testItemStack);
}
/** Breaks a tool using high damage */
protected void breakTool(ItemStack stack) {
stack.setDamageValue(99999);
}
}