/
FillCauldronFromDyedBottle.java
65 lines (52 loc) · 1.74 KB
/
FillCauldronFromDyedBottle.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.Util;
import knightminer.inspirations.library.recipe.cauldron.ICauldronRecipe;
import knightminer.inspirations.recipes.InspirationsRecipes;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundEvent;
public enum FillCauldronFromDyedBottle implements ICauldronRecipe {
INSTANCE;
@Override
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) {
if(level == InspirationsRegistry.getCauldronMax()) {
return false;
}
return (state.isWater() || state.getColor() > -1)
&& stack.getItem() == InspirationsRecipes.dyedWaterBottle;
}
@Override
public CauldronState getState(ItemStack stack, boolean boiling, int level, CauldronState state) {
int newColor = InspirationsRecipes.dyedWaterBottle.getColor(stack);
if(level == 0) {
return CauldronState.dye(newColor);
}
int color = state.getColor();
// if color is unchanged, use the old state
if(newColor == color) {
return state;
}
// otherwise combine colors
if(color == -1) {
color = 0x888888;
}
return CauldronState.dye(Util.combineColors(newColor, color, level));
}
@Override
public int getLevel(int level) {
return level + 1;
}
@Override
public ItemStack getResult(ItemStack stack, boolean boiling, int level, CauldronState state) {
return stack.getItem().getContainerItem(stack);
}
@Override
public SoundEvent getSound(ItemStack stack, boolean boiling, int level, CauldronState state) {
return SoundEvents.ITEM_BOTTLE_EMPTY;
}
@Override
public ItemStack getContainer(ItemStack stack) {
return ItemStack.EMPTY;
}
}