/
BrewingCauldronRecipe.java
94 lines (79 loc) · 2.73 KB
/
BrewingCauldronRecipe.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
package knightminer.inspirations.library.recipe.cauldron;
import com.google.common.collect.ImmutableList;
import knightminer.inspirations.common.Config;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.potion.Potion;
import net.minecraft.potion.Potions;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import java.util.List;
/**
* Cauldron recipe to transform a potion into another potion. Used primarily with vanilla potion recipes from the brewing registry.
*/
@Deprecated
public class BrewingCauldronRecipe implements ISimpleCauldronRecipe {
private Ingredient reagent;
private CauldronState input;
private CauldronState output;
/**
* @param input Input potion type
* @param reagent Ingredient for transformation
* @param output Resulting potion type
*/
public BrewingCauldronRecipe(Potion input, Ingredient reagent, Potion output) {
this.input = CauldronState.potion(input);
this.reagent = reagent;
this.output = CauldronState.potion(output);
}
@Override
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) {
// must have at least one level and be boiling. If 3 or more stack count must be bigger than 1
return level > 0 && boiling
// if expensive brewing, level must be less than 3 or two inputs provided
&& (!Config.expensiveCauldronBrewing() || level < 3 || stack.getCount() > 1)
&& state.matches(input) && reagent.test(stack);
}
@Override
public ItemStack transformInput(ItemStack stack, boolean boiling, int level, CauldronState state) {
stack.shrink(Config.expensiveCauldronBrewing() && level > 2 ? 2 : 1);
return stack;
}
@Override
public CauldronState getState(ItemStack stack, boolean boiling, int level, CauldronState state) {
return output;
}
@Override
public List<ItemStack> getInput() {
return ImmutableList.copyOf(reagent.getMatchingStacks());
}
@Override
public int getInputLevel() {
return Config.expensiveCauldronBrewing() ? 2 : Config.getCauldronMax();
}
@Override
public Object getInputState() {
Potion potion = input.getPotion();
return potion == Potions.WATER ? Fluids.WATER : potion;
}
@Override
public Object getState() {
Potion potion = output.getPotion();
return potion == Potions.WATER ? Fluids.WATER : potion;
}
@Override
public boolean isBoiling() {
return true;
}
@Override
public SoundEvent getSound(ItemStack stack, boolean boiling, int level, CauldronState state) {
return SoundEvents.BLOCK_BREWING_STAND_BREW;
}
@Override
public String toString() {
return String.format("BrewingCauldronRecipe: %s from %s",
output.getPotion().getRegistryName(),
input.getPotion().getRegistryName());
}
}