/
ArmorDyeingCauldronRecipe.java
49 lines (40 loc) · 1.38 KB
/
ArmorDyeingCauldronRecipe.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
package knightminer.inspirations.recipes.recipe.cauldron;
import knightminer.inspirations.library.recipe.cauldron.ICauldronRecipe;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.DyeableArmorItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@Deprecated
public class ArmorDyeingCauldronRecipe implements ICauldronRecipe {
private final ArmorMaterial material;
public ArmorDyeingCauldronRecipe(ArmorMaterial material) {
this.material = material;
}
@Override
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) {
if (level == 0 || state.getColor() == -1) {
return false;
}
Item item = stack.getItem();
if (!(item instanceof DyeableArmorItem)) {
return false;
}
// only color leather, and ensure we are changing the color
DyeableArmorItem armor = (DyeableArmorItem)item;
return armor.getArmorMaterial() == material && armor.getColor(stack) != state.getColor();
}
@Override
public ItemStack getResult(ItemStack stack, boolean boiling, int level, CauldronState state) {
stack = stack.copy();
((DyeableArmorItem)stack.getItem()).setColor(stack, state.getColor());
return stack;
}
@Override
public int getLevel(int level) {
return level - 1;
}
@Override
public ItemStack getContainer(ItemStack stack) {
return ItemStack.EMPTY;
}
}