-
Notifications
You must be signed in to change notification settings - Fork 18
/
FillCauldronFromPotion.java
64 lines (54 loc) · 1.9 KB
/
FillCauldronFromPotion.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
package knightminer.inspirations.recipes.recipe;
import knightminer.inspirations.library.InspirationsRegistry;
import knightminer.inspirations.library.recipe.cauldron.ICauldronRecipe;
import net.minecraft.init.PotionTypes;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionType;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.SoundEvent;
public class FillCauldronFromPotion implements ICauldronRecipe {
private ItemStack bottle;
private Item potion;
public FillCauldronFromPotion(Item potion, ItemStack bottle) {
this.bottle = bottle;
this.potion = potion;
}
@Override
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) {
return level < InspirationsRegistry.getCauldronMax() && (level == 0 || state.getPotion() != null)
&& stack.getItem() == potion;
}
@Override
public ItemStack getResult(ItemStack stack, boolean boiling, int level, CauldronState state) {
return bottle.copy();
}
/**
* Gets the result change in cauldron level as a result of this recipe
*/
@Override
public int getLevel(int level) {
return level + 1;
}
@Override
public CauldronState getState(ItemStack stack, boolean boiling, int level, CauldronState state) {
// if the level was 0, we need to add the potion state
PotionType inputType = PotionUtils.getPotionFromItem(stack);
if(level == 0) {
return CauldronState.potion(inputType);
}
// if the types differ, it just turns black
if(state.getPotion() != inputType) {
return CauldronState.potion(PotionTypes.THICK);
}
return state;
}
@Override
public SoundEvent getSound(ItemStack stack, boolean boiling, int level, CauldronState state) {
if(level > 0 && PotionUtils.getPotionFromItem(stack) != state.getPotion()) {
return SoundEvents.BLOCK_FIRE_EXTINGUISH;
}
return SoundEvents.ITEM_BOTTLE_EMPTY;
}
}