Skip to content

Commit

Permalink
GT recipe.cfg cleanup (#2579)
Browse files Browse the repository at this point in the history
* ichorium block fixes

* alu ingot fix

* iridium ore fix

* gt vanilla assembling fixes

* ic2 assembler recipe fix

* forestry assembler recipe fixes

* spotless

* electrolyzer

* more iridium ore fixes

* another ichorium block fix

* obsidian stick fix

* remove unused railcraft obsidian recipes

* remove disabled melon recipe

* bring custom plasma fuel values to code

* spotless

* remove most recipe config uses

* fully remove recipe.cfg

* dont change recipemapbackend for now

(cherry picked from commit 27bbb51)
  • Loading branch information
chochem authored and Dream-Master committed May 3, 2024
1 parent 111aded commit c752c86
Show file tree
Hide file tree
Showing 29 changed files with 647 additions and 897 deletions.
21 changes: 7 additions & 14 deletions src/main/java/gregtech/GT_Mod.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import gregtech.api.enchants.Enchantment_EnderDamage;
import gregtech.api.enchants.Enchantment_Hazmat;
import gregtech.api.enchants.Enchantment_Radioactivity;
import gregtech.api.enums.ConfigCategories;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
Expand Down Expand Up @@ -439,14 +438,12 @@ public void onPostLoad(FMLPostInitializationEvent aEvent) {
null,
null),
new ItemData(Materials.Tin, 10886400L));
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.storageblockcrafting, "tile.glowstone", false)) {
GT_ModHandler.removeRecipe(
new ItemStack(Items.glowstone_dust, 1),
new ItemStack(Items.glowstone_dust, 1),
null,
new ItemStack(Items.glowstone_dust, 1),
new ItemStack(Items.glowstone_dust, 1));
}
GT_ModHandler.removeRecipe(
new ItemStack(Items.glowstone_dust, 1),
new ItemStack(Items.glowstone_dust, 1),
null,
new ItemStack(Items.glowstone_dust, 1),
new ItemStack(Items.glowstone_dust, 1));
GT_ModHandler.removeRecipeDelayed(
new ItemStack(Blocks.wooden_slab, 1, 0),
new ItemStack(Blocks.wooden_slab, 1, 1),
Expand Down Expand Up @@ -484,9 +481,7 @@ public void onPostLoad(FMLPostInitializationEvent aEvent) {
.getDisplayName()));
}
new GT_CraftingRecipeLoader().run();
if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, "ic2forgehammer", true)) {
GT_ModHandler.removeRecipeByOutput(ItemList.IC2_ForgeHammer.getWildcard(1L));
}
GT_ModHandler.removeRecipeByOutput(ItemList.IC2_ForgeHammer.getWildcard(1L));
GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item("machine", 1L));
GT_ModHandler.addCraftingRecipe(
GT_ModHandler.getIC2Item("machine", 1L),
Expand Down Expand Up @@ -517,8 +512,6 @@ public void onPostLoad(FMLPostInitializationEvent aEvent) {
new String[] { "blastfurnace", "blockcutter", "inductionFurnace", "generator", "windMill", "waterMill",
"solarPanel", "centrifuge", "electrolyzer", "compressor", "electroFurnace", "extractor",
"macerator", "recycler", "metalformer", "orewashingplant", "massFabricator", "replicator", })
.filter(
tName -> GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + tName, true))
.map(tName -> GT_ModHandler.getIC2Item(tName, 1L))
.forEach(GT_ModHandler::removeRecipeByOutputDelayed);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/GregTech_API.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ public class GregTech_API {
/**
* The Configuration Objects
*/
public static GT_Config sRecipeFile = null, sMachineFile = null, sWorldgenFile = null, sMaterialProperties = null,
sUnification = null, sSpecialFile = null, sClientDataFile, sOPStuff = null;
public static GT_Config sMachineFile = null, sWorldgenFile = null, sMaterialProperties = null, sUnification = null,
sSpecialFile = null, sClientDataFile, sOPStuff = null;

public static int TICKS_FOR_LAG_AVERAGING = 25, MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING = 100;
/**
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/gregtech/api/enums/ConfigCategories.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ public enum Materials {
}

public enum Recipes {
researches,
harderrecipes,
gregtechrecipes,
disabledrecipes,
recipereplacements,
storageblockcrafting,
storageblockdecrafting,
crops
storageblockdecrafting
}

public enum Machines {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/gregtech/api/recipe/RecipeMapBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ protected Collection<GT_Recipe> doAdd(GT_RecipeBuilder builder) {
if (properties.recipeConfigCategory != null) {
assert properties.recipeConfigKeyConvertor != null;
String configKey = properties.recipeConfigKeyConvertor.apply(recipe);
if (configKey != null && (recipe.mDuration = GregTech_API.sRecipeFile
.get(properties.recipeConfigCategory, configKey, recipe.mDuration)) <= 0) {
if (configKey != null && recipe.mDuration <= 0) {
continue;
}
}
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/gregtech/api/util/GT_BaseCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,10 @@ public GT_BaseCrop(int aID, String aCropName, String aDiscoveredBy, ItemStack aB
mStats[4] = aStatWeed;
mAttributes = aAttributes;
mBlock = aBlock;
if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.crops, aCropName, true)) {
if (!Crops.instance.registerCrop(this, aID))
throw new GT_ItsNotMyFaultException("Make sure the Crop ID is valid!");
if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1);
sCropList.add(this);
}
if (!Crops.instance.registerCrop(this, aID))
throw new GT_ItsNotMyFaultException("Make sure the Crop ID is valid!");
if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1);
sCropList.add(this);
}
if (bIc2NeiLoaded) {
try {
Expand Down Expand Up @@ -226,7 +224,7 @@ public int getOptimalHavestSize(ICropTile crop) {

/**
* Checks if the crop needs a block below it
*
*
* @return True if the crop needs a block below it to grow to its max size
*/
public boolean needsBlockBelow() {
Expand Down Expand Up @@ -263,7 +261,7 @@ public boolean isBlockBelow(ICropTile aCrop) {

/**
* An isolated function to check if an item stack is a block that should be below this crop
*
*
* @param aItem a stack of the block placed under the crop
* @return The result of the check
*/
Expand Down
17 changes: 1 addition & 16 deletions src/main/java/gregtech/api/util/GT_ModHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ConfigCategories;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
Expand Down Expand Up @@ -494,8 +493,6 @@ public static boolean addScrapboxDrop(float aChance, ItemStack aOutput) {
if (aOutput == null || aChance <= 0) return false;
aOutput.stackSize = 1;
if (GT_Config.troll && !GT_Utility.areStacksEqual(aOutput, new ItemStack(Items.wooden_hoe, 1, 0))) return false;
aChance = (float) GregTech_API.sRecipeFile.get(ConfigCategories.Machines.scrapboxdrops, aOutput, aChance);
if (aChance <= 0) return false;
try {
GT_Utility.callMethod(
GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true),
Expand Down Expand Up @@ -538,7 +535,6 @@ public static boolean addToRecyclerBlackList(ItemStack aRecycledStack) {
public static boolean addSmeltingRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.smelting, aInput, true)) return false;
FurnaceRecipes.smelting()
.func_151394_a(aInput, GT_Utility.copyOrNull(aOutput), 0.0F);
return true;
Expand All @@ -562,18 +558,14 @@ public static boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemSt
|| (OrePrefixes.gem.contains(aInput)))) {
return false;
}
int duration = GregTech_API.sRecipeFile.get("alloysmelting", input2 == null ? aInput : aOutput, 130);
if (duration <= 0) {
return false;
}
GT_RecipeBuilder recipeBuilder = GT_Values.RA.stdBuilder();
if (input2 == null) {
recipeBuilder.itemInputs(aInput);
} else {
recipeBuilder.itemInputs(aInput, input2);
}
recipeBuilder.itemOutputs(aOutput)
.duration(duration * TICKS)
.duration(6 * SECONDS + 10 * TICKS)
.eut(3)
.recipeCategory(RecipeCategories.alloySmelterRecycling);
if (hidden) {
Expand Down Expand Up @@ -617,7 +609,6 @@ public static boolean addLiquidTransposerEmptyRecipe(ItemStack aFullContainer, F
public static boolean addExtractionRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.extractor, aInput, true)) return false;
RA.stdBuilder()
.itemInputs(aInput)
.itemOutputs(aOutput)
Expand Down Expand Up @@ -894,7 +885,6 @@ public static Map<IRecipeInput, RecipeOutput> getMassFabricatorList() {
@Deprecated
public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int[] aChances, int aHeat, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false;
RA.addThermalCentrifugeRecipe(
aInput,
(ItemStack) aOutput[0],
Expand All @@ -909,7 +899,6 @@ public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int[] aChance
@Deprecated
public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false;
RA.addThermalCentrifugeRecipe(
aInput,
(ItemStack) aOutput[0],
Expand All @@ -925,7 +914,6 @@ public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Ob
*/
public static boolean addOreWasherRecipe(ItemStack aInput, int[] aChances, int aWaterAmount, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false;
RA.stdBuilder()
.itemInputs(aInput)
.itemOutputs((ItemStack) aOutput[0], (ItemStack) aOutput[1], (ItemStack) aOutput[2])
Expand All @@ -948,7 +936,6 @@ public static boolean addOreWasherRecipe(ItemStack aInput, int[] aChances, int a

public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false;
RA.stdBuilder()
.itemInputs(aInput)
.itemOutputs((ItemStack) aOutput[0], (ItemStack) aOutput[1], (ItemStack) aOutput[2])
Expand Down Expand Up @@ -982,7 +969,6 @@ public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput)
public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput, int duration, int EUPerTick) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null || GT_Utility.areStacksEqual(aInput, aOutput, true)) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.compression, aInput, true)) return false;
RA.addCompressorRecipe(aInput, aOutput, duration, EUPerTick);
return true;
}
Expand All @@ -992,7 +978,6 @@ public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput,
*/
public static boolean addIC2MatterAmplifier(ItemStack aAmplifier, int aValue) {
if (aAmplifier == null || aValue <= 0) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.massfabamplifier, aAmplifier, true)) return false;
try {
NBTTagCompound tNBT = new NBTTagCompound();
tNBT.setInteger("amplification", aValue);
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/gregtech/api/util/GT_RecipeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraftforge.fluids.FluidStack;

import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.IRecipeMap;
Expand Down Expand Up @@ -105,7 +104,7 @@ public class GT_RecipeConstants {
if (!GT_Utility.isArrayOfLength(builder.getItemInputsBasic(), 1)
|| GT_Utility.isArrayEmptyOrNull(builder.getItemOutputs())) return Collections.emptyList();
int aDuration = builder.getDuration();
if ((aDuration = GregTech_API.sRecipeFile.get("arcfurnace", builder.getItemInputBasic(0), aDuration)) <= 0) {
if (aDuration <= 0) {
return Collections.emptyList();
}
builder.duration(aDuration);
Expand Down Expand Up @@ -291,10 +290,7 @@ public class GT_RecipeConstants {
if (!builder.isValid()) return Collections.emptyList();
Integer fuelType = builder.getMetadata(FUEL_TYPE);
if (fuelType == null) return Collections.emptyList();
builder.metadata(
FUEL_VALUE,
GregTech_API.sRecipeFile
.get("fuel_" + fuelType, builder.getItemInputBasic(0), builder.getMetadataOrDefault(FUEL_VALUE, 0)));
builder.metadata(FUEL_VALUE, builder.getMetadataOrDefault(FUEL_VALUE, 0));
return FuelType.get(fuelType)
.getTarget()
.doAdd(builder);
Expand Down
57 changes: 26 additions & 31 deletions src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import cpw.mods.fml.relauncher.ReflectionHelper;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ConfigCategories;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
Expand Down Expand Up @@ -183,19 +182,19 @@ public static void registerMaterialRecycling(ItemStack aStack, ItemData aData) {
|| GT_Utility.getFluidForFilledItem(aStack, false) != null
|| aData.mMaterial.mMaterial.mSubTags.contains(SubTag.NO_RECIPES)) return;
registerReverseMacerating(GT_Utility.copyAmount(1, aStack), aData, aData.mPrefix == null);
registerReverseSmelting(
GT_Utility.copyAmount(1, aStack),
aData.mMaterial.mMaterial,
aData.mMaterial.mAmount,
true);
if (!GT_Utility.areStacksEqual(GT_ModHandler.getIC2Item("iridiumOre", 1L), aStack)) {
registerReverseSmelting(
GT_Utility.copyAmount(1, aStack),
aData.mMaterial.mMaterial,
aData.mMaterial.mAmount,
true);
registerReverseFluidSmelting(
GT_Utility.copyAmount(1, aStack),
aData.mMaterial.mMaterial,
aData.mMaterial.mAmount,
aData.getByProduct(0));
registerReverseArcSmelting(GT_Utility.copyAmount(1, aStack), aData);
}
registerReverseArcSmelting(GT_Utility.copyAmount(1, aStack), aData);
}

/**
Expand Down Expand Up @@ -604,30 +603,26 @@ private static synchronized void registerStickStuff(String aPlate, ItemData aIte

if (aRecipeReplacing && aPlate != null && sShapesA[i] != null && sShapesA[i].length > 1) {
assert aItemData != null;
if (GregTech_API.sRecipeFile.get(
ConfigCategories.Recipes.recipereplacements,
aItemData.mMaterial.mMaterial + "." + sShapesA[i][0],
true)) {
if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe.shape))) {
switch (sShapesA[i].length) {
case 2 -> GT_ModHandler.addCraftingRecipe(
tStack,
GT_ModHandler.RecipeBits.BUFFERED,
new Object[] { sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0),
OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData });
case 3 -> GT_ModHandler.addCraftingRecipe(
tStack,
GT_ModHandler.RecipeBits.BUFFERED,
new Object[] { sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate,
s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0),
aItemData });
default -> GT_ModHandler.addCraftingRecipe(
tStack,
GT_ModHandler.RecipeBits.BUFFERED,
new Object[] { sShapesA[i][1], sShapesA[i][2], sShapesA[i][3],
s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial),
s_I.charAt(0), aItemData });
}

if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe.shape))) {
switch (sShapesA[i].length) {
case 2 -> GT_ModHandler.addCraftingRecipe(
tStack,
GT_ModHandler.RecipeBits.BUFFERED,
new Object[] { sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0),
OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData });
case 3 -> GT_ModHandler.addCraftingRecipe(
tStack,
GT_ModHandler.RecipeBits.BUFFERED,
new Object[] { sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate,
s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0),
aItemData });
default -> GT_ModHandler.addCraftingRecipe(
tStack,
GT_ModHandler.RecipeBits.BUFFERED,
new Object[] { sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], s_P.charAt(0),
aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0),
aItemData });
}
}
}
Expand Down
Loading

0 comments on commit c752c86

Please sign in to comment.