forked from friendlyhj/GrassUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecipeUtils.zs
More file actions
100 lines (89 loc) · 3.02 KB
/
RecipeUtils.zs
File metadata and controls
100 lines (89 loc) · 3.02 KB
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
100
#loader crafttweaker
#priority 30000
import crafttweaker.item.IItemStack;
import crafttweaker.item.IIngredient;
import crafttweaker.data.IData;
import crafttweaker.oredict.IOreDictEntry;
import scripts.grassUtils.StringHelper;
import scripts.grassUtils.classes.ConditionedItemStack.ConditionedItemStack;
static tweakedRecipesAmount as int = 0;
//修改合成, 先删后加, 第一个参数true表有序, false无序, 需要二维数组(即使是无序)
function recipeTweak(isShaped as bool,out as IItemStack,input as IIngredient[][]) as int{
var recipeName as string = StringHelper.getItemNameWithUnderline(out);
if (out.hasTag) {
recipeName ~= ("_withtag_" ~ tweakedRecipesAmount);
}
recipes.remove(out.withAmount(1),true);
if (isShaped) {
recipes.addShaped(recipeName,out,input);
} else {
recipes.addShapeless(recipeName,out,input[0]);
}
tweakedRecipesAmount += 1;
return tweakedRecipesAmount;
}
function createSurround(core as IIngredient,surrounded as IIngredient) as IIngredient[][] {
return [[surrounded,surrounded,surrounded],
[surrounded,core,surrounded],
[surrounded,surrounded,surrounded]];
}
function createFull3(input as IIngredient) as IIngredient[][] {
return [[input,input,input],
[input,input,input],
[input,input,input]];
}
function createFull2(input as IIngredient) as IIngredient[][] {
return [[input,input],[input,input]];
}
function createCross(five as IIngredient, four as IIngredient) as IIngredient[][] {
return [[five, four, five],
[four, five, four],
[five, four, five]];
}
function createCrossWithCore(core as IIngredient, a as IIngredient, b as IIngredient) as IIngredient[][] {
return [[a, b, a],
[b, core, b],
[a, b, a]];
}
//删除工作台与熔炉合成, 并在JEI内隐藏
function removeAllRecipe(input as IItemStack) as bool {
recipes.remove(input);
furnace.remove(input);
furnace.setFuel(input, 0);
mods.jei.JEI.removeAndHide(input);
return true;
}
//数组复数删除
function removeAllRecipes(input as IItemStack[]) as bool {
for item in input {
removeAllRecipe(item);
}
return true;
}
function getConditions(stack as IItemStack) as ConditionedItemStack {
return ConditionedItemStack(stack);
}
//从矿辞中提取金属名, 但处理金属名为多个单词的如DarkSteel, 会出bug, 返回Steel
function getMetalName(arg as IOreDictEntry) as string {
var input as string = arg.name;
var temp as string = "";
var i as int = input.length - 1;
while (i >= 0) {
temp = input[i] ~ temp;
if (input[i].toUpperCase() == input[i]) {
return temp;
}
i -= 1;
}
return "Invalid";
}
//从矿辞中提取金属名, 需要部件名参数
function getMetalNameNew(ore as IOreDictEntry, partName as string) as string {
var name as string = ore.name;
if (name.length > 0 && partName.length > 0) {
if (name.contains(partName)) {
return name.substring(partName.length);
}
}
return null;
}