@@ -85,103 +85,19 @@ private <T extends Recipe<?>> CategoryBuilder<T> builder(Class<? extends T> reci
8585 return new CategoryBuilder <>(recipeClass );
8686 }
8787
88- private class CategoryBuilder <T extends Recipe <?>> {
89- private final Class <? extends T > recipeClass ;
90- private Predicate <CRecipes > predicate = cRecipes -> true ;
91- private IDrawable background ;
92- private IDrawable icon ;
93-
94- private final List <Consumer <List <RecipeHolder <T >>>> recipeListConsumers = new ArrayList <Consumer <List <RecipeHolder <T >>>>();
95- private final List <Supplier <? extends ItemStack >> catalysts = new ArrayList <>();
88+ private class CategoryBuilder <T extends Recipe <?>> extends CreateRecipeCategory .Builder <T > {
9689
9790 public CategoryBuilder (Class <? extends T > recipeClass ) {
98- this .recipeClass = recipeClass ;
99- }
100-
101- public CategoryBuilder <T > enableIf (Predicate <CRecipes > predicate ) {
102- this .predicate = predicate ;
103- return this ;
104- }
105-
106- public CategoryBuilder <T > enableWhen (Function <CRecipes , ConfigBase .ConfigBool > configValue ) {
107- predicate = c -> configValue .apply (c ).get ();
108- return this ;
109- }
110-
111- public CategoryBuilder <T > addRecipeListConsumer (Consumer <List <RecipeHolder <T >>> consumer ) {
112- this .recipeListConsumers .add (consumer );
113- return this ;
114- }
115-
116- public CategoryBuilder <T > addTypedRecipes (IRecipeTypeInfo recipeTypeEntry ) {
117- Objects .requireNonNull (recipeTypeEntry );
118- return this .addTypedRecipes (recipeTypeEntry ::getType );
119- }
120-
121- public <I extends RecipeInput , R extends Recipe <I >> CategoryBuilder <T > addTypedRecipes (Supplier <RecipeType <R >> recipeType ) {
122- return this .addRecipeListConsumer ((recipes ) -> CreateJEI .consumeTypedRecipes ((recipe ) -> {
123- if (this .recipeClass .isInstance (recipe .value ())) {
124- recipes .add ((RecipeHolder <T >) recipe );
125- }
126-
127- }, (RecipeType )recipeType .get ()));
128- }
129-
130- public CategoryBuilder <T > catalystStack (Supplier <ItemStack > supplier ) {
131- catalysts .add (supplier );
132- return this ;
91+ super (recipeClass );
13392 }
13493
135- public CategoryBuilder <T > catalyst (Supplier <ItemLike > supplier ) {
136- return catalystStack (() -> new ItemStack (supplier .get ()
137- .asItem ()));
138- }
139-
140- public CategoryBuilder <T > icon (IDrawable icon ) {
141- this .icon = icon ;
142- return this ;
143- }
144-
145- public CategoryBuilder <T > itemIcon (ItemLike item ) {
146- icon (new ItemIcon (() -> new ItemStack (item )));
147- return this ;
148- }
149-
150- public CategoryBuilder <T > doubleItemIcon (ItemLike item1 , ItemLike item2 ) {
151- icon (new DoubleItemIcon (() -> new ItemStack (item1 ), () -> new ItemStack (item2 )));
152- return this ;
153- }
154-
155- public CategoryBuilder <T > background (IDrawable background ) {
156- this .background = background ;
157- return this ;
158- }
159-
160- public CategoryBuilder <T > emptyBackground (int width , int height ) {
161- background (new EmptyBackground (width , height ));
162- return this ;
163- }
164-
165- public CreateRecipeCategory <T > build (String name , CreateRecipeCategory .Factory <T > factory ) {
166- Supplier <List <RecipeHolder <T >>> recipesSupplier ;
167- if (predicate .test (AllConfigs .server ().recipes )) {
168- recipesSupplier = () -> {
169- List <RecipeHolder <T >> recipes = new ArrayList <>();
170- for (Consumer <List <RecipeHolder <T >>> consumer : recipeListConsumers )
171- consumer .accept (recipes );
172- return recipes ;
173- };
174- } else {
175- recipesSupplier = Collections ::emptyList ;
176- }
177-
178- CreateRecipeCategory .Info <T > info = new CreateRecipeCategory .Info <>(
179- new mezz .jei .api .recipe .RecipeType <>(CreatingSpace .resource (name ), recipeClass ),
180- Component .translatable (CreatingSpace .MODID + ".recipe." + name ), background , icon , recipesSupplier , catalysts );
181- CreateRecipeCategory <T > category = factory .create (info );
94+ @ Override
95+ public CreateRecipeCategory <T > build (ResourceLocation id , CreateRecipeCategory .Factory <T > factory ) {
96+ CreateRecipeCategory <T > category = super .build (id , factory );
18297 allCategories .add (category );
18398 return category ;
18499 }
100+
185101 }
186102
187103 @ Override
0 commit comments