Skip to content

Commit 1f69eb4

Browse files
MCTian-mibruberu
andauthored
Make grs setFormula method behave in the same way as ceu ones (GregTechCEu#2772)
Co-authored-by: bruberu <[email protected]>
1 parent 957d878 commit 1f69eb4

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

src/main/java/gregtech/integration/groovy/MaterialExpansion.java

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public class MaterialExpansion {
2626
// Material Methods //
2727
////////////////////////////////////
2828

29-
public static void setFormula(Material m, String formula) {
30-
setFormula(m, formula, false);
29+
public static Material setFormula(Material m, String formula) {
30+
return setFormula(m, formula, false);
3131
}
3232

33-
public static void setFormula(Material m, String formula, boolean withFormatting) {
34-
if (checkFrozen("set material chemical formula")) return;
35-
m.setFormula(formula, withFormatting);
33+
public static Material setFormula(Material m, String formula, boolean withFormatting) {
34+
if (checkFrozen("set material chemical formula")) return m;
35+
return m.setFormula(formula, withFormatting);
3636
}
3737

3838
public static boolean hasFlag(Material m, String flagName) {
@@ -77,20 +77,22 @@ public static int burnTime(Material m) {
7777
return 0;
7878
}
7979

80-
public static void setHarvestLevel(Material m, int harvestLevel) {
81-
if (checkFrozen("set harvest level")) return;
80+
public static Material setHarvestLevel(Material m, int harvestLevel) {
81+
if (checkFrozen("set harvest level")) return m;
8282
DustProperty prop = m.getProperty(PropertyKey.DUST);
8383
if (prop != null) {
8484
prop.setHarvestLevel(harvestLevel);
8585
} else logError(m, "set the harvest level", "Dust");
86+
return m;
8687
}
8788

88-
public static void setBurnTime(Material m, int burnTime) {
89-
if (checkFrozen("set burn time")) return;
89+
public static Material setBurnTime(Material m, int burnTime) {
90+
if (checkFrozen("set burn time")) return m;
9091
DustProperty prop = m.getProperty(PropertyKey.DUST);
9192
if (prop != null) {
9293
prop.setBurnTime(burnTime);
9394
} else logError(m, "set the burn time", "Dust");
95+
return m;
9496
}
9597

9698
///////////////////////////////////
@@ -136,46 +138,49 @@ public static int toolEnchantability(Material m) {
136138
return 0;
137139
}
138140

139-
public static void addToolEnchantment(Material m, Enchantment enchantment, int level) {
140-
addScaledToolEnchantment(m, enchantment, level, 0);
141+
public static Material addToolEnchantment(Material m, Enchantment enchantment, int level) {
142+
return addScaledToolEnchantment(m, enchantment, level, 0);
141143
}
142144

143-
public static void addScaledToolEnchantment(Material m, Enchantment enchantment, int level, double levelGrowth) {
144-
if (checkFrozen("add tool enchantment")) return;
145+
public static Material addScaledToolEnchantment(Material m, Enchantment enchantment, int level,
146+
double levelGrowth) {
147+
if (checkFrozen("add tool enchantment")) return m;
145148
MaterialToolProperty prop = m.getProperty(PropertyKey.TOOL);
146149
if (prop != null) {
147150
prop.addEnchantmentForTools(enchantment, level, levelGrowth);
148151
} else logError(m, "change tool enchantments", "Tool");
152+
return m;
149153
}
150154

151-
public static void setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
152-
boolean shouldIngoreCraftingTools) {
153-
setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, 0, 0, shouldIngoreCraftingTools);
155+
public static Material setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
156+
boolean shouldIngoreCraftingTools) {
157+
return setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, 0, 0, shouldIngoreCraftingTools);
154158
}
155159

156-
public static void setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
157-
int enchantability, boolean shouldIngoreCraftingTools) {
158-
setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, enchantability, 0, shouldIngoreCraftingTools);
160+
public static Material setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
161+
int enchantability, boolean shouldIngoreCraftingTools) {
162+
return setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, enchantability, 0,
163+
shouldIngoreCraftingTools);
159164
}
160165

161-
public static void setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability) {
162-
setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, 0, 0, false);
166+
public static Material setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability) {
167+
return setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, 0, 0, false);
163168
}
164169

165-
public static void setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
166-
int enchantability) {
167-
setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, enchantability, 0, false);
170+
public static Material setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
171+
int enchantability) {
172+
return setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, enchantability, 0, false);
168173
}
169174

170-
public static void setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
171-
int enchantability, int toolHarvestLevel) {
172-
setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, enchantability, toolHarvestLevel, false);
175+
public static Material setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
176+
int enchantability, int toolHarvestLevel) {
177+
return setToolStats(m, toolSpeed, toolAttackDamage, toolDurability, enchantability, toolHarvestLevel, false);
173178
}
174179

175-
public static void setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
176-
int enchantability, int toolHarvestLevel,
177-
boolean shouldIngoreCraftingTools) {
178-
if (checkFrozen("set tool stats")) return;
180+
public static Material setToolStats(Material m, float toolSpeed, float toolAttackDamage, int toolDurability,
181+
int enchantability, int toolHarvestLevel,
182+
boolean shouldIngoreCraftingTools) {
183+
if (checkFrozen("set tool stats")) return m;
179184
MaterialToolProperty prop = m.getProperty(PropertyKey.TOOL);
180185
if (prop != null) {
181186
prop.setToolSpeed(toolSpeed);
@@ -185,19 +190,21 @@ public static void setToolStats(Material m, float toolSpeed, float toolAttackDam
185190
prop.setToolEnchantability(enchantability == 0 ? 10 : enchantability);
186191
prop.setShouldIgnoreCraftingTools(shouldIngoreCraftingTools);
187192
} else logError(m, "change tool stats", "Tool");
193+
return m;
188194
}
189195

190196
////////////////////////////////////
191197
// Extra Tool Property //
192198
////////////////////////////////////
193199

194-
public static void setOverrideToolStats(Material m, String toolId, ExtraToolProperty.Builder overrideBuilder) {
195-
if (checkFrozen("set overriding tool stats")) return;
200+
public static Material setOverrideToolStats(Material m, String toolId, ExtraToolProperty.Builder overrideBuilder) {
201+
if (checkFrozen("set overriding tool stats")) return m;
196202
m.getProperties().ensureSet(PropertyKey.EXTRATOOL);
197203
ExtraToolProperty prop = m.getProperty(PropertyKey.EXTRATOOL);
198204
if (prop != null) {
199205
prop.setOverrideProperty(toolId, overrideBuilder.build());
200206
} else logError(m, "change tool stats", "Tool");
207+
return m;
201208
}
202209

203210
// Wire/Item Pipe/Fluid Pipe stuff?
@@ -206,15 +213,16 @@ public static void setOverrideToolStats(Material m, String toolId, ExtraToolProp
206213
// Blast Property //
207214
////////////////////////////////////
208215

209-
public static void setBlastTemp(Material m, int blastTemp) {
210-
if (checkFrozen("set blast temperature")) return;
216+
public static Material setBlastTemp(Material m, int blastTemp) {
217+
if (checkFrozen("set blast temperature")) return m;
211218
if (blastTemp <= 0) {
212219
GroovyLog.get().error("Blast Temperature must be greater than zero! Material: " + m.getUnlocalizedName());
213-
return;
220+
return m;
214221
}
215222
BlastProperty prop = m.getProperty(PropertyKey.BLAST);
216223
if (prop != null) prop.setBlastTemperature(blastTemp);
217224
else m.setProperty(PropertyKey.BLAST, new BlastProperty(blastTemp));
225+
return m;
218226
}
219227

220228
public static int blastTemp(Material m) {

0 commit comments

Comments
 (0)