diff --git a/src/main/java/gregtech/api/GTValues.java b/src/main/java/gregtech/api/GTValues.java index b530c0d468d..6ae5cc1c443 100644 --- a/src/main/java/gregtech/api/GTValues.java +++ b/src/main/java/gregtech/api/GTValues.java @@ -71,7 +71,7 @@ public class GTValues { /** * The Voltage Tiers adjusted for cable loss, divided by 2. */ - public static final int[] VHA = { 7, 16, 60, 240, 960, 3840, 15360, 61440, 245760, 983040, 3932160, 15728640, + public static final int[] VHA = { 4, 16, 60, 240, 960, 3840, 15360, 61440, 245760, 983040, 3932160, 15728640, 62914560, 251658240, 1006632960 }; /** @@ -83,6 +83,13 @@ public class GTValues { 9007199254740992L, 36028797018963968L, 144115188075855872L, 576460752303423488L, 2305843009213693952L, Long.MAX_VALUE }; + public static final long[] VAOC = { 7, 30, 120, 480, 1920, 7680, 30720, 123880, 491520, 1966080, 7864320, + 31457280, 125829120, 503316480, 2013265920, 8053063680L, 32212254720L, 128849018880L, 515396075520L, + 2061584302080L, 8246337208320L, 32985348833280L, 131948427333120L, 527865581332480L, 2111062325297920L, + 8444249301319680L, 33777097205278720L, 135108988821415880L, 540431751284459520L, 2161727821137838080L, + 8646911284550352320L + }; + public static final int ULV = 0; public static final int LV = 1; public static final int MV = 2; diff --git a/src/main/java/gregtech/api/unification/material/Material.java b/src/main/java/gregtech/api/unification/material/Material.java index d0f42cbe1ac..f3346ae30d0 100644 --- a/src/main/java/gregtech/api/unification/material/Material.java +++ b/src/main/java/gregtech/api/unification/material/Material.java @@ -1,5 +1,6 @@ package gregtech.api.unification.material; +import gregtech.api.GTValues; import gregtech.api.GregTechAPI; import gregtech.api.fluids.FluidBuilder; import gregtech.api.fluids.FluidState; @@ -370,6 +371,26 @@ public int getBlastTemperature() { return prop == null ? 0 : prop.getBlastTemperature(); } + @ZenGetter("workingTier") + public int getWorkingTier() { + return materialInfo.workingTier; + } + + @ZenMethod + public void setWorkingTier(int workingTier) { + if (workingTier < 0) { + throw new IllegalArgumentException( + "Cannot set working tier for material " + materialInfo.resourceLocation + "to less than 0 (ULV)!"); + } + if (workingTier > GTValues.MAX) { + throw new IllegalArgumentException( + "Cannot set working tier for material " + materialInfo.resourceLocation + + "to greater than 14 (MAX)!"); + + } + materialInfo.workingTier = workingTier; + } + public FluidStack getPlasma(int amount) { return getFluid(FluidStorageKeys.PLASMA, amount); } @@ -1110,6 +1131,28 @@ public Builder addDefaultEnchant(Enchantment enchant, int level) { return this; } + /** + * Sets the tier for "working" recipes to require, such as extruding, bending, etc. + * + * @param tier The tier. Defaults to {@link GTValues#LV} if unset, + * though some recipes may still vary (such as Extruder recipes or Dense Plates). + */ + public Builder workingTier(int tier) { + if (tier < 0) { + throw new IllegalArgumentException( + "Cannot set working tier for material " + materialInfo.resourceLocation + + "to less than 0 (ULV)!"); + } + if (tier > GTValues.MAX) { + throw new IllegalArgumentException( + "Cannot set working tier for material " + materialInfo.resourceLocation + + "to greater than 14 (MAX)!"); + + } + materialInfo.workingTier = tier; + return this; + } + public Material build() { materialInfo.componentList = ImmutableList.copyOf(composition); materialInfo.verifyInfo(properties, averageRGB); @@ -1168,6 +1211,13 @@ private static class MaterialInfo { */ private Element element; + /** + * The tier for "working" recipes to require, such as extruding, bending, etc. + *

+ * Default: {@link GTValues#LV}, though some recipes may still vary (such as Dense Plates being MV). + */ + private int workingTier = GTValues.LV; + private MaterialInfo(int metaItemSubId, @NotNull ResourceLocation resourceLocation) { this.metaItemSubId = metaItemSubId; String name = resourceLocation.getPath(); diff --git a/src/main/java/gregtech/api/util/GTUtility.java b/src/main/java/gregtech/api/util/GTUtility.java index 39b4a6a0d65..02701d9b61b 100644 --- a/src/main/java/gregtech/api/util/GTUtility.java +++ b/src/main/java/gregtech/api/util/GTUtility.java @@ -920,4 +920,43 @@ public double getAsDouble() { public static int safeCastLongToInt(long v) { return v > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) v; } + + /** + * Scales a proposed recipe voltage according to a provided Material working tier. + * + * @param voltage The suggested base voltage for the recipe. + * @param workingTier The voltage tier ({@link GTValues#V}) to conform this recipe to. + * + * @return The new recipe voltage. + */ + public static long scaleVoltage(long voltage, int workingTier) { + if (workingTier == GTValues.LV) { + // no action needed, as this is the default. + return voltage; + } + + int tierLower = Math.max(0, workingTier - 1); + if (voltage > GTValues.V[tierLower]) { + // no action needed, this recipe is already scaled accordingly. + return voltage; + } + + // Multiplying very low voltages (less than 16 EU/t) with a formula like below can cause undesirably high + // EU/t. For example, 2 EU/t scaled to MV would multiply all the way to 128 EU/t before being above LV voltage. + // For this reason, recipes below 16 EU/t simply get set to their tier's VHA[tier] (half voltage adjusted). + if (voltage <= 16) { + return GTValues.VHA[workingTier]; + } + + // Instead of blindly increasing the voltage to something like VA[workingTier], try to scale the + // voltage up by a "0/4 overclock". The goal here is to retain recipes with EU/t such as 24 staying + // below a full amp but still increasing the tier. For instance, 24 EU/t with working tier of MV would become + // 96 EU/t rather than 120 EU/t with this logic. + while (voltage <= GTValues.V[workingTier - 1]) { + voltage *= 4; + } + + // Sanity check to make sure we don't accidentally create full-amp recipes. + return Math.min(voltage, GTValues.VA[workingTier]); + } } diff --git a/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java index 56b9ea27cb4..ebebd63ac85 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java @@ -8,7 +8,11 @@ import gregtech.api.unification.material.MarkerMaterials; import gregtech.api.unification.material.Material; import gregtech.api.unification.material.Materials; -import gregtech.api.unification.material.properties.*; +import gregtech.api.unification.material.properties.BlastProperty; +import gregtech.api.unification.material.properties.DustProperty; +import gregtech.api.unification.material.properties.IngotProperty; +import gregtech.api.unification.material.properties.OreProperty; +import gregtech.api.unification.material.properties.PropertyKey; import gregtech.api.unification.ore.OrePrefix; import gregtech.api.unification.stack.UnificationEntry; import gregtech.api.util.GTUtility; @@ -67,6 +71,7 @@ public static void register() { public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty property) { ItemStack dustStack = OreDictUnifier.get(dustPrefix, mat); OreProperty oreProperty = mat.hasProperty(PropertyKey.ORE) ? mat.getProperty(PropertyKey.ORE) : null; + int workingTier = mat.getWorkingTier(); if (mat.hasProperty(PropertyKey.GEM)) { ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, mat); @@ -75,14 +80,14 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty .inputs(dustStack) .fluidInputs(Materials.Water.getFluid(250)) .chancedOutput(gemStack, 7000, 1000) - .duration(1200).EUt(24) + .duration(1200).EUt(GTUtility.scaleVoltage(24, workingTier)) .buildAndRegister(); RecipeMaps.AUTOCLAVE_RECIPES.recipeBuilder() .inputs(dustStack) .fluidInputs(Materials.DistilledWater.getFluid(50)) .outputs(gemStack) - .duration(600).EUt(24) + .duration(600).EUt(GTUtility.scaleVoltage(24, workingTier)) .buildAndRegister(); } @@ -92,6 +97,7 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty .outputs(GTUtility.copy(3, gemStack)) .chancedOutput(dust, Materials.DarkAsh, 2500, 0) .explosives(new ItemStack(MetaBlocks.POWDERBARREL, 8)) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); RecipeMaps.IMPLOSION_RECIPES.recipeBuilder() @@ -99,6 +105,7 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty .outputs(GTUtility.copy(3, gemStack)) .chancedOutput(dust, Materials.DarkAsh, 2500, 0) .explosives(4) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); RecipeMaps.IMPLOSION_RECIPES.recipeBuilder() @@ -106,6 +113,7 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty .outputs(GTUtility.copy(3, gemStack)) .chancedOutput(dust, Materials.DarkAsh, 2500, 0) .explosives(MetaItems.DYNAMITE.getStackForm(2)) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); RecipeMaps.IMPLOSION_RECIPES.recipeBuilder() @@ -113,6 +121,7 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty .outputs(GTUtility.copy(3, gemStack)) .chancedOutput(dust, Materials.DarkAsh, 2500, 0) .explosives(new ItemStack(MetaBlocks.ITNT)) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); } @@ -284,24 +293,29 @@ public static void processTinyDust(OrePrefix orePrefix, Material material, DustP } public static void processIngot(OrePrefix ingotPrefix, Material material, IngotProperty property) { - if (material.hasFlag(MORTAR_GRINDABLE)) { + int workingTier = material.getWorkingTier(); + + if (material.hasFlag(MORTAR_GRINDABLE) && workingTier <= HV) { ModHandler.addShapedRecipe(String.format("mortar_grind_%s", material), OreDictUnifier.get(OrePrefix.dust, material), "X", "m", 'X', new UnificationEntry(ingotPrefix, material)); } if (material.hasFlag(GENERATE_ROD)) { - ModHandler.addShapedRecipe(String.format("stick_%s", material), - OreDictUnifier.get(OrePrefix.stick, material, 1), - "f ", " X", - 'X', new UnificationEntry(ingotPrefix, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("stick_%s", material), + OreDictUnifier.get(OrePrefix.stick, material, 1), + "f ", " X", + 'X', new UnificationEntry(ingotPrefix, material)); + } + if (!material.hasFlag(NO_WORKING)) { RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() .input(ingotPrefix, material) .notConsumable(MetaItems.SHAPE_EXTRUDER_ROD) .outputs(OreDictUnifier.get(OrePrefix.stick, material, 2)) .duration((int) material.getMass() * 2) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } } @@ -311,7 +325,8 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP .notConsumable(MetaItems.SHAPE_MOLD_INGOT) .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L)) .outputs(OreDictUnifier.get(ingotPrefix, material)) - .duration(20).EUt(VA[ULV]) + .duration(20) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } @@ -321,26 +336,32 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP .notConsumable(MetaItems.SHAPE_EXTRUDER_INGOT) .outputs(OreDictUnifier.get(OrePrefix.ingot, material)) .duration(10) - .EUt(4 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(4 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } - ALLOY_SMELTER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration((int) material.getMass()) + ALLOY_SMELTER_RECIPES.recipeBuilder() .input(ingot, material) .notConsumable(MetaItems.SHAPE_MOLD_NUGGET.getStackForm()) .output(nugget, material, 9) + .duration((int) material.getMass()) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); if (!OreDictUnifier.get(block, material).isEmpty()) { - ALLOY_SMELTER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration((int) material.getMass() * 9) + ALLOY_SMELTER_RECIPES.recipeBuilder() .input(block, material) .notConsumable(MetaItems.SHAPE_MOLD_INGOT.getStackForm()) .output(ingot, material, 9) + .duration((int) material.getMass() * 9) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); - COMPRESSOR_RECIPES.recipeBuilder().EUt(2).duration(300) + COMPRESSOR_RECIPES.recipeBuilder() .input(ingot, material, (int) (block.getMaterialAmount(material) / M)) .output(block, material) + .duration(300) + .EUt(GTUtility.scaleVoltage(2, workingTier)) .buildAndRegister(); } @@ -353,28 +374,32 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP .circuitMeta(1) .input(ingotPrefix, material) .outputs(plateStack) - .EUt(24).duration((int) (material.getMass())) + .duration((int) (material.getMass())) + .EUt(GTUtility.scaleVoltage(24, workingTier)) .buildAndRegister(); RecipeMaps.FORGE_HAMMER_RECIPES.recipeBuilder() .input(ingotPrefix, material, 3) .outputs(GTUtility.copy(2, plateStack)) - .EUt(16).duration((int) material.getMass()) + .duration((int) material.getMass()) + .EUt(GTUtility.scaleVoltage(16, workingTier)) .buildAndRegister(); - ModHandler.addShapedRecipe(String.format("plate_%s", material), - plateStack, "h", "I", "I", 'I', new UnificationEntry(ingotPrefix, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("plate_%s", material), + plateStack, "h", "I", "I", 'I', new UnificationEntry(ingotPrefix, material)); + } } } - int voltageMultiplier = getVoltageMultiplier(material); + long voltageMultiplier = getVoltageMultiplier(material); if (!OreDictUnifier.get(plate, material).isEmpty()) { RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() .input(ingotPrefix, material) .notConsumable(MetaItems.SHAPE_EXTRUDER_PLATE) .outputs(OreDictUnifier.get(OrePrefix.plate, material)) .duration((int) material.getMass()) - .EUt(8 * voltageMultiplier) + .EUt(GTUtility.scaleVoltage(8 * voltageMultiplier, workingTier)) .buildAndRegister(); if (material.hasFlag(NO_SMASHING)) { @@ -383,7 +408,7 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP .notConsumable(MetaItems.SHAPE_EXTRUDER_PLATE) .outputs(OreDictUnifier.get(OrePrefix.plate, material)) .duration((int) material.getMass()) - .EUt(8 * voltageMultiplier) + .EUt(GTUtility.scaleVoltage(8 * voltageMultiplier, workingTier)) .buildAndRegister(); } } @@ -393,8 +418,9 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP public static void processGemConversion(OrePrefix gemPrefix, @Nullable OrePrefix prevPrefix, Material material) { long materialAmount = gemPrefix.getMaterialAmount(material); ItemStack crushedStack = OreDictUnifier.getDust(material, materialAmount); + int workingTier = material.getWorkingTier(); - if (material.hasFlag(MORTAR_GRINDABLE)) { + if (material.hasFlag(MORTAR_GRINDABLE) && workingTier <= HV) { ModHandler.addShapedRecipe(String.format("gem_to_dust_%s_%s", material, gemPrefix), crushedStack, "X", "m", 'X', new UnificationEntry(gemPrefix, material)); } @@ -416,17 +442,19 @@ public static void processGemConversion(OrePrefix gemPrefix, @Nullable OrePrefix .notConsumable(OrePrefix.craftingLens, MarkerMaterials.Color.White) .output(gemPrefix, material) .duration(300) - .EUt(240) + .EUt(GTUtility.scaleVoltage(240, workingTier)) .buildAndRegister(); } } public static void processNugget(OrePrefix orePrefix, Material material, DustProperty property) { ItemStack nuggetStack = OreDictUnifier.get(orePrefix, material); + int workingTier = material.getWorkingTier(); + if (material.hasProperty(PropertyKey.INGOT)) { ItemStack ingotStack = OreDictUnifier.get(OrePrefix.ingot, material); - if (!ConfigHolder.recipes.disableManualCompression) { + if (!ConfigHolder.recipes.disableManualCompression && workingTier <= HV) { ModHandler.addShapelessRecipe(String.format("nugget_disassembling_%s", material), GTUtility.copy(9, nuggetStack), new UnificationEntry(OrePrefix.ingot, material)); ModHandler.addShapedRecipe(String.format("nugget_assembling_%s", material), @@ -436,12 +464,16 @@ public static void processNugget(OrePrefix orePrefix, Material material, DustPro COMPRESSOR_RECIPES.recipeBuilder() .input(nugget, material, 9) .output(ingot, material) - .EUt(2).duration(300).buildAndRegister(); + .duration(300) + .EUt(GTUtility.scaleVoltage(2, workingTier)) + .buildAndRegister(); - ALLOY_SMELTER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration((int) material.getMass()) + ALLOY_SMELTER_RECIPES.recipeBuilder() .input(nugget, material, 9) .notConsumable(MetaItems.SHAPE_MOLD_INGOT.getStackForm()) .output(ingot, material) + .duration((int) material.getMass()) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { @@ -450,13 +482,12 @@ public static void processNugget(OrePrefix orePrefix, Material material, DustPro .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L)) .outputs(OreDictUnifier.get(orePrefix, material, 9)) .duration((int) material.getMass()) - .EUt(VA[ULV]) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } } else if (material.hasProperty(PropertyKey.GEM)) { - ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, material); - - if (!ConfigHolder.recipes.disableManualCompression) { + if (!ConfigHolder.recipes.disableManualCompression && workingTier <= HV) { + ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, material); ModHandler.addShapelessRecipe(String.format("nugget_disassembling_%s", material), GTUtility.copy(9, nuggetStack), new UnificationEntry(OrePrefix.gem, material)); ModHandler.addShapedRecipe(String.format("nugget_assembling_%s", material), @@ -467,6 +498,7 @@ public static void processNugget(OrePrefix orePrefix, Material material, DustPro public static void processFrame(OrePrefix framePrefix, Material material, DustProperty property) { if (material.hasFlag(GENERATE_FRAME)) { + int workingTier = material.getWorkingTier(); boolean isWoodenFrame = ModHandler.isMaterialWood(material); ModHandler.addShapedRecipe(String.format("frame_%s", material), OreDictUnifier.get(framePrefix, material, 2), @@ -477,7 +509,7 @@ public static void processFrame(OrePrefix framePrefix, Material material, DustPr .input(OrePrefix.stick, material, 4) .circuitMeta(4) .outputs(OreDictUnifier.get(framePrefix, material, 1)) - .EUt(VA[ULV]).duration(64) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)).duration(64) .buildAndRegister(); } } @@ -485,13 +517,16 @@ public static void processFrame(OrePrefix framePrefix, Material material, DustPr public static void processBlock(OrePrefix blockPrefix, Material material, DustProperty property) { ItemStack blockStack = OreDictUnifier.get(blockPrefix, material); long materialAmount = blockPrefix.getMaterialAmount(material); + int workingTier = material.getWorkingTier(); + if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() .notConsumable(MetaItems.SHAPE_MOLD_BLOCK) .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom( ((int) (materialAmount * L / M)))) .outputs(blockStack) - .duration((int) material.getMass()).EUt(VA[ULV]) + .duration((int) material.getMass()) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } @@ -501,7 +536,8 @@ public static void processBlock(OrePrefix blockPrefix, Material material, DustPr RecipeMaps.CUTTER_RECIPES.recipeBuilder() .input(blockPrefix, material) .outputs(GTUtility.copy((int) (materialAmount / M), plateStack)) - .duration((int) (material.getMass() * 8L)).EUt(VA[LV]) + .duration((int) (material.getMass() * 8L)) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); } } @@ -525,7 +561,7 @@ public static void processBlock(OrePrefix blockPrefix, Material material, DustPr // do not allow hand crafting or uncrafting of blacklisted blocks if (!material.hasFlag(EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES) && - !ConfigHolder.recipes.disableManualCompression) { + !ConfigHolder.recipes.disableManualCompression && workingTier <= HV) { ModHandler.addShapelessRecipe(String.format("block_compress_%s", material), blockStack, result.toArray()); @@ -535,35 +571,41 @@ public static void processBlock(OrePrefix blockPrefix, Material material, DustPr } if (material.hasProperty(PropertyKey.INGOT)) { - int voltageMultiplier = getVoltageMultiplier(material); + long voltageMultiplier = getVoltageMultiplier(material); RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() .input(OrePrefix.ingot, material, (int) (materialAmount / M)) .notConsumable(MetaItems.SHAPE_EXTRUDER_BLOCK) .outputs(blockStack) - .duration(10).EUt(8 * voltageMultiplier) + .duration(10) + .EUt(GTUtility.scaleVoltage(8 * voltageMultiplier, workingTier)) .buildAndRegister(); RecipeMaps.ALLOY_SMELTER_RECIPES.recipeBuilder() .input(OrePrefix.ingot, material, (int) (materialAmount / M)) .notConsumable(MetaItems.SHAPE_MOLD_BLOCK) .outputs(blockStack) - .duration(5).EUt(4 * voltageMultiplier) + .duration(5) + .EUt(GTUtility.scaleVoltage(4 * voltageMultiplier, workingTier)) .buildAndRegister(); } else if (material.hasProperty(PropertyKey.GEM)) { COMPRESSOR_RECIPES.recipeBuilder() .input(gem, material, (int) (block.getMaterialAmount(material) / M)) .output(block, material) - .duration(300).EUt(2).buildAndRegister(); + .duration(300) + .EUt(GTUtility.scaleVoltage(2, workingTier)) + .buildAndRegister(); FORGE_HAMMER_RECIPES.recipeBuilder() .input(block, material) .output(gem, material, (int) (block.getMaterialAmount(material) / M)) - .duration(100).EUt(24).buildAndRegister(); + .duration(100) + .EUt(GTUtility.scaleVoltage(24, workingTier)) + .buildAndRegister(); } } } - private static int getVoltageMultiplier(Material material) { + private static long getVoltageMultiplier(Material material) { return material.getBlastTemperature() >= 2800 ? VA[LV] : VA[ULV]; } } diff --git a/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java index ddff63fd34a..7e81f53f116 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java @@ -59,12 +59,13 @@ public static void register() { public static void processBolt(OrePrefix boltPrefix, Material material, DustProperty property) { ItemStack boltStack = OreDictUnifier.get(boltPrefix, material); ItemStack ingotStack = OreDictUnifier.get(OrePrefix.ingot, material); + int workingTier = material.getWorkingTier(); RecipeMaps.CUTTER_RECIPES.recipeBuilder() .input(OrePrefix.screw, material) .outputs(boltStack) .duration(20) - .EUt(24) + .EUt(GTUtility.scaleVoltage(24, workingTier)) .buildAndRegister(); if (!boltStack.isEmpty() && !ingotStack.isEmpty()) { @@ -73,7 +74,7 @@ public static void processBolt(OrePrefix boltPrefix, Material material, DustProp .notConsumable(MetaItems.SHAPE_EXTRUDER_BOLT) .outputs(GTUtility.copy(8, boltStack)) .duration(15) - .EUt(VA[MV]) + .EUt(GTUtility.scaleVoltage(VA[MV], workingTier)) .buildAndRegister(); if (material.hasFlag(NO_SMASHING)) { @@ -82,7 +83,7 @@ public static void processBolt(OrePrefix boltPrefix, Material material, DustProp .notConsumable(MetaItems.SHAPE_EXTRUDER_BOLT) .outputs(GTUtility.copy(8, boltStack)) .duration(15) - .EUt(VA[MV]) + .EUt(GTUtility.scaleVoltage(VA[MV], workingTier)) .buildAndRegister(); } } @@ -90,30 +91,36 @@ public static void processBolt(OrePrefix boltPrefix, Material material, DustProp public static void processScrew(OrePrefix screwPrefix, Material material, DustProperty property) { ItemStack screwStack = OreDictUnifier.get(screwPrefix, material); + int workingTier = material.getWorkingTier(); RecipeMaps.LATHE_RECIPES.recipeBuilder() .input(OrePrefix.bolt, material) .outputs(screwStack) .duration((int) Math.max(1, material.getMass() / 8L)) - .EUt(4) + .EUt(GTUtility.scaleVoltage(4, workingTier)) .buildAndRegister(); - ModHandler.addShapedRecipe(String.format("screw_%s", material), - screwStack, "fX", "X ", - 'X', new UnificationEntry(OrePrefix.bolt, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("screw_%s", material), + screwStack, "fX", "X ", + 'X', new UnificationEntry(OrePrefix.bolt, material)); + } } public static void processFoil(OrePrefix foilPrefix, Material material, IngotProperty property) { - if (!material.hasFlag(NO_SMASHING)) + int workingTier = material.getWorkingTier(); + + if (!material.hasFlag(NO_SMASHING) && workingTier <= HV) { ModHandler.addShapedRecipe(String.format("foil_%s", material), OreDictUnifier.get(foilPrefix, material, 2), "hP ", 'P', new UnificationEntry(plate, material)); + } RecipeMaps.BENDER_RECIPES.recipeBuilder() .input(plate, material) .output(foilPrefix, material, 4) .duration((int) material.getMass()) - .EUt(24) + .EUt(GTUtility.scaleVoltage(24, workingTier)) .circuitMeta(1) .buildAndRegister(); @@ -121,7 +128,7 @@ public static void processFoil(OrePrefix foilPrefix, Material material, IngotPro .input(ingot, material) .output(foilPrefix, material, 4) .duration((int) material.getMass()) - .EUt(24) + .EUt(GTUtility.scaleVoltage(24, workingTier)) .circuitMeta(10) .buildAndRegister(); @@ -131,7 +138,7 @@ public static void processFoil(OrePrefix foilPrefix, Material material, IngotPro .notConsumable(MetaItems.SHAPE_EXTRUDER_FOIL) .output(foilPrefix, material, 4) .duration((int) material.getMass()) - .EUt(24) + .EUt(GTUtility.scaleVoltage(24, workingTier)) .buildAndRegister(); RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() @@ -139,13 +146,15 @@ public static void processFoil(OrePrefix foilPrefix, Material material, IngotPro .notConsumable(MetaItems.SHAPE_EXTRUDER_FOIL) .output(foilPrefix, material, 4) .duration((int) material.getMass()) - .EUt(24) + .EUt(GTUtility.scaleVoltage(24, workingTier)) .buildAndRegister(); } } public static void processFineWire(OrePrefix fineWirePrefix, Material material, IngotProperty property) { - if (!OreDictUnifier.get(foil, material).isEmpty()) + int workingTier = material.getWorkingTier(); + + if (!OreDictUnifier.get(foil, material).isEmpty() && workingTier <= HV) ModHandler.addShapelessRecipe(String.format("fine_wire_%s", material.toString()), OreDictUnifier.get(fineWirePrefix, material), 'x', new UnificationEntry(OrePrefix.foil, material)); @@ -156,7 +165,7 @@ public static void processFineWire(OrePrefix fineWirePrefix, Material material, .circuitMeta(1) .output(fineWirePrefix, material, 4) .duration((int) material.getMass() * 3 / 2) - .EUt(VA[ULV]) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } @@ -165,20 +174,22 @@ public static void processFineWire(OrePrefix fineWirePrefix, Material material, .circuitMeta(3) .output(fineWirePrefix, material, 8) .duration((int) material.getMass() * 2) - .EUt(VA[ULV]) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } public static void processGear(OrePrefix gearPrefix, Material material, DustProperty property) { + int workingTier = material.getWorkingTier(); + ItemStack stack = OreDictUnifier.get(gearPrefix, material); if (gearPrefix == OrePrefix.gear && material.hasProperty(PropertyKey.INGOT)) { - int voltageMultiplier = getVoltageMultiplier(material); + long voltageMultiplier = getVoltageMultiplier(material); RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() .input(OrePrefix.ingot, material, 4) .notConsumable(MetaItems.SHAPE_EXTRUDER_GEAR) .outputs(OreDictUnifier.get(gearPrefix, material)) .duration((int) material.getMass() * 5) - .EUt(8 * voltageMultiplier) + .EUt(GTUtility.scaleVoltage(8 * voltageMultiplier, workingTier)) .buildAndRegister(); RecipeMaps.ALLOY_SMELTER_RECIPES.recipeBuilder() @@ -186,7 +197,7 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp .notConsumable(MetaItems.SHAPE_MOLD_GEAR) .outputs(OreDictUnifier.get(gearPrefix, material)) .duration((int) material.getMass() * 10) - .EUt(2 * voltageMultiplier) + .EUt(GTUtility.scaleVoltage(2 * voltageMultiplier, workingTier)) .buildAndRegister(); if (material.hasFlag(NO_SMASHING)) { @@ -195,7 +206,7 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp .notConsumable(MetaItems.SHAPE_EXTRUDER_GEAR) .outputs(OreDictUnifier.get(gearPrefix, material)) .duration((int) material.getMass() * 5) - .EUt(8 * voltageMultiplier) + .EUt(GTUtility.scaleVoltage(8 * voltageMultiplier, workingTier)) .buildAndRegister(); } } @@ -208,29 +219,33 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp material.getProperty(PropertyKey.FLUID).solidifiesFrom(L * (isSmall ? 1 : 4))) .outputs(stack) .duration(isSmall ? 20 : 100) - .EUt(VA[ULV]) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } if (material.hasFlag(GENERATE_PLATE) && material.hasFlag(GENERATE_ROD)) { if (gearPrefix == OrePrefix.gearSmall) { - ModHandler.addShapedRecipe(String.format("small_gear_%s", material), - OreDictUnifier.get(gearSmall, material), - " R ", "hPx", " R ", 'R', new UnificationEntry(stick, material), 'P', - new UnificationEntry(plate, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("small_gear_%s", material), + OreDictUnifier.get(gearSmall, material), + " R ", "hPx", " R ", 'R', new UnificationEntry(stick, material), 'P', + new UnificationEntry(plate, material)); + } RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() .input(OrePrefix.ingot, material) .notConsumable(MetaItems.SHAPE_EXTRUDER_GEAR_SMALL) .outputs(stack) .duration((int) material.getMass()) - .EUt(material.getBlastTemperature() >= 2800 ? 256 : 64) + .EUt(GTUtility.scaleVoltage(material.getBlastTemperature() >= 2800 ? 256 : 64, workingTier)) .buildAndRegister(); - RecipeMaps.ALLOY_SMELTER_RECIPES.recipeBuilder().duration((int) material.getMass()).EUt(VA[LV]) + RecipeMaps.ALLOY_SMELTER_RECIPES.recipeBuilder() .input(ingot, material, 2) .notConsumable(MetaItems.SHAPE_MOLD_GEAR_SMALL.getStackForm()) .output(gearSmall, material) + .duration((int) material.getMass()) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); if (material.hasFlag(NO_SMASHING)) { @@ -239,10 +254,10 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp .notConsumable(MetaItems.SHAPE_EXTRUDER_GEAR_SMALL) .outputs(stack) .duration((int) material.getMass()) - .EUt(material.getBlastTemperature() >= 2800 ? 256 : 64) + .EUt(GTUtility.scaleVoltage(material.getBlastTemperature() >= 2800 ? 256 : 64, workingTier)) .buildAndRegister(); } - } else { + } else if (workingTier <= HV) { ModHandler.addShapedRecipe(String.format("gear_%s", material), stack, "RPR", "PwP", "RPR", 'P', new UnificationEntry(OrePrefix.plate, material), @@ -253,19 +268,24 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp public static void processLens(OrePrefix lensPrefix, Material material, GemProperty property) { ItemStack stack = OreDictUnifier.get(lensPrefix, material); + int workingTier = material.getWorkingTier(); LATHE_RECIPES.recipeBuilder() .input(plate, material) .output(lens, material) .output(dustSmall, material) - .duration(1200).EUt(120).buildAndRegister(); + .duration(1200) + .EUt(GTUtility.scaleVoltage(VA[MV], workingTier)) + .buildAndRegister(); if (!OreDictUnifier.get(gemExquisite, material).isEmpty()) { LATHE_RECIPES.recipeBuilder() .input(gemExquisite, material) .output(lens, material) .output(dust, material, 2) - .duration(2400).EUt(30).buildAndRegister(); + .duration(2400) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) + .buildAndRegister(); } if (material == Materials.Diamond) { // override Diamond Lens to be LightBlue @@ -292,23 +312,27 @@ public static void processPlate(OrePrefix platePrefix, Material material, DustPr .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L)) .outputs(OreDictUnifier.get(platePrefix, material)) .duration(40) - .EUt(VA[ULV]) + .EUt(GTUtility.scaleVoltage(VA[ULV], material.getWorkingTier())) .buildAndRegister(); } } public static void processPlateDouble(OrePrefix doublePrefix, Material material, IngotProperty property) { + int workingTier = material.getWorkingTier(); + if (material.hasFlag(GENERATE_PLATE)) { - if (!material.hasFlag(NO_SMASHING)) { + if (!material.hasFlag(NO_SMASHING) && workingTier <= HV) { ModHandler.addShapedRecipe(String.format("plate_double_%s", material), OreDictUnifier.get(doublePrefix, material), "h", "P", "P", 'P', new UnificationEntry(plate, material)); } - BENDER_RECIPES.recipeBuilder().EUt(96).duration((int) material.getMass() * 2) + BENDER_RECIPES.recipeBuilder() .input(plate, material, 2) .output(doublePrefix, material) .circuitMeta(2) + .duration((int) material.getMass() * 2) + .EUt(GTUtility.scaleVoltage(96, workingTier)) .buildAndRegister(); BENDER_RECIPES.recipeBuilder() @@ -316,18 +340,20 @@ public static void processPlateDouble(OrePrefix doublePrefix, Material material, .circuitMeta(2) .output(doublePrefix, material) .duration((int) material.getMass() * 2) - .EUt(96) + .EUt(GTUtility.scaleVoltage(96, workingTier)) .buildAndRegister(); } } public static void processPlateDense(OrePrefix orePrefix, Material material, DustProperty property) { + int workingTier = material.getWorkingTier(); + RecipeMaps.BENDER_RECIPES.recipeBuilder() .input(OrePrefix.plate, material, 9) .circuitMeta(9) .output(orePrefix, material) .duration((int) Math.max(material.getMass() * 9L, 1L)) - .EUt(96) + .EUt(GTUtility.scaleVoltage(96, workingTier)) .buildAndRegister(); if (material.hasProperty(PropertyKey.INGOT)) { @@ -336,69 +362,87 @@ public static void processPlateDense(OrePrefix orePrefix, Material material, Dus .circuitMeta(9) .output(orePrefix, material) .duration((int) Math.max(material.getMass() * 9L, 1L)) - .EUt(96) + .EUt(GTUtility.scaleVoltage(96, workingTier)) .buildAndRegister(); } } public static void processRing(OrePrefix ringPrefix, Material material, IngotProperty property) { + int workingTier = material.getWorkingTier(); + RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() .input(OrePrefix.ingot, material) .notConsumable(MetaItems.SHAPE_EXTRUDER_RING) .outputs(OreDictUnifier.get(ringPrefix, material, 4)) .duration((int) material.getMass() * 2) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); if (!material.hasFlag(NO_SMASHING)) { - ModHandler.addShapedRecipe(String.format("ring_%s", material), - OreDictUnifier.get(ringPrefix, material), - "h ", " X", - 'X', new UnificationEntry(OrePrefix.stick, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("ring_%s", material), + OreDictUnifier.get(ringPrefix, material), + "h ", " X", + 'X', new UnificationEntry(OrePrefix.stick, material)); + } } else { RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() .input(OrePrefix.dust, material) .notConsumable(MetaItems.SHAPE_EXTRUDER_RING) .outputs(OreDictUnifier.get(ringPrefix, material, 4)) .duration((int) material.getMass() * 2) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } } public static void processSpringSmall(OrePrefix springPrefix, Material material, IngotProperty property) { - ModHandler.addShapedRecipe(String.format("spring_small_%s", material.toString()), - OreDictUnifier.get(springSmall, material), - " s ", "fRx", 'R', new UnificationEntry(stick, material)); + int workingTier = material.getWorkingTier(); - BENDER_RECIPES.recipeBuilder().duration((int) (material.getMass() / 2)).EUt(VA[ULV]) + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("spring_small_%s", material.toString()), + OreDictUnifier.get(springSmall, material), + " s ", "fRx", 'R', new UnificationEntry(stick, material)); + } + + BENDER_RECIPES.recipeBuilder() .input(stick, material) .output(springSmall, material, 2) .circuitMeta(1) + .duration((int) (material.getMass() / 2)) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } public static void processSpring(OrePrefix springPrefix, Material material, IngotProperty property) { + int workingTier = material.getWorkingTier(); + RecipeMaps.BENDER_RECIPES.recipeBuilder() .input(stickLong, material) .outputs(OreDictUnifier.get(OrePrefix.spring, material)) .circuitMeta(1) .duration(200) - .EUt(16) + .EUt(GTUtility.scaleVoltage(16, workingTier)) .buildAndRegister(); - ModHandler.addShapedRecipe(String.format("spring_%s", material.toString()), - OreDictUnifier.get(spring, material), - " s ", "fRx", " R ", 'R', new UnificationEntry(stickLong, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("spring_%s", material.toString()), + OreDictUnifier.get(spring, material), + " s ", "fRx", " R ", 'R', new UnificationEntry(stickLong, material)); + } } public static void processRotor(OrePrefix rotorPrefix, Material material, IngotProperty property) { ItemStack stack = OreDictUnifier.get(rotorPrefix, material); - ModHandler.addShapedRecipe(String.format("rotor_%s", material.toString()), stack, - "ChC", "SRf", "CdC", - 'C', new UnificationEntry(plate, material), - 'S', new UnificationEntry(screw, material), - 'R', new UnificationEntry(ring, material)); + int workingTier = material.getWorkingTier(); + + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("rotor_%s", material.toString()), stack, + "ChC", "SRf", "CdC", + 'C', new UnificationEntry(plate, material), + 'S', new UnificationEntry(screw, material), + 'R', new UnificationEntry(ring, material)); + } if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() @@ -406,7 +450,7 @@ public static void processRotor(OrePrefix rotorPrefix, Material material, IngotP .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L * 4)) .outputs(GTUtility.copy(stack)) .duration(120) - .EUt(20) + .EUt(GTUtility.scaleVoltage(20, workingTier)) .buildAndRegister(); } @@ -415,7 +459,7 @@ public static void processRotor(OrePrefix rotorPrefix, Material material, IngotP .notConsumable(MetaItems.SHAPE_EXTRUDER_ROTOR) .outputs(GTUtility.copy(stack)) .duration((int) material.getMass() * 4) - .EUt(material.getBlastTemperature() >= 2800 ? 256 : 64) + .EUt(GTUtility.scaleVoltage(material.getBlastTemperature() >= 2800 ? 256 : 64, workingTier)) .buildAndRegister(); if (material.hasFlag(NO_SMASHING)) { @@ -424,17 +468,19 @@ public static void processRotor(OrePrefix rotorPrefix, Material material, IngotP .notConsumable(MetaItems.SHAPE_EXTRUDER_ROTOR) .outputs(GTUtility.copy(stack)) .duration((int) material.getMass() * 4) - .EUt(material.getBlastTemperature() >= 2800 ? 256 : 64) + .EUt(GTUtility.scaleVoltage(material.getBlastTemperature() >= 2800 ? 256 : 64, workingTier)) .buildAndRegister(); } } public static void processStick(OrePrefix stickPrefix, Material material, DustProperty property) { + int workingTier = material.getWorkingTier(); + if (material.hasProperty(PropertyKey.GEM) || material.hasProperty(PropertyKey.INGOT)) { RecipeBuilder builder = RecipeMaps.LATHE_RECIPES.recipeBuilder() .input(material.hasProperty(PropertyKey.GEM) ? OrePrefix.gem : OrePrefix.ingot, material) .duration((int) Math.max(material.getMass() * 2, 1)) - .EUt(16); + .EUt(GTUtility.scaleVoltage(16, workingTier)); if (ConfigHolder.recipes.harderRods) { builder.output(OrePrefix.stick, material); @@ -451,53 +497,59 @@ public static void processStick(OrePrefix stickPrefix, Material material, DustPr .input(stickPrefix, material) .outputs(GTUtility.copy(4, boltStack)) .duration((int) Math.max(material.getMass() * 2L, 1L)) - .EUt(4) + .EUt(GTUtility.scaleVoltage(4, workingTier)) .buildAndRegister(); - ModHandler.addShapedRecipe(String.format("bolt_saw_%s", material), - GTUtility.copy(2, boltStack), - "s ", " X", - 'X', new UnificationEntry(OrePrefix.stick, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("bolt_saw_%s", material), + GTUtility.copy(2, boltStack), + "s ", " X", + 'X', new UnificationEntry(OrePrefix.stick, material)); + } } } public static void processLongStick(OrePrefix longStickPrefix, Material material, DustProperty property) { ItemStack stack = OreDictUnifier.get(longStickPrefix, material); ItemStack stickStack = OreDictUnifier.get(OrePrefix.stick, material); + int workingTier = material.getWorkingTier(); RecipeMaps.CUTTER_RECIPES.recipeBuilder() .input(longStickPrefix, material) .outputs(GTUtility.copy(2, stickStack)) - .duration((int) Math.max(material.getMass(), 1L)).EUt(4) + .duration((int) Math.max(material.getMass(), 1L)) + .EUt(GTUtility.scaleVoltage(4, workingTier)) .buildAndRegister(); - ModHandler.addShapedRecipe(String.format("stick_long_%s", material), - GTUtility.copy(2, stickStack), - "s", "X", 'X', new UnificationEntry(OrePrefix.stickLong, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("stick_long_%s", material), + GTUtility.copy(2, stickStack), + "s", "X", 'X', new UnificationEntry(OrePrefix.stickLong, material)); - if (material.hasProperty(PropertyKey.GEM)) { - ModHandler.addShapedRecipe(String.format("stick_long_gem_flawless_%s", material), - stickStack, - "sf", - "G ", - 'G', new UnificationEntry(OrePrefix.gemFlawless, material)); + if (material.hasProperty(PropertyKey.GEM)) { + ModHandler.addShapedRecipe(String.format("stick_long_gem_flawless_%s", material), + stickStack, + "sf", + "G ", + 'G', new UnificationEntry(OrePrefix.gemFlawless, material)); - ModHandler.addShapedRecipe(String.format("stick_long_gem_exquisite_%s", material), - GTUtility.copy(2, stickStack), - "sf", "G ", - 'G', new UnificationEntry(OrePrefix.gemExquisite, material)); + ModHandler.addShapedRecipe(String.format("stick_long_gem_exquisite_%s", material), + GTUtility.copy(2, stickStack), + "sf", "G ", + 'G', new UnificationEntry(OrePrefix.gemExquisite, material)); - } + } - ModHandler.addShapedRecipe(String.format("stick_long_stick_%s", material), stack, - "ShS", - 'S', new UnificationEntry(OrePrefix.stick, material)); + ModHandler.addShapedRecipe(String.format("stick_long_stick_%s", material), stack, + "ShS", + 'S', new UnificationEntry(OrePrefix.stick, material)); + } RecipeMaps.FORGE_HAMMER_RECIPES.recipeBuilder() .input(OrePrefix.stick, material, 2) .outputs(stack) .duration((int) Math.max(material.getMass(), 1L)) - .EUt(16) + .EUt(GTUtility.scaleVoltage(16, workingTier)) .buildAndRegister(); if (material.hasProperty(PropertyKey.INGOT)) { @@ -506,7 +558,7 @@ public static void processLongStick(OrePrefix longStickPrefix, Material material .notConsumable(MetaItems.SHAPE_EXTRUDER_ROD_LONG) .outputs(stack) .duration((int) Math.max(material.getMass(), 1L)) - .EUt(64) + .EUt(GTUtility.scaleVoltage(64, workingTier)) .buildAndRegister(); if (material.hasFlag(NO_SMASHING)) { @@ -515,7 +567,7 @@ public static void processLongStick(OrePrefix longStickPrefix, Material material .notConsumable(MetaItems.SHAPE_EXTRUDER_ROD_LONG) .outputs(stack) .duration((int) Math.max(material.getMass(), 1L)) - .EUt(64) + .EUt(GTUtility.scaleVoltage(64, workingTier)) .buildAndRegister(); } } @@ -524,6 +576,7 @@ public static void processLongStick(OrePrefix longStickPrefix, Material material public static void processTurbine(OrePrefix toolPrefix, Material material, IngotProperty property) { ItemStack rotorStack = MetaItems.TURBINE_ROTOR.getStackForm(); AbstractMaterialPartBehavior.setPartMaterial(rotorStack, material); + int workingTier = material.getWorkingTier(); RecipeMaps.ASSEMBLER_RECIPES.recipeBuilder() .input(OrePrefix.turbineBlade, material, 8) @@ -539,10 +592,10 @@ public static void processTurbine(OrePrefix toolPrefix, Material material, Ingot .input(OrePrefix.screw, material, 2) .outputs(OreDictUnifier.get(toolPrefix, material)) .duration(20) - .EUt(256) + .EUt(GTUtility.scaleVoltage(256, workingTier)) .buildAndRegister(); - if (hasDoublePlate) { + if (hasDoublePlate && workingTier <= HV) { ModHandler.addShapedRecipe(String.format("turbine_blade_%s", material), OreDictUnifier.get(toolPrefix, material), "PPP", "SPS", "fPd", @@ -552,7 +605,9 @@ public static void processTurbine(OrePrefix toolPrefix, Material material, Ingot } public static void processRound(OrePrefix roundPrefix, Material material, IngotProperty property) { - if (!material.hasFlag(NO_SMASHING)) { + int workingTier = material.getWorkingTier(); + + if (!material.hasFlag(NO_SMASHING) && workingTier <= HV) { ModHandler.addShapedRecipe(String.format("round_%s", material), OreDictUnifier.get(round, material), @@ -563,13 +618,15 @@ public static void processRound(OrePrefix roundPrefix, Material material, IngotP "fIh", 'I', new UnificationEntry(ingot, material)); } - LATHE_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100) + LATHE_RECIPES.recipeBuilder() .input(nugget, material) .output(round, material) + .duration(100) + .EUt(GTUtility.scaleVoltage(VA[ULV], workingTier)) .buildAndRegister(); } - private static int getVoltageMultiplier(Material material) { + private static long getVoltageMultiplier(Material material) { return material.getBlastTemperature() > 2800 ? VA[LV] : VA[ULV]; } } diff --git a/src/main/java/gregtech/loaders/recipe/handlers/PipeRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/PipeRecipeHandler.java index bd58e4263e8..72b6373661e 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/PipeRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/PipeRecipeHandler.java @@ -80,6 +80,7 @@ private static void processRestrictivePipe(OrePrefix pipePrefix, Material materi private static void processPipeTiny(OrePrefix pipePrefix, Material material, IMaterialProperty property) { ItemStack pipeStack = OreDictUnifier.get(pipePrefix, material); + int workingTier = material.getWorkingTier(); // Some pipes like wood do not have an ingot if (material.hasProperty(PropertyKey.INGOT)) { @@ -88,7 +89,7 @@ private static void processPipeTiny(OrePrefix pipePrefix, Material material, IMa .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_TINY) .outputs(GTUtility.copy(2, pipeStack)) .duration((int) (material.getMass())) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } @@ -98,21 +99,25 @@ private static void processPipeTiny(OrePrefix pipePrefix, Material material, IMa .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_TINY) .outputs(GTUtility.copy(2, pipeStack)) .duration((int) (material.getMass())) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } else { if (ModHandler.isMaterialWood(material)) { - ModHandler.addShapedRecipe(String.format("tiny_%s_pipe", material), - GTUtility.copy(2, pipeStack), " s ", "rXw", - 'X', new UnificationEntry(OrePrefix.plank, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("tiny_%s_pipe", material), + GTUtility.copy(2, pipeStack), " s ", "rXw", + 'X', new UnificationEntry(OrePrefix.plank, material)); + } - ASSEMBLER_RECIPES.recipeBuilder().duration(200).EUt(VA[LV]) + ASSEMBLER_RECIPES.recipeBuilder() .input(plate, material) .circuitMeta(18) .fluidInputs(Glue.getFluid(10)) .output(pipePrefix, material, 2) + .duration(200) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); - } else { + } else if (workingTier <= HV) { ModHandler.addShapedRecipe(String.format("tiny_%s_pipe", material), GTUtility.copy(2, pipeStack), " s ", "hXw", 'X', new UnificationEntry(OrePrefix.plate, material)); @@ -122,6 +127,7 @@ private static void processPipeTiny(OrePrefix pipePrefix, Material material, IMa private static void processPipeSmall(OrePrefix pipePrefix, Material material, IMaterialProperty property) { ItemStack pipeStack = OreDictUnifier.get(pipePrefix, material); + int workingTier = material.getWorkingTier(); if (material.hasProperty(PropertyKey.INGOT)) { RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() @@ -129,7 +135,7 @@ private static void processPipeSmall(OrePrefix pipePrefix, Material material, IM .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_SMALL) .outputs(pipeStack) .duration((int) (material.getMass())) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } @@ -139,22 +145,26 @@ private static void processPipeSmall(OrePrefix pipePrefix, Material material, IM .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_SMALL) .outputs(pipeStack) .duration((int) (material.getMass())) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } else { if (ModHandler.isMaterialWood(material)) { - ModHandler.addShapedRecipe(String.format("small_%s_pipe", material), - pipeStack, "sXr", - 'X', new UnificationEntry(OrePrefix.plank, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("small_%s_pipe", material), + pipeStack, "sXr", + 'X', new UnificationEntry(OrePrefix.plank, material)); + } - ASSEMBLER_RECIPES.recipeBuilder().duration(200).EUt(VA[LV]) + ASSEMBLER_RECIPES.recipeBuilder() .input(plate, material) .circuitMeta(12) .fluidInputs(Glue.getFluid(10)) .output(pipePrefix, material) + .duration(200) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); - } else { + } else if (workingTier <= HV) { ModHandler.addShapedRecipe(String.format("small_%s_pipe", material), pipeStack, "wXh", 'X', new UnificationEntry(OrePrefix.plate, material)); @@ -164,6 +174,7 @@ private static void processPipeSmall(OrePrefix pipePrefix, Material material, IM private static void processPipeNormal(OrePrefix pipePrefix, Material material, IMaterialProperty property) { ItemStack pipeStack = OreDictUnifier.get(pipePrefix, material); + int workingTier = material.getWorkingTier(); if (material.hasProperty(PropertyKey.INGOT)) { RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() @@ -171,7 +182,7 @@ private static void processPipeNormal(OrePrefix pipePrefix, Material material, I .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_NORMAL) .outputs(pipeStack) .duration((int) material.getMass() * 3) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } @@ -181,22 +192,26 @@ private static void processPipeNormal(OrePrefix pipePrefix, Material material, I .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_NORMAL) .outputs(pipeStack) .duration((int) material.getMass() * 3) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } else { if (ModHandler.isMaterialWood(material)) { - ModHandler.addShapedRecipe(String.format("medium_%s_pipe", material), - pipeStack, "XXX", "s r", - 'X', new UnificationEntry(OrePrefix.plank, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("medium_%s_pipe", material), + pipeStack, "XXX", "s r", + 'X', new UnificationEntry(OrePrefix.plank, material)); + } - ASSEMBLER_RECIPES.recipeBuilder().duration(200).EUt(VA[LV]) + ASSEMBLER_RECIPES.recipeBuilder() .input(plate, material, 3) .circuitMeta(6) .fluidInputs(Glue.getFluid(20)) .output(pipePrefix, material) + .duration(200) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); - } else { + } else if (workingTier <= HV) { ModHandler.addShapedRecipe(String.format("medium_%s_pipe", material), pipeStack, "XXX", "w h", 'X', new UnificationEntry(OrePrefix.plate, material)); @@ -206,6 +221,7 @@ private static void processPipeNormal(OrePrefix pipePrefix, Material material, I private static void processPipeLarge(OrePrefix pipePrefix, Material material, IMaterialProperty property) { ItemStack pipeStack = OreDictUnifier.get(pipePrefix, material); + int workingTier = material.getWorkingTier(); if (material.hasProperty(PropertyKey.INGOT)) { RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() @@ -213,7 +229,7 @@ private static void processPipeLarge(OrePrefix pipePrefix, Material material, IM .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_LARGE) .outputs(pipeStack) .duration((int) material.getMass() * 6) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } @@ -223,21 +239,25 @@ private static void processPipeLarge(OrePrefix pipePrefix, Material material, IM .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_LARGE) .outputs(pipeStack) .duration((int) material.getMass() * 6) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } else { if (ModHandler.isMaterialWood(material)) { - ModHandler.addShapedRecipe(String.format("large_%s_pipe", material), - pipeStack, "XXX", "s r", "XXX", - 'X', new UnificationEntry(OrePrefix.plank, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("large_%s_pipe", material), + pipeStack, "XXX", "s r", "XXX", + 'X', new UnificationEntry(OrePrefix.plank, material)); + } - ASSEMBLER_RECIPES.recipeBuilder().duration(100).EUt(VA[LV]) + ASSEMBLER_RECIPES.recipeBuilder() .input(plate, material, 6) .circuitMeta(2) .fluidInputs(Glue.getFluid(50)) .output(pipePrefix, material) + .duration(100) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); - } else { + } else if (workingTier <= HV) { ModHandler.addShapedRecipe(String.format("large_%s_pipe", material), pipeStack, "XXX", "w h", "XXX", 'X', new UnificationEntry(OrePrefix.plate, material)); @@ -247,6 +267,7 @@ private static void processPipeLarge(OrePrefix pipePrefix, Material material, IM private static void processPipeHuge(OrePrefix pipePrefix, Material material, IMaterialProperty property) { ItemStack pipeStack = OreDictUnifier.get(pipePrefix, material); + int workingTier = material.getWorkingTier(); if (material.hasProperty(PropertyKey.INGOT)) { RecipeMaps.EXTRUDER_RECIPES.recipeBuilder() @@ -254,7 +275,7 @@ private static void processPipeHuge(OrePrefix pipePrefix, Material material, IMa .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_HUGE) .outputs(pipeStack) .duration((int) material.getMass() * 24) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } @@ -264,21 +285,25 @@ private static void processPipeHuge(OrePrefix pipePrefix, Material material, IMa .notConsumable(MetaItems.SHAPE_EXTRUDER_PIPE_HUGE) .outputs(pipeStack) .duration((int) material.getMass() * 24) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } else if (OrePrefix.plateDouble.doGenerateItem(material)) { if (ModHandler.isMaterialWood(material)) { - ModHandler.addShapedRecipe(String.format("huge_%s_pipe", material), - pipeStack, "XXX", "s r", "XXX", - 'X', new UnificationEntry(OrePrefix.plateDouble, material)); + if (workingTier <= HV) { + ModHandler.addShapedRecipe(String.format("huge_%s_pipe", material), + pipeStack, "XXX", "s r", "XXX", + 'X', new UnificationEntry(OrePrefix.plateDouble, material)); + } - ASSEMBLER_RECIPES.recipeBuilder().duration(100).EUt(VA[LV]) + ASSEMBLER_RECIPES.recipeBuilder() .input(plateDouble, material, 6) .circuitMeta(24) .fluidInputs(Glue.getFluid(100)) .output(pipePrefix, material) + .duration(100) + .EUt(GTUtility.scaleVoltage(VA[LV], workingTier)) .buildAndRegister(); - } else { + } else if (workingTier <= HV) { ModHandler.addShapedRecipe(String.format("huge_%s_pipe", material), pipeStack, "XXX", "w h", "XXX", 'X', new UnificationEntry(OrePrefix.plateDouble, material)); @@ -318,7 +343,7 @@ private static void processPipeNonuple(OrePrefix pipePrefix, Material material, .buildAndRegister(); } - private static int getVoltageMultiplier(Material material) { + private static long getVoltageMultiplier(Material material) { return material.getBlastTemperature() >= 2800 ? VA[LV] : VA[ULV]; } } diff --git a/src/main/java/gregtech/loaders/recipe/handlers/ToolRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/ToolRecipeHandler.java index c33821d80d9..502c6309a28 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/ToolRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/ToolRecipeHandler.java @@ -15,6 +15,7 @@ import gregtech.api.unification.material.properties.PropertyKey; import gregtech.api.unification.ore.OrePrefix; import gregtech.api.unification.stack.UnificationEntry; +import gregtech.api.util.GTUtility; import gregtech.common.crafting.ToolHeadReplaceRecipe; import gregtech.common.items.MetaItems; import gregtech.common.items.ToolItems; @@ -237,7 +238,7 @@ private static void processTool(OrePrefix prefix, Material material, MaterialToo } private static void processElectricTool(OrePrefix prefix, Material material, MaterialToolProperty property) { - final int voltageMultiplier = material.getBlastTemperature() > 2800 ? VA[LV] : VA[ULV]; + final long voltageMultiplier = material.getBlastTemperature() > 2800 ? VA[LV] : VA[ULV]; OrePrefix toolPrefix; if (material.hasFlag(GENERATE_PLATE)) { @@ -293,7 +294,7 @@ private static void processElectricTool(OrePrefix prefix, Material material, Mat .input(OrePrefix.gear, material) .output(toolPrefix, material) .duration((int) material.getMass() * 4) - .EUt(8 * voltageMultiplier) + .EUt(GTUtility.scaleVoltage(8 * voltageMultiplier, material.getWorkingTier())) .buildAndRegister(); } diff --git a/src/main/java/gregtech/loaders/recipe/handlers/WireRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/WireRecipeHandler.java index 129150429d5..ead8bc0b1d2 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/WireRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/WireRecipeHandler.java @@ -66,13 +66,14 @@ public static void register() { public static void processWireSingle(OrePrefix wirePrefix, Material material, WireProperties property) { OrePrefix prefix = material.hasProperty(PropertyKey.INGOT) ? ingot : material.hasProperty(PropertyKey.GEM) ? gem : dust; + int workingTier = material.getWorkingTier(); EXTRUDER_RECIPES.recipeBuilder() .input(prefix, material) .notConsumable(SHAPE_EXTRUDER_WIRE) .output(wireGtSingle, material, 2) .duration((int) material.getMass() * 2) - .EUt(6 * getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier)) .buildAndRegister(); WIREMILL_RECIPES.recipeBuilder() @@ -80,7 +81,7 @@ public static void processWireSingle(OrePrefix wirePrefix, Material material, Wi .circuitMeta(1) .output(wireGtSingle, material, 2) .duration((int) material.getMass()) - .EUt(getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(getVoltageMultiplier(material), workingTier)) .buildAndRegister(); for (OrePrefix wireSize : wireSizes) { @@ -90,11 +91,11 @@ public static void processWireSingle(OrePrefix wirePrefix, Material material, Wi .circuitMeta(multiplier * 2) .output(wireSize, material) .duration((int) (material.getMass() * multiplier)) - .EUt(getVoltageMultiplier(material)) + .EUt(GTUtility.scaleVoltage(getVoltageMultiplier(material), workingTier)) .buildAndRegister(); } - if (!material.hasFlag(NO_WORKING) && material.hasFlag(GENERATE_PLATE)) { + if (!material.hasFlag(NO_WORKING) && material.hasFlag(GENERATE_PLATE) && workingTier <= HV) { ModHandler.addShapedRecipe(String.format("%s_wire_single", material), OreDictUnifier.get(wireGtSingle, material), "Xx", 'X', new UnificationEntry(plate, material)); @@ -185,7 +186,7 @@ private static void generateManualRecipe(OrePrefix wirePrefix, Material material .buildAndRegister(); } - private static int getVoltageMultiplier(Material material) { + private static long getVoltageMultiplier(Material material) { return material.getBlastTemperature() >= 2800 ? VA[LV] : VA[ULV]; } } diff --git a/src/test/java/gregtech/api/util/VoltageScaleTest.java b/src/test/java/gregtech/api/util/VoltageScaleTest.java new file mode 100644 index 00000000000..d7d84c0350b --- /dev/null +++ b/src/test/java/gregtech/api/util/VoltageScaleTest.java @@ -0,0 +1,43 @@ +package gregtech.api.util; + +import gregtech.api.GTValues; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class VoltageScaleTest { + + @Test + public void testVoltages() { + // Some commonly used numbers for recipe voltages. Ensure none change at LV scaling tier + assertEquals(2, GTUtility.scaleVoltage(2, GTValues.LV)); + assertEquals(4, GTUtility.scaleVoltage(4, GTValues.LV)); + assertEquals(7, GTUtility.scaleVoltage(7, GTValues.LV)); + assertEquals(8, GTUtility.scaleVoltage(8, GTValues.LV)); + assertEquals(16, GTUtility.scaleVoltage(16, GTValues.LV)); + assertEquals(24, GTUtility.scaleVoltage(24, GTValues.LV)); + assertEquals(30, GTUtility.scaleVoltage(30, GTValues.LV)); + // Also test that voltages above are not affected. + assertEquals(120, GTUtility.scaleVoltage(120, GTValues.LV)); + + // Test to make sure they scale to above LV, with the appropriate scaled voltage + // The first few are capped at half voltage. + assertEquals(GTValues.VHA[GTValues.MV], GTUtility.scaleVoltage(2, GTValues.MV)); + assertEquals(GTValues.VHA[GTValues.MV], GTUtility.scaleVoltage(4, GTValues.MV)); + assertEquals(GTValues.VHA[GTValues.MV], GTUtility.scaleVoltage(7, GTValues.MV)); + assertEquals(GTValues.VHA[GTValues.MV], GTUtility.scaleVoltage(8, GTValues.MV)); + assertEquals(GTValues.VHA[GTValues.MV], GTUtility.scaleVoltage(16, GTValues.MV)); + // The remaining should scale depending on their actual voltage + assertEquals(96, GTUtility.scaleVoltage(24, GTValues.MV)); + assertEquals(120, GTUtility.scaleVoltage(30, GTValues.MV)); + // Ensure a recipe will not exceed VA, even if the provided value "should" scale higher + assertEquals(120, GTUtility.scaleVoltage(32, GTValues.MV)); + // Test that voltages already at MV are unaffected. + assertEquals(33, GTUtility.scaleVoltage(33, GTValues.MV)); + assertEquals(120, GTUtility.scaleVoltage(120, GTValues.MV)); + // Also test that voltages above are still unaffected. + assertEquals(129, GTUtility.scaleVoltage(129, GTValues.MV)); + assertEquals(480, GTUtility.scaleVoltage(480, GTValues.MV)); + } +}