-
Notifications
You must be signed in to change notification settings - Fork 756
/
IModifierWorktableRecipe.java
104 lines (87 loc) · 3.96 KB
/
IModifierWorktableRecipe.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package slimeknights.tconstruct.library.recipe.worktable;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import slimeknights.mantle.recipe.ICommonRecipe;
import slimeknights.tconstruct.library.modifiers.ModifierEntry;
import slimeknights.tconstruct.library.recipe.ITinkerableContainer;
import slimeknights.tconstruct.library.recipe.RecipeResult;
import slimeknights.tconstruct.library.recipe.TinkerRecipeTypes;
import slimeknights.tconstruct.library.recipe.tinkerstation.IMutableTinkerStationContainer;
import slimeknights.tconstruct.library.recipe.tinkerstation.ITinkerStationRecipe;
import slimeknights.tconstruct.library.tools.nbt.IToolStackView;
import slimeknights.tconstruct.library.tools.nbt.ToolStack;
import javax.annotation.Nullable;
import java.util.List;
/**
* Main interface for all recipes in the Modifier Worktable
*/
public interface IModifierWorktableRecipe extends ICommonRecipe<ITinkerableContainer> {
@Override
default RecipeType<?> getType() {
return TinkerRecipeTypes.MODIFIER_WORKTABLE.get();
}
/** If true, this recipe matches the given inputs, does not consider the modifier button yet */
@Override
boolean matches(ITinkerableContainer inv, Level world);
/** Gets the title for display in JEI and in the info panel */
Component getTitle();
/**
* Gets the description of this recipe, or display an error if this recipe matches but currently has no modifiers
* @param inv Recipe inventory, null when fetching in JEI
*/
Component getDescription(@Nullable ITinkerableContainer inv);
/**
* Gets a list of modifier buttons for the given input. May be empty.
* It will not be automatically sorted, you must ensure the order is consistent on both client and server.
* In JEI, return empty to represent any modifier.
* @param inv Recipe inventory, null when fetching in JEI
*/
List<ModifierEntry> getModifierOptions(@Nullable ITinkerableContainer inv);
/**
* Gets the tool stack result for this recipe.
* @param inv Inventory instance
* @param modifier Modifier that was interacted with
* @return Tool stack result. Can be the same instance as previousResult or a new instance.
* Should never share NBT with {@link ITinkerableContainer#getTinkerable()}, needs to be a copy.
*/
RecipeResult<ToolStack> getResult(ITinkerableContainer inv, ModifierEntry modifier);
/** Gets the number to shrink the tool slot by and the size of the output, perfectly valid for this to be higher than the contained number of tools */
default int toolResultSize() {
return ITinkerStationRecipe.DEFAULT_TOOL_STACK_SIZE;
}
/**
* Updates the input stacks upon crafting this recipe
* @param result Result from {@link #getResult(ITinkerableContainer, ModifierEntry)}
* @param inv Inventory instance to modify inputs
* @param isServer If true, this is on the serverside. Use to handle randomness, {@link IMutableTinkerStationContainer#giveItem(ItemStack)} should handle being called serverside only
*/
default void updateInputs(IToolStackView result, ITinkerableContainer.Mutable inv, boolean isServer) {
// shrink all stacks by 1
for (int index = 0; index < inv.getInputCount(); index++) {
inv.shrinkInput(index, 1);
}
}
/** Gets input tool options, need not be rendered with the modifiers, simply be valid tools */
List<ItemStack> getInputTools();
/**
* Gets an ingredients to display in JEI.
* @param slot Slot index to display
* @return Display item list
*/
List<ItemStack> getDisplayItems(int slot);
/** Gets the number of inputs for this recipe */
int getInputCount();
/** Deprecated methods to ignore */
@Override
@Deprecated
default ItemStack getResultItem() {
return ItemStack.EMPTY;
}
@Deprecated
@Override
default ItemStack assemble(ITinkerableContainer inv) {
return ItemStack.EMPTY;
}
}