Skip to content

Commit 4f2f38b

Browse files
Address Reviews
- Enable ULV working tier - Apply to gem crystallization
1 parent d78fdf6 commit 4f2f38b

File tree

8 files changed

+49
-25
lines changed

8 files changed

+49
-25
lines changed

src/main/java/gregtech/api/GTValues.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class GTValues {
7171
/**
7272
* The Voltage Tiers adjusted for cable loss, divided by 2.
7373
*/
74-
public static final int[] VHA = { 7, 16, 60, 240, 960, 3840, 15360, 61440, 245760, 983040, 3932160, 15728640,
74+
public static final int[] VHA = { 4, 16, 60, 240, 960, 3840, 15360, 61440, 245760, 983040, 3932160, 15728640,
7575
62914560, 251658240, 1006632960 };
7676

7777
/**
@@ -83,6 +83,13 @@ public class GTValues {
8383
9007199254740992L, 36028797018963968L, 144115188075855872L, 576460752303423488L, 2305843009213693952L,
8484
Long.MAX_VALUE };
8585

86+
public static final long[] VA_FULL = { 7, 30, 120, 480, 1920, 7680, 30720, 123880, 491520, 1966080, 7864320,
87+
31457280, 125829120, 503316480, 2013265920, 8053063680L, 32212254720L, 128849018880L, 515396075520L,
88+
2061584302080L, 8246337208320L, 32985348833280L, 131948427333120L, 527865581332480L, 2111062325297920L,
89+
8444249301319680L, 33777097205278720L, 135108988821415880L, 540431751284459520L, 2161727821137838080L,
90+
8646911284550352320L
91+
};
92+
8693
public static final int ULV = 0;
8794
public static final int LV = 1;
8895
public static final int MV = 2;

src/main/java/gregtech/api/unification/material/Material.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,11 @@ public void setWorkingTier(int workingTier) {
381381
throw new IllegalArgumentException(
382382
"Cannot set working tier for material " + materialInfo.resourceLocation + "to less than 0 (ULV)!");
383383
}
384-
if (workingTier == GTValues.ULV) {
385-
workingTier = GTValues.LV;
384+
if (workingTier > GTValues.MAX_TRUE) {
385+
throw new IllegalArgumentException(
386+
"Cannot set working tier for material " + materialInfo.resourceLocation +
387+
"to greater than 30 (MAX_TRUE)!");
388+
386389
}
387390
materialInfo.workingTier = workingTier;
388391
}
@@ -1123,15 +1126,18 @@ public Builder addDefaultEnchant(Enchantment enchant, int level) {
11231126
*
11241127
* @param tier The tier. Defaults to {@link GTValues#LV} if unset,
11251128
* though some recipes may still vary (such as Extruder recipes or Dense Plates).
1126-
* Applying ULV is no different from LV.
11271129
*/
11281130
public Builder workingTier(int tier) {
11291131
if (tier < 0) {
11301132
throw new IllegalArgumentException(
1131-
"Working tier for material" + materialInfo.resourceLocation + "cannot be less than 0 (ULV)!");
1133+
"Cannot set working tier for material " + materialInfo.resourceLocation +
1134+
"to less than 0 (ULV)!");
11321135
}
1133-
if (tier == GTValues.ULV) {
1134-
tier = GTValues.LV;
1136+
if (tier > GTValues.MAX_TRUE) {
1137+
throw new IllegalArgumentException(
1138+
"Cannot set working tier for material " + materialInfo.resourceLocation +
1139+
"to greater than 30 (MAX_TRUE)!");
1140+
11351141
}
11361142
materialInfo.workingTier = tier;
11371143
return this;

src/main/java/gregtech/api/util/GTUtility.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,14 @@ public static int safeCastLongToInt(long v) {
929929
*
930930
* @return The new recipe voltage.
931931
*/
932-
public static int scaleVoltage(int voltage, int workingTier) {
933-
if (workingTier <= GTValues.LV) {
932+
public static long scaleVoltage(long voltage, int workingTier) {
933+
if (workingTier == GTValues.LV) {
934934
// no action needed, as this is the default.
935935
return voltage;
936936
}
937-
if (voltage > GTValues.V[workingTier - 1]) {
937+
938+
int tierLower = Math.min(0, workingTier - 1);
939+
if (voltage > GTValues.VOC[tierLower]) {
938940
// no action needed, this recipe is already scaled accordingly.
939941
return voltage;
940942
}
@@ -950,11 +952,11 @@ public static int scaleVoltage(int voltage, int workingTier) {
950952
// voltage up by a "0/4 overclock". The goal here is to retain recipes with EU/t such as 24 staying
951953
// below a full amp but still increasing the tier. For instance, 24 EU/t with working tier of MV would become
952954
// 96 EU/t rather than 120 EU/t with this logic.
953-
while (voltage <= GTValues.V[workingTier - 1]) {
955+
while (voltage <= GTValues.VOC[workingTier - 1]) {
954956
voltage *= 4;
955957
}
956958

957959
// Sanity check to make sure we don't accidentally create full-amp recipes.
958-
return Math.min(voltage, GTValues.VA[workingTier]);
960+
return Math.min(voltage, GTValues.VA_FULL[workingTier]);
959961
}
960962
}

src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import gregtech.api.unification.material.MarkerMaterials;
99
import gregtech.api.unification.material.Material;
1010
import gregtech.api.unification.material.Materials;
11-
import gregtech.api.unification.material.properties.*;
11+
import gregtech.api.unification.material.properties.BlastProperty;
12+
import gregtech.api.unification.material.properties.DustProperty;
13+
import gregtech.api.unification.material.properties.IngotProperty;
14+
import gregtech.api.unification.material.properties.OreProperty;
15+
import gregtech.api.unification.material.properties.PropertyKey;
1216
import gregtech.api.unification.ore.OrePrefix;
1317
import gregtech.api.unification.stack.UnificationEntry;
1418
import gregtech.api.util.GTUtility;
@@ -67,6 +71,7 @@ public static void register() {
6771
public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty property) {
6872
ItemStack dustStack = OreDictUnifier.get(dustPrefix, mat);
6973
OreProperty oreProperty = mat.hasProperty(PropertyKey.ORE) ? mat.getProperty(PropertyKey.ORE) : null;
74+
int workingTier = mat.getWorkingTier();
7075
if (mat.hasProperty(PropertyKey.GEM)) {
7176
ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, mat);
7277

@@ -75,14 +80,14 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty
7580
.inputs(dustStack)
7681
.fluidInputs(Materials.Water.getFluid(250))
7782
.chancedOutput(gemStack, 7000, 1000)
78-
.duration(1200).EUt(24)
83+
.duration(1200).EUt(GTUtility.scaleVoltage(24, workingTier))
7984
.buildAndRegister();
8085

8186
RecipeMaps.AUTOCLAVE_RECIPES.recipeBuilder()
8287
.inputs(dustStack)
8388
.fluidInputs(Materials.DistilledWater.getFluid(50))
8489
.outputs(gemStack)
85-
.duration(600).EUt(24)
90+
.duration(600).EUt(GTUtility.scaleVoltage(24, workingTier))
8691
.buildAndRegister();
8792
}
8893

@@ -92,27 +97,31 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty
9297
.outputs(GTUtility.copy(3, gemStack))
9398
.chancedOutput(dust, Materials.DarkAsh, 2500, 0)
9499
.explosives(new ItemStack(MetaBlocks.POWDERBARREL, 8))
100+
.EUt(GTUtility.scaleVoltage(VA[LV], workingTier))
95101
.buildAndRegister();
96102

97103
RecipeMaps.IMPLOSION_RECIPES.recipeBuilder()
98104
.inputs(GTUtility.copy(4, dustStack))
99105
.outputs(GTUtility.copy(3, gemStack))
100106
.chancedOutput(dust, Materials.DarkAsh, 2500, 0)
101107
.explosives(4)
108+
.EUt(GTUtility.scaleVoltage(VA[LV], workingTier))
102109
.buildAndRegister();
103110

104111
RecipeMaps.IMPLOSION_RECIPES.recipeBuilder()
105112
.inputs(GTUtility.copy(4, dustStack))
106113
.outputs(GTUtility.copy(3, gemStack))
107114
.chancedOutput(dust, Materials.DarkAsh, 2500, 0)
108115
.explosives(MetaItems.DYNAMITE.getStackForm(2))
116+
.EUt(GTUtility.scaleVoltage(VA[LV], workingTier))
109117
.buildAndRegister();
110118

111119
RecipeMaps.IMPLOSION_RECIPES.recipeBuilder()
112120
.inputs(GTUtility.copy(4, dustStack))
113121
.outputs(GTUtility.copy(3, gemStack))
114122
.chancedOutput(dust, Materials.DarkAsh, 2500, 0)
115123
.explosives(new ItemStack(MetaBlocks.ITNT))
124+
.EUt(GTUtility.scaleVoltage(VA[LV], workingTier))
116125
.buildAndRegister();
117126
}
118127

@@ -378,7 +387,7 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP
378387
}
379388
}
380389

381-
int voltageMultiplier = getVoltageMultiplier(material);
390+
long voltageMultiplier = getVoltageMultiplier(material);
382391
if (!OreDictUnifier.get(plate, material).isEmpty()) {
383392
RecipeMaps.EXTRUDER_RECIPES.recipeBuilder()
384393
.input(ingotPrefix, material)
@@ -555,7 +564,7 @@ public static void processBlock(OrePrefix blockPrefix, Material material, DustPr
555564
}
556565

557566
if (material.hasProperty(PropertyKey.INGOT)) {
558-
int voltageMultiplier = getVoltageMultiplier(material);
567+
long voltageMultiplier = getVoltageMultiplier(material);
559568
RecipeMaps.EXTRUDER_RECIPES.recipeBuilder()
560569
.input(OrePrefix.ingot, material, (int) (materialAmount / M))
561570
.notConsumable(MetaItems.SHAPE_EXTRUDER_BLOCK)
@@ -589,7 +598,7 @@ public static void processBlock(OrePrefix blockPrefix, Material material, DustPr
589598
}
590599
}
591600

592-
private static int getVoltageMultiplier(Material material) {
601+
private static long getVoltageMultiplier(Material material) {
593602
return material.getBlastTemperature() >= 2800 ? VA[LV] : VA[ULV];
594603
}
595604
}

src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp
183183

184184
ItemStack stack = OreDictUnifier.get(gearPrefix, material);
185185
if (gearPrefix == OrePrefix.gear && material.hasProperty(PropertyKey.INGOT)) {
186-
int voltageMultiplier = getVoltageMultiplier(material);
186+
long voltageMultiplier = getVoltageMultiplier(material);
187187
RecipeMaps.EXTRUDER_RECIPES.recipeBuilder()
188188
.input(OrePrefix.ingot, material, 4)
189189
.notConsumable(MetaItems.SHAPE_EXTRUDER_GEAR)
@@ -275,7 +275,7 @@ public static void processLens(OrePrefix lensPrefix, Material material, GemPrope
275275
.output(lens, material)
276276
.output(dustSmall, material)
277277
.duration(1200)
278-
.EUt(GTUtility.scaleVoltage(120, workingTier))
278+
.EUt(GTUtility.scaleVoltage(VA[MV], workingTier))
279279
.buildAndRegister();
280280

281281
if (!OreDictUnifier.get(gemExquisite, material).isEmpty()) {
@@ -284,7 +284,7 @@ public static void processLens(OrePrefix lensPrefix, Material material, GemPrope
284284
.output(lens, material)
285285
.output(dust, material, 2)
286286
.duration(2400)
287-
.EUt(GTUtility.scaleVoltage(30, workingTier))
287+
.EUt(GTUtility.scaleVoltage(VA[LV], workingTier))
288288
.buildAndRegister();
289289
}
290290

@@ -626,7 +626,7 @@ public static void processRound(OrePrefix roundPrefix, Material material, IngotP
626626
.buildAndRegister();
627627
}
628628

629-
private static int getVoltageMultiplier(Material material) {
629+
private static long getVoltageMultiplier(Material material) {
630630
return material.getBlastTemperature() > 2800 ? VA[LV] : VA[ULV];
631631
}
632632
}

src/main/java/gregtech/loaders/recipe/handlers/PipeRecipeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ private static void processPipeNonuple(OrePrefix pipePrefix, Material material,
343343
.buildAndRegister();
344344
}
345345

346-
private static int getVoltageMultiplier(Material material) {
346+
private static long getVoltageMultiplier(Material material) {
347347
return material.getBlastTemperature() >= 2800 ? VA[LV] : VA[ULV];
348348
}
349349
}

src/main/java/gregtech/loaders/recipe/handlers/ToolRecipeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private static void processTool(OrePrefix prefix, Material material, ToolPropert
238238
}
239239

240240
private static void processElectricTool(OrePrefix prefix, Material material, ToolProperty property) {
241-
final int voltageMultiplier = material.getBlastTemperature() > 2800 ? VA[LV] : VA[ULV];
241+
final long voltageMultiplier = material.getBlastTemperature() > 2800 ? VA[LV] : VA[ULV];
242242
OrePrefix toolPrefix;
243243

244244
if (material.hasFlag(GENERATE_PLATE)) {

src/main/java/gregtech/loaders/recipe/handlers/WireRecipeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private static void generateManualRecipe(OrePrefix wirePrefix, Material material
186186
.buildAndRegister();
187187
}
188188

189-
private static int getVoltageMultiplier(Material material) {
189+
private static long getVoltageMultiplier(Material material) {
190190
return material.getBlastTemperature() >= 2800 ? VA[LV] : VA[ULV];
191191
}
192192
}

0 commit comments

Comments
 (0)