-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathIJEIRemoval.java
More file actions
128 lines (116 loc) · 5.29 KB
/
IJEIRemoval.java
File metadata and controls
128 lines (116 loc) · 5.29 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.cleanroommc.groovyscript.api.jeiremoval;
import com.cleanroommc.groovyscript.api.jeiremoval.operations.IOperation;
import com.cleanroommc.groovyscript.api.jeiremoval.operations.ISlotOperation;
import com.cleanroommc.groovyscript.compat.mods.jei.removal.OperationHandler;
import mezz.jei.api.gui.IRecipeLayout;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
/**
* Interface that should be implemented on {@link com.cleanroommc.groovyscript.api.INamed} registries,
* primarily those that would be iterated through as part of {@link com.cleanroommc.groovyscript.compat.mods.ModSupport#getAllContainers()},
* and contains methods indicating what JEI Categories the given registry represents
* and how to remove those recipes.
* <p>
* Primarily interacted with by {@link com.cleanroommc.groovyscript.compat.mods.jei.removal.JeiRemovalHelper#getRemovalMethod(String, IRecipeLayout)}.
* <p>
* In most cases, classes should implement {@link Default} instead of directly implementing {@link IJEIRemoval}.
*
* @see Default
*/
public interface IJEIRemoval {
/**
* A list containing any number of strings which
* are the UIDs of a JEI recipe category {@link mezz.jei.api.recipe.IRecipeCategory#getUid()}.
* <br>
* This list is typically immutable.
*
* @return a list of all UIDs associated with the target recipe category
*/
@NotNull
Collection<String> getCategories();
/**
* Generates one or more removal methods for the targeted recipe, if possible,
* using the information from JEI to do so.
* <p>
* If possible, the first removal method should only remove a single recipe,
* but this is not required and may not be possible.
* <p>
* The path to the recipe will automatically be generated before each entry, only the method name and its parameters should be returned.
* <p>
* Any empty list should be returned if generating a removal method is not possible.
*
* @param layout a map of type to group of slots displayed in JEI
* @return a collection of all generated method to remove the targeted recipe
*/
@NotNull
List<String> getRemoval(IRecipeLayout layout);
/**
* Has a default removal method, {@link #getRemoval(IRecipeLayout)},
* which returns a method to remove the recipe for each input and output.
* <p>
* If changing the operations interacted with is required, implementations should generally override
* the {@link #getJEIOperations()} method instead of {@link #getRemoval(IRecipeLayout)}.
*/
interface Default extends IJEIRemoval {
/**
* A shorthand method that modifies the default operations so each
* of the default operations includes the provided slots.
* <p>
* Should be used inside {@link #getJEIOperations()} to provide the return value.
*
* @param included all slots to be included
* @return a list if operations with the given slots included
* @see OperationHandler#defaultOperations()
*/
static List<IOperation> includeSlots(int... included) {
var operations = OperationHandler.defaultOperations();
for (var operation : operations) {
if (operation instanceof ISlotOperation<?> op) op.include(included);
}
return operations;
}
/**
* A shorthand method that modifies the default operations so each
* of the default operations excludes the provided slots.
* <p>
* Should be used inside {@link #getJEIOperations()} to provide the return value.
*
* @param excluded all slots to be excluded
* @return a list if operations with the given slots excluded
* @see OperationHandler#defaultOperations()
*/
static List<IOperation> excludeSlots(int... excluded) {
var operations = OperationHandler.defaultOperations();
for (var operation : operations) {
if (operation instanceof ISlotOperation<?> op) op.exclude(excluded);
}
return operations;
}
/**
* Calls {@link OperationHandler#removalOptions(IRecipeLayout, List)} with the output of {@link #getJEIOperations()}.\
* <p>
* In almost all cases, this should not be overridden and
* {@link #getJEIOperations()} should be manipulated instead.
*
* @see OperationHandler#removalOptions(IRecipeLayout, List)
*/
@Override
default @NotNull List<String> getRemoval(IRecipeLayout layout) {
return OperationHandler.removalOptions(layout, getJEIOperations());
}
/**
* Gets the desired operations that will be parsed through with the target {@link IRecipeLayout}.
* <p>
* Should be overridden to modify the excluded slots, override incorrectly labeled input or output slots,
* or to override the names of the methods.
*
* @return a list of operations to process
* @see OperationHandler#defaultOperations()
* @see OperationHandler#removalOptions(IRecipeLayout, List)
*/
default @NotNull List<IOperation> getJEIOperations() {
return OperationHandler.defaultOperations();
}
}
}