/
FillCauldronRecipe.java
106 lines (92 loc) · 3.42 KB
/
FillCauldronRecipe.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
package knightminer.inspirations.library.recipe.cauldron;
import knightminer.inspirations.common.Config;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import slimeknights.mantle.recipe.match.RecipeMatch;
import javax.annotation.Nullable;
import java.util.Objects;
/**
* Cauldron recipe to fill the cauldron from a fluid container
*/
@Deprecated
public class FillCauldronRecipe extends FluidCauldronRecipe {
private int amount;
/**
* Full constructor
* @param input Input container
* @param fluid Fluid produced and required in the current cauldron
* @param amount Amount of fluid produced
* @param container Resulting container after filling the cauldron
* @param boiling If true, the cauldron must be placed above lava for this recipe
* @param sound Sound to play when filling
*/
public FillCauldronRecipe(RecipeMatch input, Fluid fluid, int amount, ItemStack container, @Nullable Boolean boiling, SoundEvent sound) {
super(input, fluid, container, boiling, 0, sound);
if (fluid == Fluids.EMPTY) {
throw new IllegalArgumentException("Cannot create fill recipe with empty fluid");
}
this.amount = amount;
}
/**
* Full constructor
* @param input Input container
* @param fluid Fluid produced and required in the current cauldron
* @param amount Amount of fluid produced
* @param container Resulting container after filling the cauldron
* @param sound Sound to play when filling
*/
public FillCauldronRecipe(RecipeMatch input, Fluid fluid, int amount, ItemStack container, SoundEvent sound) {
this(input, fluid, amount, container, null, sound);
}
/**
* Constructor with default sound
* @param input Input container
* @param fluid Fluid produced and required in the current cauldron
* @param amount Amount of fluid produced
* @param container Resulting container after filling the cauldron
*/
public FillCauldronRecipe(RecipeMatch input, Fluid fluid, int amount, ItemStack container) {
this(input, fluid, amount, container, SoundEvents.ITEM_BOTTLE_EMPTY);
}
/**
* Constructor with default sound and empty container
* @param input Input container
* @param fluid Fluid produced and required in the current cauldron
* @param amount Amount of fluid produced
*/
public FillCauldronRecipe(RecipeMatch input, Fluid fluid, int amount) {
this(input, fluid, amount, ItemStack.EMPTY);
}
@Override
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) {
if (level == Config.getCauldronMax() || (level > 0 && !state.matches(fluid))
|| (this.boiling != null && boiling != this.boiling)) {
return false;
}
return matches(stack);
}
@Override
public CauldronState getState(ItemStack stack, boolean boiling, int level, CauldronState state) {
return Objects.requireNonNull(fluid);
}
@Override
public int getLevel(int level) {
return level + amount;
}
@Override
public int getInputLevel() {
return 0;
}
@Override
public ItemStack getContainer(ItemStack stack) {
return ItemStack.EMPTY;
}
@Override
public String toString() {
assert fluid != null;
return String.format("FillCauldronRecipe: filling with %s", fluid.getFluid().getAttributes().getTranslationKey());
}
}