/
FillCauldronRecipe.java
96 lines (82 loc) · 3.1 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
package knightminer.inspirations.library.recipe.cauldron;
import javax.annotation.ParametersAreNonnullByDefault;
import knightminer.inspirations.library.InspirationsRegistry;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fluids.Fluid;
import slimeknights.mantle.util.RecipeMatch;
/**
* Cauldron recipe to fill the cauldron from a fluid container
*/
@ParametersAreNonnullByDefault
public class FillCauldronRecipe extends CauldronFluidRecipe {
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, Boolean boiling, SoundEvent sound) {
super(input, fluid, container, boiling, 0, sound);
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 == InspirationsRegistry.getCauldronMax() || (level > 0 && !state.matches(fluid))
|| (this.boiling != null && boiling != this.boiling.booleanValue())) {
return false;
}
return matches(stack);
}
@Override
public CauldronState getState(ItemStack stack, boolean boiling, int level, CauldronState state) {
return fluid;
}
@Override
public int getLevel(int level) {
return level + amount;
}
@Override
public int getInputLevel() {
return 0;
}
@Override
public String toString() {
return String.format("FillCauldronRecipe: filling with %s", fluid.getFluid().getName());
}
}