/
RecipesRecipeProvider.java
712 lines (649 loc) · 39.5 KB
/
RecipesRecipeProvider.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
package knightminer.inspirations.recipes.data;
import knightminer.inspirations.common.data.ConfigEnabledCondition;
import knightminer.inspirations.common.datagen.IInspirationsRecipeBuilder;
import knightminer.inspirations.common.datagen.NBTIngredient;
import knightminer.inspirations.library.InspirationsTags;
import knightminer.inspirations.library.recipe.RecipeSerializers;
import knightminer.inspirations.library.recipe.cauldron.CauldronContentTypes;
import knightminer.inspirations.library.recipe.cauldron.CauldronIngredients;
import knightminer.inspirations.library.recipe.cauldron.contents.ICauldronContents;
import knightminer.inspirations.library.recipe.cauldron.ingredient.ICauldronIngredient;
import knightminer.inspirations.library.recipe.cauldron.ingredient.SizedIngredient;
import knightminer.inspirations.library.recipe.cauldron.recipe.CauldronRecipeBuilder;
import knightminer.inspirations.library.recipe.cauldron.recipe.CauldronTransformBuilder;
import knightminer.inspirations.library.recipe.cauldron.special.DyeableCauldronRecipe;
import knightminer.inspirations.library.recipe.cauldron.special.EmptyPotionCauldronRecipe;
import knightminer.inspirations.library.recipe.cauldron.special.FillPotionCauldronRecipe;
import knightminer.inspirations.library.recipe.cauldron.util.TemperaturePredicate;
import knightminer.inspirations.recipes.InspirationsRecipes;
import knightminer.inspirations.recipes.recipe.cauldron.BrewingCauldronRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.DyeCauldronWaterRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.MixCauldronDyeRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.PotionFermentCauldronTransform;
import knightminer.inspirations.shared.InspirationsShared;
import knightminer.inspirations.utility.InspirationsUtility;
import net.minecraft.advancements.ICriterionInstance;
import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.block.Blocks;
import net.minecraft.block.SoundType;
import net.minecraft.data.CustomRecipeBuilder;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider;
import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.data.ShapelessRecipeBuilder;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvents;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.crafting.conditions.ICondition;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
import net.minecraftforge.registries.IForgeRegistryEntry;
import slimeknights.mantle.recipe.data.ConsumerWrapperBuilder;
import slimeknights.mantle.registration.object.EnumObject;
import javax.annotation.Nullable;
import java.util.EnumSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import static knightminer.inspirations.library.recipe.cauldron.recipe.ICauldronRecipe.MAX;
import static knightminer.inspirations.library.recipe.cauldron.recipe.ICauldronRecipe.QUARTER;
import static knightminer.inspirations.library.recipe.cauldron.recipe.ICauldronRecipe.THIRD;
import static knightminer.inspirations.library.recipe.cauldron.recipe.ICauldronRecipe.TWELFTH;
public class RecipesRecipeProvider extends RecipeProvider implements IConditionBuilder, IInspirationsRecipeBuilder {
private Consumer<IFinishedRecipe> consumer;
public RecipesRecipeProvider(DataGenerator generatorIn) {
super(generatorIn);
}
@Override
public String getName() {
return "Inspirations Recipes - Recipes";
}
@Override
public Consumer<IFinishedRecipe> getConsumer() {
return consumer;
}
@Override
public ICondition baseCondition() {
return ConfigEnabledCondition.MODULE_RECIPES;
}
@Override
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
this.consumer = consumer;
this.addCauldronRecipes();
}
private void addCauldronRecipes() {
String folder = "cauldron/";
ICauldronIngredient waterIngredient = CauldronIngredients.FLUID.of(Fluids.WATER);
Consumer<IFinishedRecipe> cauldronRecipes = withCondition(ConfigEnabledCondition.CAULDRON_RECIPES);
// vanilla recipes //
// fill containers
// bucket
CustomRecipeBuilder.customRecipe(RecipeSerializers.CAULDRON_FILL_BUCKET)
.build(withCondition(ConfigEnabledCondition.CAULDRON_RECIPES), resourceName(folder + "fill_bucket"));
// glass bottles
ItemStack waterBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER);
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Items.GLASS_BOTTLE), waterIngredient)
.minLevels(THIRD)
.addLevels(-THIRD)
.setOutput(waterBottle.copy())
.setSound(SoundEvents.ITEM_BOTTLE_FILL)
.addCriterion("has_item", hasItem(Items.GLASS_BOTTLE))
.build(cauldronRecipes, resource(folder + "fill_water_bottle"));
// empty container
// bucket
CustomRecipeBuilder.customRecipe(RecipeSerializers.CAULDRON_EMPTY_BUCKET)
.build(cauldronRecipes, resourceName(folder + "empty_bucket"));
// water bottle
CauldronRecipeBuilder.cauldron(SizedIngredient.of(new NBTIngredient(waterBottle)), waterIngredient)
.maxLevels(MAX - 1)
.addLevels(THIRD)
.setOutput(Items.GLASS_BOTTLE)
.setOutput(CauldronContentTypes.FLUID.of(Fluids.WATER))
.noContainer()
.setSound(SoundEvents.ITEM_BOTTLE_EMPTY)
.addCriterion("has_item", hasItem(
ItemPredicate.Builder.create()
.item(Items.POTION)
.nbt(Objects.requireNonNull(waterBottle.getTag()))
.build()))
.build(cauldronRecipes, resource(folder + "empty_water_bottle"));
// custom recipes //
// sponge dry cauldron
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Blocks.SPONGE), waterIngredient)
.matchFull()
.setEmpty()
.setOutput(Blocks.WET_SPONGE)
.addCriterion("has_item", hasItem(Blocks.SPONGE))
.setSound(SoundType.PLANT.getPlaceSound())
.build(cauldronRecipes, resource(folder + "dry_cauldron"));
// melt ice if boiling, use fancier recipe if cauldron ice is enabled
String iceFolder = folder + "ice/";
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Blocks.ICE), waterIngredient)
.maxLevels(MAX - 1)
.setFull()
.setTemperature(TemperaturePredicate.BOILING)
.setOutput(CauldronContentTypes.FLUID.of(Fluids.WATER))
.setSound(SoundEvents.ITEM_BUCKET_FILL)
.addCriterion("has_item", hasItem(Blocks.ICE))
.build(withCondition(ConfigEnabledCondition.CAULDRON_RECIPES, not(ConfigEnabledCondition.CAULDRON_ICE)), wrapE(Fluids.WATER, iceFolder, "_from_ice"));
// freeze water into ice when cold
Consumer<IFinishedRecipe> cauldronIce = withCondition(ConfigEnabledCondition.CAULDRON_ICE);
ResourceLocation ice = Objects.requireNonNull(Blocks.ICE.getRegistryName());
CauldronTransformBuilder.transform(CauldronIngredients.FLUID.of(Fluids.WATER), CauldronContentTypes.CUSTOM.of(ice), 500)
.setTemperature(TemperaturePredicate.FREEZING)
.addCriterion("has_item", hasItem(Items.ICE))
.setSound(SoundType.GLASS.getPlaceSound())
.build(cauldronIce, resource(iceFolder + "ice_from_water"));
// freeze wet ice into packed ice
ResourceLocation wetIce = Objects.requireNonNull(resource("wet_ice"));
ResourceLocation packedIce = Objects.requireNonNull(Blocks.PACKED_ICE.getRegistryName());
CauldronTransformBuilder.transform(CauldronIngredients.CUSTOM.of(wetIce), CauldronContentTypes.CUSTOM.of(packedIce), 2000)
.setTemperature(TemperaturePredicate.FREEZING)
.addCriterion("has_item", hasItem(Items.PACKED_ICE))
.setSound(SoundType.GLASS.getPlaceSound())
.build(cauldronIce, resource(iceFolder + "packed_ice_from_wet_ice"));
// melt back again when hot
CauldronTransformBuilder.transform(CauldronIngredients.CUSTOM.of(ice), CauldronContentTypes.FLUID.of(Fluids.WATER), 500)
.setTemperature(TemperaturePredicate.BOILING)
.addCriterion("has_item", hasItem(Items.ICE))
.setSound(SoundEvents.ITEM_BUCKET_EMPTY)
.build(cauldronIce, resource(iceFolder + "water_from_ice_melting"));
CauldronTransformBuilder.transform(CauldronIngredients.CUSTOM.of(wetIce), CauldronContentTypes.FLUID.of(Fluids.WATER), 500)
.setTemperature(TemperaturePredicate.BOILING)
.addCriterion("has_item", hasItem(Items.ICE))
.setSound(SoundType.GLASS.getPlaceSound())
.build(cauldronIce, resource(iceFolder + "water_from_wet_ice"));
CauldronTransformBuilder.transform(CauldronIngredients.CUSTOM.of(packedIce), CauldronContentTypes.CUSTOM.of(wetIce), 2000)
.setTemperature(TemperaturePredicate.BOILING)
.addCriterion("has_item", hasItem(Items.PACKED_ICE))
.setSound(SoundType.GLASS.getPlaceSound())
.build(cauldronIce, resource(iceFolder + "wet_ice_from_packed_ice"));
// fill and empty ice
CauldronRecipeBuilder.cauldron(CauldronIngredients.CUSTOM.of(ice))
.matchFull()
.setEmpty()
.setOutput(Blocks.ICE)
.setSound(SoundType.GLASS.getBreakSound())
.addCriterion("has_item", hasItem(Items.ICE))
.build(cauldronIce, resource(iceFolder + "pickup_ice"));
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Blocks.ICE), CauldronIngredients.CUSTOM.of(ice))
.matchEmpty()
.setFull()
.setOutput(CauldronContentTypes.CUSTOM.of(ice))
.setSound(SoundType.GLASS.getPlaceSound())
.addCriterion("has_item", hasItem(Items.ICE))
.build(cauldronIce, resource(iceFolder + "place_ice"));
// fill and empty wet ice
CauldronRecipeBuilder.cauldron(CauldronIngredients.CUSTOM.of(wetIce))
.matchFull()
.setOutput(Blocks.ICE)
.setOutput(CauldronContentTypes.FLUID.of(Fluids.WATER))
.setSound(SoundType.GLASS.getBreakSound())
.addCriterion("has_item", hasItem(Items.ICE))
.build(cauldronIce, resource(iceFolder + "pickup_wet_ice"));
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Blocks.ICE), CauldronIngredients.FLUID.of(Fluids.WATER))
.matchFull()
.setOutput(CauldronContentTypes.CUSTOM.of(wetIce))
.setSound(SoundType.GLASS.getPlaceSound())
.addCriterion("has_item", hasItem(Items.ICE))
.build(cauldronIce, resource(iceFolder + "place_wet_ice"));
// fill and empty packed ice
CauldronRecipeBuilder.cauldron(CauldronIngredients.CUSTOM.of(packedIce))
.matchFull()
.setEmpty()
.setOutput(Blocks.PACKED_ICE)
.setSound(SoundType.GLASS.getBreakSound())
.addCriterion("has_item", hasItem(Items.PACKED_ICE))
.build(cauldronIce, resource(iceFolder + "pickup_packed_ice"));
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Blocks.PACKED_ICE), CauldronIngredients.CUSTOM.of(packedIce))
.matchEmpty()
.setFull()
.setOutput(CauldronContentTypes.CUSTOM.of(packedIce))
.setSound(SoundType.GLASS.getPlaceSound())
.addCriterion("has_item", hasItem(Items.ICE))
.build(cauldronIce, resource(iceFolder + "place_packed_ice"));
// clean sticky pistons
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Blocks.STICKY_PISTON), waterIngredient)
.minLevels(THIRD)
.addLevels(-THIRD)
.setOutput(Blocks.PISTON)
.addCriterion("has_item", hasItem(Blocks.STICKY_PISTON))
.build(cauldronRecipes, wrap(Blocks.STICKY_PISTON, folder, "_cleaning"));
// concrete powder
String concreteFolder = folder + "concrete/";
Consumer<IFinishedRecipe> concrete = withCondition(ConfigEnabledCondition.CAULDRON_CONCRETE);
VanillaEnum.CONCRETE_POWDER.forEach((color, powder) ->
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(powder), waterIngredient)
.minLevels(THIRD)
.addLevels(-THIRD)
.setOutput(VanillaEnum.CONCRETE.get(color))
.addCriterion("has_item", hasItem(powder))
.build(concrete, resource(concreteFolder + color.getString()))
);
// temporary milk recipes until Forge merges one of my milk bucket fixes
Consumer<IFinishedRecipe> fluidConsumer = withCondition(ConfigEnabledCondition.CAULDRON_FLUIDS);
ICauldronIngredient milkIngredient = CauldronIngredients.FLUID.of(InspirationsTags.Fluids.MILK);
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Items.MILK_BUCKET), milkIngredient)
.maxLevels(MAX - 1)
.setFull()
.setOutput(Items.BUCKET)
.setOutput(CauldronContentTypes.FLUID.of(InspirationsRecipes.milk))
.noContainer()
.addCriterion("has_item", hasItem(Items.MILK_BUCKET))
.setSound(SoundEvents.ITEM_BUCKET_EMPTY)
.build(fluidConsumer, resource(folder + "empty_milk_bucket"));
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Items.BUCKET), milkIngredient)
.matchFull()
.setEmpty()
.setOutput(Items.MILK_BUCKET)
.addCriterion("has_item", hasItem(Items.MILK_BUCKET))
.setSound(SoundEvents.ITEM_BUCKET_FILL)
.build(fluidConsumer, resource(folder + "fill_milk_bucket"));
// honey //
// fill and empty bottle, note unlike water this is in quarters
String honeyFolder = folder + "honey/";
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Items.HONEY_BOTTLE), CauldronIngredients.FLUID.of(InspirationsRecipes.honey))
.maxLevels(MAX - 1)
.addLevels(QUARTER)
.setOutput(Items.GLASS_BOTTLE)
.noContainer()
.setOutput(CauldronContentTypes.FLUID.of(InspirationsRecipes.honey))
.setSound(SoundEvents.ITEM_BOTTLE_EMPTY)
.addCriterion("has_item", hasItem(Items.HONEY_BOTTLE))
.build(fluidConsumer, resource(honeyFolder + "empty_bottle"));
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Items.GLASS_BOTTLE), CauldronIngredients.FLUID.of(InspirationsRecipes.honey))
.minLevels(QUARTER)
.addLevels(-QUARTER)
.setOutput(Items.HONEY_BOTTLE)
.setSound(SoundEvents.ITEM_BUCKET_FILL)
.addCriterion("has_item", hasItem(Items.HONEY_BOTTLE))
.build(fluidConsumer, resource(honeyFolder + "fill_bottle"));
// add and remove honey block
ResourceLocation honeyBlock = new ResourceLocation("honey_block");
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Blocks.HONEY_BLOCK), CauldronIngredients.CUSTOM.of(honeyBlock))
.matchEmpty()
.setFull()
.setOutput(CauldronContentTypes.CUSTOM.of(honeyBlock))
.setSound(SoundType.HONEY.getPlaceSound())
.addCriterion("has_item", hasItem(Blocks.HONEY_BLOCK))
.build(fluidConsumer, resource(honeyFolder + "place_block"));
CauldronRecipeBuilder.cauldron(CauldronIngredients.CUSTOM.of(honeyBlock))
.matchFull()
.setEmpty()
.setOutput(Blocks.HONEY_BLOCK)
.setSound(SoundType.HONEY.getBreakSound())
.addCriterion("has_item", hasItem(Blocks.HONEY_BLOCK))
.build(fluidConsumer, resource(honeyFolder + "pickup_block"));
// can grab 1 layer of honey for 1 sugar. Same rate as crafting table, but uses solid honey
// if full block, gives block instead
CauldronRecipeBuilder.cauldron(CauldronIngredients.CUSTOM.of(honeyBlock))
.levelRange(TWELFTH, MAX - 1)
.addLevels(-TWELFTH)
.setOutput(Items.SUGAR)
.setSound(SoundType.SAND.getBreakSound())
.addCriterion("has_item", hasItem(Items.HONEY_BOTTLE))
.build(fluidConsumer, resource(honeyFolder + "pickup_sugar"));
// solidifies at room temp, melts under heat
CauldronTransformBuilder.transform(CauldronIngredients.FLUID.of(InspirationsRecipes.honey), CauldronContentTypes.CUSTOM.of(honeyBlock), 300)
.setTemperature(TemperaturePredicate.COOL)
.setSound(SoundType.HONEY.getPlaceSound())
.addCriterion("has_item", hasItem(Blocks.HONEY_BLOCK))
.build(fluidConsumer, resource(honeyFolder + "solidify"));
CauldronTransformBuilder.transform(CauldronIngredients.CUSTOM.of(honeyBlock), CauldronContentTypes.FLUID.of(InspirationsRecipes.honey), 300)
.setTemperature(TemperaturePredicate.BOILING)
.setSound(SoundType.HONEY.getBreakSound())
.addCriterion("has_item", hasItem(Blocks.HONEY_BLOCK))
.build(fluidConsumer, resource(honeyFolder + "melt"));
// dyes //
// dye cauldron water
String dyeFolder = folder + "dye/";
Consumer<IFinishedRecipe> dyeConsumer = withCondition(ConfigEnabledCondition.CAULDRON_DYEING);
for (DyeColor color : DyeColor.values()) {
// normal dye to set color
dyeConsumer.accept(new DyeCauldronWaterRecipe.FinishedRecipe(resource(dyeFolder + "dye_" + color.getString()), color));
// dyed bottle to mix color
dyeConsumer.accept(new MixCauldronDyeRecipe.FinishedRecipe(
resource(dyeFolder + "bottle/" + color.getString()),
Ingredient.fromItems(InspirationsRecipes.simpleDyedWaterBottle.get(color)),
color.getColorValue()));
}
// mixed dyed bottle
dyeConsumer.accept(new MixCauldronDyeRecipe.FinishedRecipe(resource(dyeFolder + "bottle/mixed"), Ingredient.fromItems(InspirationsRecipes.mixedDyedWaterBottle)));
// fill dyed bottle
CustomRecipeBuilder.customRecipe(RecipeSerializers.CAULDRON_FILL_DYED_BOTTLE).build(dyeConsumer, resourceName(dyeFolder + "bottle/fill"));
// mix dyed bottles
String mixFolder = dyeFolder + "bottle/mix/";
addDyedBottleMix(mixFolder, DyeColor.CYAN, DyeColor.BLUE, DyeColor.GREEN);
addDyedBottleMix(mixFolder, DyeColor.GRAY, DyeColor.BLACK, DyeColor.WHITE);
addDyedBottleMix(mixFolder, DyeColor.LIGHT_BLUE, DyeColor.BLUE, DyeColor.WHITE);
addDyedBottleMix(mixFolder, DyeColor.LIGHT_GRAY, DyeColor.BLACK, DyeColor.WHITE, DyeColor.WHITE);
addDyedBottleMix(mixFolder, DyeColor.LIGHT_GRAY, DyeColor.GRAY, DyeColor.WHITE);
addDyedBottleMix(mixFolder, DyeColor.LIME, DyeColor.GREEN, DyeColor.WHITE);
addDyedBottleMix(mixFolder, DyeColor.MAGENTA, DyeColor.BLUE, DyeColor.RED, DyeColor.PINK);
addDyedBottleMix(mixFolder, DyeColor.MAGENTA, DyeColor.BLUE, DyeColor.RED, DyeColor.RED, DyeColor.WHITE);
addDyedBottleMix(mixFolder, DyeColor.MAGENTA, DyeColor.PURPLE, DyeColor.PINK);
addDyedBottleMix(mixFolder, DyeColor.ORANGE, DyeColor.RED, DyeColor.YELLOW);
addDyedBottleMix(mixFolder, DyeColor.PINK, DyeColor.RED, DyeColor.WHITE);
addDyedBottleMix(mixFolder, DyeColor.PURPLE, DyeColor.BLUE, DyeColor.RED);
// extra color mixes not supported by vanilla
//addDyedBottleMix(mixFolder, DyeColor.GREEN, ConfigEnabledCondition.EXTRA_DYE_RECIPES, DyeColor.BLUE, DyeColor.YELLOW);
//addDyedBottleMix(mixFolder, DyeColor.GREEN, ConfigEnabledCondition.EXTRA_DYE_RECIPES, DyeColor.BLUE, DyeColor.YELLOW);
// undye and dye vanilla blocks
addColoredRecipes(ItemTags.WOOL, VanillaEnum.WOOL, folder + "wool/", null);
addColoredRecipes(ItemTags.BEDS, VanillaEnum.BED, folder + "bed/", null);
addColoredRecipes(ItemTags.CARPETS, InspirationsShared.VANILLA_CARPETS, folder + "carpet/", null);
addColoredRecipes(InspirationsTags.Items.SHULKER_BOXES, VanillaEnum.SHULKER_BOX, Items.SHULKER_BOX, folder + "shulker_box/", true, null);
// Inspirations blocks
addColoredRecipes(InspirationsTags.Items.CARPETED_TRAPDOORS, InspirationsUtility.carpetedTrapdoors, folder + "carpeted_trapdoor/", ConfigEnabledCondition.CARPETED_TRAPDOOR);
// craft vanilla blocks using dyed bottles, as Forge did not reimplement the tags
// since I have to add recipes, a little more generous with them
Consumer<IFinishedRecipe> bottleConsumer = withCondition(ConfigEnabledCondition.CAULDRON_DYEING);
String bottleFolder = folder + "bottle/";
InspirationsRecipes.simpleDyedWaterBottle.forEach((dye, bottle) -> {
String name = dye.getString();
ICriterionInstance hasBottle = hasItem(bottle);
// wool
addComboRecipe(bottleConsumer, VanillaEnum.WOOL.get(dye), "wool", ItemTags.WOOL, bottle, resource(bottleFolder + "wool/" + name));
addSurroundRecipe(bottleConsumer, VanillaEnum.CARPET.get(dye), "carpet", InspirationsTags.Items.CARPETS, bottle, resource(bottleFolder + "carpet/" + name));
addComboRecipe(bottleConsumer, VanillaEnum.BED.get(dye), "dyed_bed", ItemTags.BEDS, bottle, resource(bottleFolder + "beds/" + name));
// stained glass
addSurroundRecipe(bottleConsumer, VanillaEnum.STAINED_GLASS.get(dye), "stained_glass", Tags.Items.GLASS_COLORLESS, bottle, resource(bottleFolder + "stained_glass/" + name));
addSurroundRecipe(bottleConsumer, VanillaEnum.STAINED_GLASS_PANE.get(dye), "stained_glass_pane", Tags.Items.GLASS_PANES_COLORLESS, bottle, resource(bottleFolder + "stained_glass_pane/" + name));
// terracotta
addSurroundRecipe(bottleConsumer, VanillaEnum.TERRACOTTA.get(dye), "stained_terracotta", InspirationsTags.Items.TERRACOTTA, bottle, resource(bottleFolder + "terracotta/" + name));
// concrete powder
ShapelessRecipeBuilder.shapelessRecipe(VanillaEnum.CONCRETE_POWDER.get(dye), 8)
.setGroup("concrete_powder")
.addIngredient(bottle)
.addIngredient(ItemTags.SAND)
.addIngredient(ItemTags.SAND)
.addIngredient(ItemTags.SAND)
.addIngredient(ItemTags.SAND)
.addIngredient(Tags.Items.GRAVEL)
.addIngredient(Tags.Items.GRAVEL)
.addIngredient(Tags.Items.GRAVEL)
.addIngredient(Tags.Items.GRAVEL)
.addCriterion("has_item", hasBottle)
.build(bottleConsumer, resource(bottleFolder + "concrete_powder/" + name));
});
// leather dyeing and clearing
addDyeableRecipes(Items.LEATHER_HELMET, folder);
addDyeableRecipes(Items.LEATHER_CHESTPLATE, folder);
addDyeableRecipes(Items.LEATHER_LEGGINGS, folder);
addDyeableRecipes(Items.LEATHER_BOOTS, folder);
addDyeableRecipes(Items.LEATHER_HORSE_ARMOR, folder);
// banner pattern removing
CustomRecipeBuilder.customRecipe(RecipeSerializers.CAULDRON_REMOVE_BANNER_PATTERN).build(cauldronRecipes, resourceName(folder + "remove_banner_pattern"));
// potions //
String potionFolder = folder + "potion/";
Consumer<IFinishedRecipe> potionConsumer = withCondition(ConfigEnabledCondition.CAULDRON_POTIONS);
// normal
potionConsumer.accept(new EmptyPotionCauldronRecipe.FinishedRecipe(
resource(potionFolder + "normal_empty"), Items.POTION, Items.GLASS_BOTTLE));
potionConsumer.accept(new FillPotionCauldronRecipe.FinishedRecipe(
resource(potionFolder + "normal_fill"), SizedIngredient.fromItems(Items.GLASS_BOTTLE), Items.POTION));
// splash
potionConsumer.accept(new EmptyPotionCauldronRecipe.FinishedRecipe(
resource(potionFolder + "splash_empty"), Items.SPLASH_POTION, InspirationsRecipes.splashBottle));
potionConsumer.accept(new FillPotionCauldronRecipe.FinishedRecipe(
resource(potionFolder + "splash_fill"), SizedIngredient.fromTag(InspirationsTags.Items.SPLASH_BOTTLES), Items.SPLASH_POTION));
// lingering
potionConsumer.accept(new EmptyPotionCauldronRecipe.FinishedRecipe(
resource(potionFolder + "lingering_empty"), Items.LINGERING_POTION, InspirationsRecipes.lingeringBottle));
potionConsumer.accept(new FillPotionCauldronRecipe.FinishedRecipe(
resource(potionFolder + "lingering_fill"), SizedIngredient.fromTag(InspirationsTags.Items.LINGERING_BOTTLES), Items.LINGERING_POTION));
// tipped arrows
withCondition(ConfigEnabledCondition.CAULDRON_TIP_ARROWS).accept(
new FillPotionCauldronRecipe.FinishedRecipe(resource(potionFolder + "tipped_arrow"), SizedIngredient.fromItems(16, Items.ARROW), Items.TIPPED_ARROW));
// craft the bottles
ShapelessRecipeBuilder.shapelessRecipe(InspirationsRecipes.splashBottle)
.addIngredient(Items.GLASS_BOTTLE)
.addIngredient(Items.GLASS_BOTTLE)
.addIngredient(Items.GLASS_BOTTLE)
.addIngredient(Tags.Items.GUNPOWDER)
.addCriterion("has_item", hasItem(Tags.Items.GUNPOWDER))
.build(potionConsumer, prefix(InspirationsRecipes.splashBottle, potionFolder));
ShapelessRecipeBuilder.shapelessRecipe(InspirationsRecipes.lingeringBottle)
.addIngredient(InspirationsTags.Items.SPLASH_BOTTLES)
.addIngredient(InspirationsTags.Items.SPLASH_BOTTLES)
.addIngredient(InspirationsTags.Items.SPLASH_BOTTLES)
.addIngredient(Items.DRAGON_BREATH)
.addCriterion("has_item", hasItem(Items.DRAGON_BREATH))
.build(potionConsumer, prefix(InspirationsRecipes.lingeringBottle, potionFolder));
// brew the potions
Consumer<IFinishedRecipe> brewingConsumer = withCondition(ConfigEnabledCondition.CAULDRON_BREWING);
brewingConsumer.accept(new BrewingCauldronRecipe.FinishedRecipe(resource(potionFolder + "potion_brewing"), RecipeSerializers.CAULDRON_POTION_BREWING, false));
brewingConsumer.accept(new BrewingCauldronRecipe.FinishedRecipe(resource(potionFolder + "forge_brewing"), RecipeSerializers.CAULDRON_FORGE_BREWING, false));
brewingConsumer.accept(new PotionFermentCauldronTransform.FinishedRecipe(resource(potionFolder + "potion_ferment"), 600));
// fluid recipes //
// beetroot is just water based
addStewRecipe(Items.BEETROOT_SOUP, Ingredient.fromTag(Tags.Items.CROPS_BEETROOT), 6, InspirationsRecipes.beetrootSoup, waterIngredient, folder + "beetroot_soup/");
// mushroom water based
addStewRecipe(Items.MUSHROOM_STEW, Ingredient.fromTag(Tags.Items.MUSHROOMS), 2, InspirationsRecipes.mushroomStew, waterIngredient, folder + "mushroom_stew/");
// potato comes from mushroom
addStewRecipe(InspirationsRecipes.potatoSoupItem, Ingredient.fromItems(Items.BAKED_POTATO), 2, InspirationsRecipes.potatoSoup, CauldronIngredients.FLUID.of(InspirationsRecipes.mushroomStew), folder + "potato_soup/");
// add in some rabbit for rabbit stew
addStewRecipe(Items.RABBIT_STEW, Ingredient.fromItems(Items.COOKED_RABBIT), 1, InspirationsRecipes.rabbitStew, CauldronIngredients.FLUID.of(InspirationsRecipes.potatoSoup), folder + "rabbit_stew/");
// normal potato soup crafting
ShapelessRecipeBuilder.shapelessRecipe(InspirationsRecipes.potatoSoupItem)
.addIngredient(Items.BOWL)
.addIngredient(Items.BAKED_POTATO)
.addIngredient(Items.BAKED_POTATO)
.addIngredient(Tags.Items.MUSHROOMS)
.addCriterion("has_item", hasItem(Items.BAKED_POTATO))
.build(withCondition(), resource(folder + "potato_soup/item"));
}
/**
* Adds cauldron recipes to dye and undye colored blocks
* @param tag Tag for colored block
* @param enumObject Object of items
* @param folder Folder for output
* @param condition Extra condition to add, if null uses base conditions
*/
private void addColoredRecipes(ITag<Item> tag, EnumObject<DyeColor,? extends IItemProvider> enumObject, String folder, @Nullable ICondition condition) {
addColoredRecipes(tag, enumObject, enumObject.get(DyeColor.WHITE), folder, false, condition);
}
/**
* Adds cauldron recipes to dye and undye colored blocks
* @param tag Tag for colored block
* @param enumObject Object of items
* @param folder Folder for output
* @param undyedItem Undyed variant
* @param copyNBT If true, copies NBT
* @param condition Extra condition to add, if null uses base conditions
*/
private void addColoredRecipes(ITag<Item> tag, EnumObject<DyeColor,? extends IItemProvider> enumObject, IItemProvider undyedItem, String folder, boolean copyNBT, @Nullable ICondition condition) {
// add condition if present
Consumer<IFinishedRecipe> dyed, undyed;
if (condition == null) {
undyed = withCondition(ConfigEnabledCondition.CAULDRON_RECIPES);
dyed = withCondition(ConfigEnabledCondition.CAULDRON_DYEING);
} else {
undyed = withCondition(ConfigEnabledCondition.CAULDRON_RECIPES, condition);
dyed = withCondition(ConfigEnabledCondition.CAULDRON_DYEING, condition);
}
// undyed
SizedIngredient ingredient = SizedIngredient.fromTag(tag);
ICriterionInstance criteria = hasItem(tag);
CauldronRecipeBuilder undyedBuilder = CauldronRecipeBuilder
.cauldron(ingredient, CauldronIngredients.FLUID.of(Fluids.WATER))
.minLevels(THIRD)
.addLevels(-THIRD)
.setOutput(undyedItem)
.addCriterion("has_item", criteria);
if (copyNBT) {
undyedBuilder.setCopyNBT();
}
undyedBuilder.build(undyed, resource(folder + "undye"));
// dyed recipes need one more condition
enumObject.forEach((color, block) -> {
CauldronRecipeBuilder coloredBuilder = CauldronRecipeBuilder
.cauldron(ingredient, CauldronIngredients.DYE.of(color))
.minLevels(THIRD)
.addLevels(-THIRD)
.setOutput(block)
.addCriterion("has_item", criteria);
if (copyNBT) {
coloredBuilder.setCopyNBT();
}
coloredBuilder.build(dyed, resource(folder + color.getString()));
});
}
/**
* Adds recipes to dye and clear a dyeable item
* @param dyeable Dyeable item
* @param folder Folder for recipes
*/
private void addDyeableRecipes(IItemProvider dyeable, String folder) {
Ingredient ingredient = Ingredient.fromItems(dyeable);
withCondition(ConfigEnabledCondition.CAULDRON_RECIPES)
.accept(DyeableCauldronRecipe.FinishedRecipe.clear(prefix(dyeable, folder + "dyeable/clear_"), ingredient));
withCondition(ConfigEnabledCondition.CAULDRON_DYEING)
.accept(DyeableCauldronRecipe.FinishedRecipe.dye(prefix(dyeable, folder + "dyeable/dye_"), ingredient));
}
/**
* Adds recipes for making stew
* @param stewItem Item of filled stew
* @param ingredient Ingredient to make stew
* @param amount Amount of stew ingredient
* @param stewFluid Fluid for making stew
* @param base Base fluid for stew
* @param folder Folder for recipes
*/
private void addStewRecipe(IItemProvider stewItem, Ingredient ingredient, int amount, Fluid stewFluid, ICauldronIngredient base, String folder) {
Consumer<IFinishedRecipe> consumer = withCondition(ConfigEnabledCondition.CAULDRON_FLUIDS);
ICauldronIngredient stewIngredient = CauldronIngredients.FLUID.of(stewFluid);
ICauldronContents stewContents = CauldronContentTypes.FLUID.of(stewFluid);
// fill the bowl
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(Items.BOWL), stewIngredient)
.minLevels(THIRD)
.addLevels(-THIRD)
.setOutput(stewItem)
.setSound(SoundEvents.ITEM_BOTTLE_FILL)
.addCriterion("has_item", hasItem(Items.BOWL))
.build(consumer, resource(folder + "fill_bowl"));
// empty the bowl
CauldronRecipeBuilder.cauldron(SizedIngredient.fromItems(stewItem), stewIngredient)
.maxLevels(MAX - 1)
.addLevels(THIRD)
.setOutput(Items.BOWL)
.setOutput(stewContents)
.noContainer()
.setSound(SoundEvents.ITEM_BOTTLE_EMPTY)
.addCriterion("has_item", hasItem(stewItem))
.build(consumer, resource(folder + "empty_bowl"));
// if the cauldron has 1 level, takes 1 item. If it has 2 or 3, take twice as many
ICriterionInstance criteria = hasItem(Blocks.CAULDRON);
CauldronRecipeBuilder.cauldron(SizedIngredient.of(ingredient, amount), base)
.levelRange(1, THIRD)
.setTemperature(TemperaturePredicate.BOILING)
.setOutput(stewContents)
.addCriterion("has_item", criteria)
.build(consumer, resource(folder + "stew_small"));
CauldronRecipeBuilder.cauldron(SizedIngredient.of(ingredient, amount * 2), base)
.minLevels(THIRD + 1)
.setTemperature(TemperaturePredicate.BOILING)
.setOutput(stewContents)
.addCriterion("has_item", criteria)
.build(consumer, resource(folder + "stew_large"));
}
/**
* Adds a shapless recipe to mix dyed bottles
* @param folder Output folder
* @param output Output color
* @param inputs List of color inputs
*/
private void addDyedBottleMix(String folder, DyeColor output, DyeColor... inputs) {
addDyedBottleMix(folder, output, null, inputs);
}
/**
* Adds a shapless recipe to mix dyed bottles
* @param folder Output folder
* @param output Output color
* @param extraCondition Additional condition to add to the recipe
* @param inputs List of color inputs
*/
private void addDyedBottleMix(String folder, DyeColor output, @Nullable ICondition extraCondition, DyeColor... inputs) {
// set serializer to shapeless no container and add conditions
ConsumerWrapperBuilder consumerBuilder = ConsumerWrapperBuilder
.wrap(RecipeSerializers.SHAPELESS_NO_CONTAINER)
.addCondition(ConfigEnabledCondition.CAULDRON_DYEING);
if (extraCondition != null) {
consumerBuilder.addCondition(extraCondition);
}
Consumer<IFinishedRecipe> consumer = consumerBuilder.build(getConsumer());
// build recipe name
StringBuilder name = new StringBuilder(folder + output.getString() + "_from");
Item outputItem = InspirationsRecipes.simpleDyedWaterBottle.get(output);
ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapelessRecipe(outputItem, inputs.length)
.setGroup(Objects.requireNonNull(outputItem.getRegistryName()).toString());
Set<DyeColor> seen = EnumSet.noneOf(DyeColor.class);
for (DyeColor input : inputs) {
IItemProvider bottle = InspirationsRecipes.simpleDyedWaterBottle.get(input);
builder.addIngredient(bottle);
// only add each color to the name and criteria once
if (!seen.contains(input)) {
builder.addCriterion("has_" + input.getString(), hasItem(bottle));
name.append("_").append(input.getString());
seen.add(input);
}
}
// build the recipe with the built name
builder.build(consumer, resourceName(name.toString()));
}
/**
* Adds a recipe that surrounds an item with a tag
* @param consumer Recipe consumer
* @param output Recipe output
* @param group Recipe group
* @param surround Item for surrounding
* @param center Center item
* @param location Recipe output location
*/
private void addSurroundRecipe(Consumer<IFinishedRecipe> consumer, IItemProvider output, String group, ITag<Item> surround, IItemProvider center, ResourceLocation location) {
ShapedRecipeBuilder.shapedRecipe(output, 8)
.setGroup(group)
.key('#', surround)
.key('x', center)
.patternLine("###")
.patternLine("#x#")
.patternLine("###")
.addCriterion("has_item", hasItem(center))
.build(consumer, location);
}
/**
* Adds a recipe that combines two items in a shapeless manner
* @param consumer Recipe consumer
* @param output Recipe output
* @param group Recipe group
* @param input Tag like the output
* @param modifier Item consumed to modify it
* @param location Recipe output location
*/
private void addComboRecipe(Consumer<IFinishedRecipe> consumer, IItemProvider output, String group, ITag<Item> input, IItemProvider modifier, ResourceLocation location) {
ShapelessRecipeBuilder.shapelessRecipe(output)
.setGroup(group)
.addIngredient(input)
.addIngredient(modifier)
.addCriterion("has_item", hasItem(modifier))
.build(consumer, location);
}
private ResourceLocation prefixE(IForgeRegistryEntry<?> entry, String prefix) {
return this.resource(prefix + Objects.requireNonNull(entry.getRegistryName()).getPath());
}
private ResourceLocation wrapE(IForgeRegistryEntry<?> entry, String prefix, String suffix) {
return this.resource(prefix + Objects.requireNonNull(entry.getRegistryName()).getPath() + suffix);
}
}