/
FillPotionFromCauldron.java
48 lines (40 loc) · 1.41 KB
/
FillPotionFromCauldron.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
package knightminer.inspirations.recipes.recipe;
import knightminer.inspirations.library.Util;
import knightminer.inspirations.library.recipe.cauldron.ICauldronRecipe;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.SoundEvent;
import slimeknights.mantle.util.RecipeMatch;
public class FillPotionFromCauldron implements ICauldronRecipe {
private RecipeMatch bottle;
private Item potion;
public FillPotionFromCauldron(Item potion, ItemStack bottle) {
this.bottle = RecipeMatch.of(bottle);
this.potion = potion;
}
public FillPotionFromCauldron(Item potion, String bottle) {
this.bottle = RecipeMatch.of(bottle);
this.potion = potion;
}
@Override
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) {
if(level == 0) {
return false;
}
return state.getPotion() != null && bottle.matches(Util.createNonNullList(stack)).isPresent();
}
@Override
public ItemStack getResult(ItemStack stack, boolean boiling, int level, CauldronState state) {
return PotionUtils.addPotionToItemStack(new ItemStack(potion), state.getPotion());
}
@Override
public int getLevel(int level) {
return level - 1;
}
@Override
public SoundEvent getSound(ItemStack stack, boolean boiling, int level, CauldronState state) {
return SoundEvents.ITEM_BOTTLE_FILL;
}
}