/
Anvil.java
99 lines (82 loc) · 3.06 KB
/
Anvil.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
97
98
99
package modtweaker2.mods.tfcraft.handlers;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.InputHelper.toStack;
import static com.bioxx.tfc.api.Crafting.AnvilReq.getReqFromInt;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import com.bioxx.tfc.api.Crafting.AnvilManager;
import com.bioxx.tfc.api.Crafting.AnvilRecipe;
@ZenClass("mods.tfcraft.Anvil")
public class Anvil {
@ZenMethod
public static void add(IItemStack input1, IItemStack input2, String plan, int value, boolean flux, int req, IItemStack output){
MineTweakerAPI.apply(new Add(new AnvilRecipe(toStack(input1), toStack(input2), plan, value, flux, req, toStack(output))));
}
/**
* For parameter <code>req</code>:<p> 1==copper;<p> 2==bronze;<p> 3==Wrought Iron;<p>
* 4==Steel;<p> 5==Black Steel;<p> 6==Red Steel;<p> 7==Blue Steel;<p> default is stone.
*/
@ZenMethod
public static void addWeld(IItemStack input1, IItemStack input2, int req, IItemStack output){
MineTweakerAPI.apply(new AddWeld(new AnvilRecipe(toStack(input1), toStack(input2), true, getReqFromInt(req), toStack(output))));
}
@ZenMethod
public static void remove(IItemStack stack){
MineTweakerAPI.apply(new Remove(toStack(stack)));
}
@ZenMethod
public static void removeWeld(IItemStack stack){
MineTweakerAPI.apply(new RemoveWeld(toStack(stack)));
}
private static class Add extends BaseListAddition{
public Add(AnvilRecipe recipe) {
super("Anvil-Regular", TFCHelper.anvilRecipes, recipe);
}
}
private static class AddWeld extends BaseListAddition{
public AddWeld(AnvilRecipe recipe) {
super("Anvil-Weld", TFCHelper.anvilWeldRecipes, recipe);
}
}
private static class Remove extends BaseListRemoval{
public Remove(ItemStack out){
super("Anvil-Remove-Regular", TFCHelper.anvilRecipes, out);
}
@Override
public void apply() {
ArrayList<AnvilRecipe> toRemove = new ArrayList<AnvilRecipe>();
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && areEqual(recipe.getCraftingResult(), stack)){
toRemove.add(recipe);
}
}
for (AnvilRecipe aRecipe : toRemove){
TFCHelper.anvilRecipes.remove(aRecipe);
}
}
}
private static class RemoveWeld extends BaseListRemoval{
public RemoveWeld(ItemStack out){
super("Anvil-Remove-Weld", TFCHelper.anvilWeldRecipes, out);
}
@Override
public void apply() {
ArrayList<AnvilRecipe> toRemove = new ArrayList<AnvilRecipe>();
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && recipe.getCraftingResult() == stack){
toRemove.add(recipe);
}
}
for (AnvilRecipe aRecipe : toRemove){
TFCHelper.anvilWeldRecipes.remove(aRecipe);
}
}
}
}